To obtain the date from the maximum rolling value, follow these steps:
For example, let's say you have daily sales data and you want to find the date with the highest rolling 7-day sales total. You would:
Assuming your sales data is in a Pandas DataFrame called df
, your code might look something like this:
# Calculate rolling 7-day sum
df['rolling_7day_sales'] = df['sales'].rolling(window=7).sum()
# Find date with highest rolling 7-day sum
max_rolling_sum = df['rolling_7day_sales'].max()
max_rolling_date = df.loc[df['rolling_7day_sales'] == max_rolling_sum, 'date'].iloc[0]
# Output date with highest rolling 7-day sum
print(f"The date with the highest rolling 7-day sales total is {max_rolling_date}.")
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-30 15:42:08 +0000
Seen: 13 times
Last updated: Jun 30 '23
How can I add up the value of a different layer's field when it intersects with a polygon in QGIS?
What is the method for de-linearizing the value of the depth buffer?
What is the expected outcome of the math.floor function in terms of the return value?
What is the method to retrieve the value of a checkbox using react-hook-form?
What is the method for obtaining the value of a attribute using Xpath?
How can an array object be set in React using JSON if there is no pre-existing value?