Here my problem (assume that I already imported Pandas as pd and so on...):
I have a data frame called "x" It contains several columns, one of them called "Time" Time has dates in the format: Tue, 01 Jan 2019 18:09:17 GMT I want to transform those dates into the format: '%a, %d %b %Y %H:%M:%S %Z'
Here is where the problem starts
First
I tried:
x['connectionTime'] = pd.to_datetime(x['connectionTime'], format='%a, %d %b %Y %H:%M:%S %Z')
I got the error
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
then I tried:
x.loc[:, 'connectionTime'] = pd.to_datetime(x_before.loc[:, 'connectionTime'] , format='%a, %d %b %Y %H:%M:%S %Z')
and I got the error:
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
finally if I do:
x_t = pd.to_datetime(x['connectionTime'], format='%a, %d %b %Y %H:%M:%S %Z')
THIS WORKS!!!
BUT
x_before.loc[:, 'connectionTime'] = x_t
gives the error:
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
I really do not know what else I should try.
THANKS!!!!