Pythonで文字列を日付型に変える方法(ついでにPandasの場合とも比較)2023/2/22 / 1 min readView more blogs with the tag python, View more blogs with the tag pandasTable 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