Zanam Zanam - 1 year ago 172
Python Question

Intersection of multiple pandas dataframe

I have a number of dataframes in a list as:

frameList = [df1,df2,..,df100]

Each dataframe is made of first column as
and second column is

How do I find common temperature column from all the dataframes in the list by intersecting it on
. Using pandas
is not going to work as I will have to redo pairwise intersection multiple times.


Changed the column heading to only intersection as I think word
was confusing.


My final output should have
as first column followed by Temperature from df1, Temperature from df2, Temperature from df3, .., Temperature from df100.

Answer Source

you can try using reduce functionality in python..something like this

dfs = [df0, df1, df2, dfN]
df_final = reduce(lambda left,right: pd.merge(left,right,on='DateTime'), dfs)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download