I have a list of dataframes as:
[df1, df2, df3, ..., df100, oddDF]
Each dataframe dfi
has DateTime
as column1 and Temperature
as column2. Except the dataframe oddDF
which has DateTime
as column1 and has temperature columns in column2 and column3.
I am looking to create a list of dataframe or one dataframe which has the common temperatures from each of df1, .. df100 and oddDF
I am trying the following:
dfs = [df0, df1, df2, .., df100, oddDF]
df_final = reduce(lambda left,right: pd.merge(left,right,on='DateTime'), dfs)
But it produces df_final
as empty
If however I do just:
dfs = [df0, df1, df2, .., df100]
df_final = reduce(lambda left,right: pd.merge(left,right,on='DateTime'), dfs)
df_final
produces the right answer.
How do I incorporate oddDF
in the code also. I have checked to make sure that oddDF's
DateTime
column has the common dates with
df1, df2, .., df100