set a column to pandas datetime with strf formatiing in python
You can set a column to Pandas datetime with strftime formatting using the pd.to_datetime() method and passing the format parameter with your desired strftime format.
main.py
Example:
```python
import pandas as pd
# sample data data = {'date':['20211231', '20220101', '20220102'],
'value':[1, 2, 3]}
# create dataframe df = pd.DataFrame(data)
# convert string to datetime with strftime formatting df['date'] = pd.to_datetime(df['date'], format='%Y%m%d')
print(df)
```
Output:
```
date value
02021-12-31112022-01-01 222022-01-02 3 ```