I want to replace dates as strings using format yyyy-mm-dd to yyyymmddhhmmss as follows:
current value: 2020-11-06
new value: 20201106000000
Input:
DATE
1 2020-11-06
2 2020-11-06
5 2015-09-28
6 2015-09-28
7 2015-09-28
I have the next piece of code taht works but throws a warning:
merge_filtered['DATE'] = merge_filtered['DATE'].str.replace('-', '')
merge_filtered['DATE'] = merge_filtered['DATE'] + '000000'
But I get the warnings at the output:
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
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
merge_filtered['DATE'] = merge_filtered['DATE'].str.replace('-', '')
SettingWithCopyWarning:
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
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
merge_filtered['DATE'] = merge_filtered['DATE'] + '000000'
DATE
1 20201106000000
2 20201106000000
5 20150928000000
6 20150928000000
7 20150928000000