I have a dataframe that includes columns with time and Date as objects dtypes
I want to convert the columns to Time and DateTime dtypes
When i try to convert it display the below error for the Date:
TypeError: 'Series' object is not callable
code:
import pandas as pd
df=pd.DataFrame( { 'time': ['22:00:00', 'nan', '00:45:00', 'nan'], 'date': ['2020-09-30T00:00:00+03:00','0001-01-01T00:00:00+02:22','2020-10-01T00:00:00+03:00','0001-01-01T00:00:00+02:22'] }) df["date"]=df["date"].fillna("00/00/0000") df["date"] = pd.to_datetime(df["date"],errors='coerce',format='%d%m%y') df["time"]=df["time"].fillna("00:00:00") df["time"] = pd.to_timedelta(df["time"].str.strip()) print(df.info())
How to fix this error??
https://stackoverflow.com/questions/67408020/how-to-convert-column-dtypes-for-datetime-and-time-in-pandas May 06, 2021 at 04:00AM
没有评论:
发表评论