Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start year flexibility #167

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions scripts/dataframe_analysis.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import numpy as np


def add_year(df):
def add_year(df, s_y=1965):
nsryan2 marked this conversation as resolved.
Show resolved Hide resolved
'''
Adds column of Year, based on the Time column

Parameters
----------
df: DataFrame
DataFrame of data to add column for the year to
s_y: Start year
nsryan2 marked this conversation as resolved.
Show resolved Hide resolved
First year in the column of Year

Returns
-------
df: DataFrame
DataFrame with the added column
'''
df['Year'] = np.round(df['Time'] / 12 + 1965, 2)
df['Year'] = np.round(df['Time'] / 12 + s_y, 2)
nsryan2 marked this conversation as resolved.
Show resolved Hide resolved
df['Year'] = df['Year'].ffill()
return df

Expand Down