Skip to content

Instantly share code, notes, and snippets.

@datagy
Created September 22, 2022 22:59
Show Gist options
  • Select an option

  • Save datagy/b18ffd1c7431aa8c3541f008c0e19c2f to your computer and use it in GitHub Desktop.

Select an option

Save datagy/b18ffd1c7431aa8c3541f008c0e19c2f to your computer and use it in GitHub Desktop.
Reading columns as datetime
# Reading Multiple Columns As Date Time
import pandas as pd
df = pd.read_excel(
'Pandas_read_files_tips.xlsx',
parse_dates={'Date': ['Month', 'Day', 'Year']}
)
print(df)
# Returns:
# Date Name Amount
# 0 2023-01-01 Nik 168
# 1 2023-01-02 Jane 178
# 2 2023-01-03 Kate 143
# 3 2023-01-04 Evan 100
# 4 2023-01-05 Nik 156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment