Skip to content

Instantly share code, notes, and snippets.

@Eligijus112
Created February 11, 2020 05:45
Show Gist options
  • Save Eligijus112/e31064a5c03c9c4d92ab133b47068577 to your computer and use it in GitHub Desktop.
Save Eligijus112/e31064a5c03c9c4d92ab133b47068577 to your computer and use it in GitHub Desktop.
Reading and formating hourly time series
# 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