im getting this:You are trying to merge on datetime64[ns, UTC] and object columns for…
- User
im getting this:You are trying to merge on datetime64[ns, UTC] and object columns for key 'Date'. If you wish to proceed you should use pd.concat
my code: def merge_valid_files(combined_df): global df_merged first = True
codefor valid_extra in os.listdir(valid_extras_directory): if valid_extra.endswith(".csv"): valid_extra_path = os.path.join(valid_extras_directory, valid_extra) extra_data = pd.read_csv(valid_extra_path) extra_data['Date'] = pd.to_datetime(extra_data['Date'], format="ISO8601", utc=True) extra_data['Date'] = extra_data['Date'].dt.date if first: df_merged = combined_df.merge(extra_data, how='left', on='Date') first = False else: df_merged = df_merged.merge(extra_data, how='left', on='Date') return df_merged - Assistant
Your issue arises because you are trying to merge DataFrames where the 'Date' column in one is of type
datetime64[ns, UTC](specifically with timezone information) and in the other is of typeobject, due to converting it to date with.dt.datewhich effectively changes the data type to Python's date object, not a pandas datetime type which can handle timezones.