Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

converting string to datetime pandas

df['date_col'] = pd.to_datetime(df['date_col'], format='%Y-%m-%d %H:%M:%S')

%Y - Year as decimal number (2004)
%m - month as zero padded number (03)
%d - Day of the month (16)
%H - Hour in 24 hour format
%M - Minutes (16)
%S - Seconds (03)

For more formats visit - https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior

Add other characters to match the exact format of the date
as given in your dataset (':', '-' etc)
Comment

from string to time python dataframe

dfc['Time_of_Sail'] = pd.to_datetime(dfc['Time_of_Sail'],format= '%H:%M:%S' ).dt.time
Comment

pandas convert string to datetime

In [51]:
pd.to_datetime(df['I_DATE'])

Out[51]:
0   2012-03-28 14:15:00
1   2012-03-28 14:17:28
2   2012-03-28 14:50:50
Name: I_DATE, dtype: datetime64[ns]
Comment

PREVIOUS NEXT
Code Example
Python :: how to save a png seaborn pandas 
Python :: how to plot graph using csv file in python 
Python :: power set python 
Python :: install python glob module in windows 
Python :: install easygui 
Python :: HOw to use passlock password manager python 
Python :: python multiply list by scalar 
Python :: pascal triangle python 
Python :: pygame draw line 
Python :: month from datetime pandas 
Python :: load images pygame 
Python :: opencv draw two images side by side 
Python :: how to get frequency of each elements in a python list 
Python :: pygame change logo 
Python :: create new django app 
Python :: matoplotlib set white background 
Python :: how to get latitude and longitude from address in python 
Python :: tkinter how to disable window resizing 
Python :: generate python date list 
Python :: python print file 
Python :: python install required packages 
Python :: python how to access clipboard 
Python :: python selenium move cursor to element 
Python :: python count the frequency of words in a list 
Python :: how to apply labelencoder on multiple columns at once 
Python :: pip install torch error 
Python :: name unnamed column pandas 
Python :: pandas add character to string 
Python :: pandas plot xlabel 
Python :: pip version 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =