I'm using a pandas data frame to compare some weather data and some pollution levels.
I need a hand because I'm plotting some data, but one of my data points is out of range and messing with my plot.
I am using a bar plot, and I would just set the y limits of the plot, however the bar for this data point still shows up and just goes out of range.
What to do to get rid of this single value? I have tried setting it to 0 but it comes up with a warning about A value is trying to be set on a copy of a slice from a DataFrame.
here is what the plot looks like, and here is some of the code that goes with it:
fig, ax = plt.subplots()
#defining the plot type and the data to be plotted.
ax.bar(df1["Pressure (hPa)"].loc["2019"],
df2["PM10 particulate matter (Hourly measured)"].loc["2019"],
alpha=0.2,
)
ax.bar(df1["Pressure (hPa)"].loc["2019"],
df2["PM2.5 particulate matter (Hourly measured)"].loc["2019"],
alpha=0.2,
color="Green")
#setting the limits of the x axis to make the graph more readable.
ax.set_xlim(970,1045)
The out of range value is in the df2. I'm just not sure how to remove it. I have tried doing
df2[df2["PM2.5 particulate matter (Hourly measured)"]>150] = 0
but that comes up with the warning message.
I have tried using < operators too directly on the data frame, but it just gives me boolean values which I can't plot :(