Pandas Datetime: Extract year, month, day, hour, minute ...
www.w3resource.com › python-exercises › pandasSep 15, 2020 · Pandas Datetime: Exercise-8 with Solution. Write a Pandas program to extract year, month, day, hour, minute, second and weekday from unidentified flying object (UFO) reporting date. Sample Solution : Python Code : import pandas as pd df = pd. read_csv (r'ufo.csv') df ['Date_time'] = df ['Date_time']. astype ('datetime64 [ns]') print("Original Dataframe:") print( df. head ()) print(" Year:") print( df.