When updating a dataframe with another dataframe you need to have them being the same dtype in the columns.
to_numeric()
- provides functionality to safely convert non-numeric types (e.g. strings) to a suitable numeric type. (See also to_datetime()
and to_timedelta()
.)
astype()
- convert (almost) any type to (almost) any other type (even if it's not necessarily sensible to do so). Also allows you to convert to categorial types (very useful).
infer_objects()
- a utility method to convert object columns holding Python objects to a pandas type if possible.
convert_dtypes()
- convert DataFrame columns to the "best possible" dtype that supports pd.NA
(pandas' object to indicate a missing value).
see Change column type in pandas for more information on these instructions
However you need to convert the columns to dates. specifically datetime64[ns] for this you need
df['Column2'] = pd.to_datetime(df['Column2'])
df['Column3'] = pd.to_datetime(df['Column3'])
df['Column5'] = pd.to_datetime(df['Column5'])
df['Column6'] = pd.to_datetime(df['Column6'])
remember to not update until they both have the same dtypes
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…