So this is what I have for the current month - February 2025 - which works as a graph.
I have highlighted in bold the key bits.
Essentially string_date = Feb 25 in this example as its finding the current month and year from today's date.
I need to be able to find the next month, i.e. Mar 25.
long_string_date is just the title of the graph, e.g. February 2025.
I Wonder if I can just adapt this code?
import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime
import datetime
import matplotlib.dates as mdates
import numpy as np
import matplotlib.ticker as plticker
from dateutil.relativedelta import relativedelta
import calendar
today = datetime.datetime.today().date()
string_date = today.strftime("%b %y")
long_string_date = today.strftime("%B %Y")
df["Date Captured"] = pd.to_datetime(df["Date Captured"])
df["Check-In"] = pd.to_datetime(df["Check-In"])
df_filtered = df[(df["Date Captured"].dt.date == today) & (df["Mon Year"] == string_date)]
grouped = df_filtered.groupby("Check-In")["Current price"].min().reset_index()
fig, ax = plt.subplots()
p1 = ax.bar(grouped["Check-In"], grouped["Current price"], color='g')
ax.bar_label(p1, label_type="edge")
ax.bar_label(p1)
# Formatting the x-axis
ax.xaxis.set_major_formatter(mdates.DateFormatter("%a %d")) # Format as "Jan 2025"
loc = plticker.MultipleLocator(base=1.0) # this locator puts ticks at regular intervals
ax.xaxis.set_major_locator(loc)
plt.xlabel("Check-In Date")
plt.ylabel("Price (£)")
plt.title(long_string_date)
plt.xticks(rotation=90) # Rotate labels
plt.ylim(50, 200)
plt.show()