Created
February 11, 2020 05:45
-
-
Save Eligijus112/e31064a5c03c9c4d92ab133b47068577 to your computer and use it in GitHub Desktop.
Reading and formating hourly time series
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
| # Loading pandas | |
| import pandas as pd | |
| # Loading date wrangling package | |
| from datetime import datetime | |
| # Reading the input data | |
| d = pd.read_csv('input/DAYTON_hourly.csv') | |
| # Formating to datetime | |
| d['Datetime'] = [datetime.strptime(x, '%Y-%m-%d %H:%M:%S') for x in d['Datetime']] | |
| # Making sure there are no duplicated data | |
| # If there are some duplicates we average the data during those duplicated days | |
| d = d.groupby('Datetime', as_index=False)['DAYTON_MW'].mean() | |
| # Sorting the values | |
| d.sort_values('Datetime', inplace=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment