I'm having trouble extracting the year from the date column of this particular dataset
Alright, it seems that
TSLA['date'] = pd.to_datetime(TSLA['date'],utc = True)
followed by:
TSLA['date'] = TSLA['date'].dt.date
got me the values i wanted i.e. YYYY-MM-DD.
#Adjust Date Info
TSLA['date'] = TSLA['date'].astype(str)
TSLA['date'] = pd.to_datetime(TSLA['date'])
The datatype of both columns is object.
Ive tried using .astype(str) on the date column thenn using a lambda function to extract the YYYY-MM-DD but the datatype doesn't change. It doesn't throw up an error either when applying the .astype(str)
.to_datetime doesn't work either.
There are no missing values in either column. I'd appreciate any opinions as to what i'm doing incorrectly?
Since i am unable to add images for now, the date column has the following values: YYYY-MM-DD HH-MM-SS-HH-MM-SS