print(data["Date Time"]
data["Date Time"] = data["Date Time"].str.replace("Verkauft","")
print(data["Date Time"]
above DataFrame is dtype: object
i want to convert into datetime to use it for visualization
data["Date Time"] = pd.to_datetime(data["Date Time"],format="%d%M%Y")
Error Output:
Update:
i added:
data["Date Time"] = data["Date Time"].str.replace(" ","")
because the output shows blank characters. however, it did not help.
Output:
CodePudding user response:
Try to remove format=
to let the function determine the right format:
data = pd.DataFrame({'Date Time': ['1. Sep 2021']})
data['Date Time'] = pd.to_datetime(data["Date Time"])
print(data)
# Output:
Date Time
0 2021-09-01
Update:
I got error again: "Unknown string format: %s, timestt"
To debug, find rows where dates have not a right format:
data.loc[pd.to_datetime(data['Date Time'], errors='coerce').isna(), 'Date Time']