Pythonで文字列を日付型に変える方法(ついでにPandasの場合とも比較) 2023年2月22日 / 1 min read View more blogs with the tag python , View more blogs with the tag pandas Table of Contents #はじめに #方法 はじめに Pythonで文字列を日付型に変える方法です。ついでにPandasの場合とも比較しています。 方法 import datetime t = 'May 26, 2022't2 = datetime.datetime.strptime(t, '%b %d, %Y')t3 = datetime.date(t2.year, t2.month, t2.day)# Output -> 2022-05-26 # dfの場合import pandas as pdpd.to_datetime(df['date'], format='%b %d, %Y')# Output -> 2022-05-26