Created
September 22, 2022 22:59
-
-
Save datagy/b18ffd1c7431aa8c3541f008c0e19c2f to your computer and use it in GitHub Desktop.
Reading columns as datetime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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