Skip to content

Commit

Permalink
allowing datetime to be passed
Browse files Browse the repository at this point in the history
  • Loading branch information
Karen McKinnon committed Aug 19, 2020
1 parent afbbaa6 commit 13fd5fc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion humidity_variability/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def add_date_columns(df):
"""

# Create datetime column
df['dt'] = [datetime.strptime(d, '%Y-%m-%d') for d in df['date']]
if isinstance(df.loc[0, 'date'], str):
df['dt'] = [datetime.strptime(d, '%Y-%m-%d') for d in df['date']]
else:
df = df.rename(columns={'date': 'dt'})

# Create month, year, season, and day of year columns
df['month'] = [d.month for d in df['dt']]
Expand Down

0 comments on commit 13fd5fc

Please sign in to comment.