I have a dataframe column1 dtype obj in format of: ==> this is one column of the dataframe
Col1
02.11.2017
11.11.2017
02.12.2017
25.12.2017
this colum i want to convert to dates column by adding a new column to the df: ==> this is the code to convert the dataframe col1 to a new df column NewDate that generate the error below
df['NewDate'] = pd.to_datetime(df['Col1'], format='%d.%m.%Y')
I want my results to be: ==> this is what i want my result to look like.
Col1 NewDate
02.11.2017 2017-11-02
11.11.2017 2017-11-11
02.12.2017 2017-12-02
25.12.2017 2017-12-25
But my ERROR is:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
But when i try this I still get the same error: ==> this is the code i tried because of the warning/error above but get the same warning/error doing so
df.loc[:, 'NewDate'] = pd.to_datetime(df['Col1'].values, format='%d.%m.%Y')
Can someone point me in the right direction? Any help is much appriciated! PS: Very new to python and pandas.
Thanks alot!