User Tools

Site Tools


convert_string_to_date

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
convert_string_to_date [2022/11/28 04:49] rajuconvert_string_to_date [2022/11/28 05:00] (current) raju
Line 1: Line 1:
 +===== Convert string to date =====
 ==== single date string; without pandas; to datetime.date ==== ==== single date string; without pandas; to datetime.date ====
 Use <code> Use <code>
Line 26: Line 27:
 </code> </code>
  
-==== multiple dates in a series; using pandas ====+Ref:- 
 +  * https://stackoverflow.com/questions/9504356/convert-string-into-date-type-on-python - where I found the answer 
 +  * https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes - shows the list of all the format codes such as %B, %Y. 
 + 
 +==== series of date strings; using pandas ====
 use <code> use <code>
 df[col_name] = pd.to_datetime(df[col_name], format_str) df[col_name] = pd.to_datetime(df[col_name], format_str)
Line 75: Line 80:
 dtype: object dtype: object
 </code> </code>
 +
 +See also: https://pandas.pydata.org/docs/reference/api/pandas.to_datetime.html
 +
convert_string_to_date.1669610954.txt.gz · Last modified: 2022/11/28 04:49 by raju