Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is concat adding time to the date when concat two dataframes

Tags:

python

pandas

I am using pandas to get data from a sql query and json. I inspected both dataframes and the both have just the dates with no time. When I concat them it adds 00:00:00 to the date of one of the dataframes in the new dataframe. Why is it doing this. And is there a work around.

I am trying to join 2 dataframes and drop_duplicates but this prevents it from functioning properly by the date unless I specify other columns in the drop_duplicates.

like image 892
Eric Avatar asked Jul 30 '26 09:07

Eric


1 Answers

Although I don't understand the underlying problem with the concat adding 00:00:00 after the date of one of the dataframes this code in the concat fixed it

    pdjoin = pd.concat([pdhistory.astype({'date': 'str'}), pdtest.astype({'date': 'str'})])
like image 102
Eric Avatar answered Aug 01 '26 23:08

Eric