1mydateparser = lambda x: pd.datetime.strptime(x, "%Y %m %d %H:%M:%S")
2df = pd.read_csv("file.csv", sep='\t', names=['date_column', 'other_column'], parse_dates=['date_column'], date_parser=mydateparser)
3
1df['DataFrame Column'] = pd.to_datetime(df['DataFrame Column'], format=specify your format)
2
1import pandas as pd
2
3values = {'dates': ['02-Sep-2019','13-Sep-2019','21-Sep-2019'],
4 'status': ['Opened','Opened','Closed']
5 }
6
7df = pd.DataFrame(values, columns = ['dates','status'])
8
9df['dates'] = pd.to_datetime(df['dates'], format='%d-%b-%Y')
10
11print (df)
12print (df.dtypes)
13
1import pandas as pd
2
3values = {'dates': ['20190902093000','20190913093000','20190921200000'],
4 'status': ['Opened','Opened','Closed']
5 }
6
7df = pd.DataFrame(values, columns = ['dates','status'])
8
9df['dates'] = pd.to_datetime(df['dates'], format='%Y%m%d%H%M%S')
10
11print (df)
12print (df.dtypes)
13
1import pandas as pd
2
3values = {'dates': ['20190902','20190913','20190921'],
4 'status': ['Opened','Opened','Closed']
5 }
6
7df = pd.DataFrame(values, columns = ['dates','status'])
8
9df['dates'] = pd.to_datetime(df['dates'], format='%Y%m%d')
10
11print (df)
12print (df.dtypes)
13
1import pandas as pd
2
3values = {'dates': ['02092019','13092019','21092019'],
4 'status': ['Opened','Opened','Closed']
5 }
6
7df = pd.DataFrame(values, columns = ['dates','status'])
8
9df['dates'] = pd.to_datetime(df['dates'], format='%d%m%Y')
10
11print (df)
12print (df.dtypes)
13
1import pandas as pd
2
3values = {'dates': ['02Sep2019','13Sep2019','21Sep2019'],
4 'status': ['Opened','Opened','Closed']
5 }
6
7df = pd.DataFrame(values, columns = ['dates','status'])
8
9df['dates'] = pd.to_datetime(df['dates'], format='%d%b%Y')
10
11print (df)
12print (df.dtypes)
13