'Turning date string into a inter

One column in my dataframe has dates in the following format: 9-Dec-21, e.g.

enter image description here

How can I convert the above date into this format? 20211209



Solution 1:[1]

Use pd.to_datetime:

df['new_column'] = pd.to_datetime(df['column']).dt.strftime('%Y%m%d')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1