Skip to content

Instantly share code, notes, and snippets.

@kperry2215
Last active July 4, 2019 22:38
Show Gist options
  • Save kperry2215/0c2a35795d4bbbd72ad24424a868e3cd to your computer and use it in GitHub Desktop.
Save kperry2215/0c2a35795d4bbbd72ad24424a868e3cd to your computer and use it in GitHub Desktop.
def get_max_initial_production(df, number_first_months, variable_column, date_column):
"""
This function allows you to look at the first X months of production, and selects
the highest production month as max initial production
Arguments:
df: Pandas dataframe.
number_first_months: float. Number of months from the point the well comes online
to compare to get the max initial production rate qi (this looks at multiple months
in case there is a production ramp-up)
variable_column: String. Column name for the column where we're attempting to get
the max volume from (can be either 'Gas' or 'Oil' in this script)
date_column: String. Column name for the date that the data was taken at
"""
#First, sort the data frame from earliest to most recent prod date
df=df.sort_values(by=date_column)
#Pull out the first x months of production, where number_first_months is x
df_beginning_production=df.head(number_first_months)
#Return the max value in the selected variable column from the newly created
#df_beginning_production df
return df_beginning_production[variable_column].max()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment