first, the solution didn't work in my code pandas merge on date column issue
I have two data frame comes from mysql query result, both of them have 'captureDate' column. In mysql table, the data type is 'date'. In the data frame, the data type is object.
df1['captureDate'] data
0 2017-06-28
1 2017-06-28
2 2017-06-28
3 2017-06-28
4 2017-06-28
5 2017-06-28
6 2017-06-28
Name: captureDate, dtype: object
df2['captureDate'] data
0 2017-06-28
1 2017-06-28
2 2017-06-28
3 2017-06-28
4 2017-06-28
5 2017-06-28
6 2017-06-28
Name: captureDate, dtype: object
when I compare the column of df1 and df2, it returns True
print df1['captureDate'].equals(df2['captureDate'])
my merge code
inner = pd.merge(df1, df2, on='captureDate', how='inner')
but, the result is wrong, it returned 49 rows. The inner info is blow:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 49 entries, 0 to 48
Data columns (total 20 columns):
rule_id_x 49 non-null int64
monitor_sites_x 49 non-null object
rule_type_x 49 non-null int64
lower_limit_x 49 non-null int64
upper_limit_x 49 non-null int64
actual_x 49 non-null int64
predict_x 49 non-null int64
captureDate 49 non-null object
deviation_x 49 non-null float32
create_time_x 49 non-null int64
actual_y 49 non-null int64
create_time_y 49 non-null int64
deviation_y 49 non-null object
id 49 non-null int64
lower_limit_y 49 non-null int64
monitor_sites_y 49 non-null object
predict_y 49 non-null int64
rule_id_y 49 non-null object
rule_type_y 49 non-null int64
upper_limit_y 49 non-null int64
so, why it happens and how to handle this issue?