Skip to content

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

The use cases for this are all along the lines of

dti1 = pd.date_range(..., freq=high)
dti2 = pd.date_range(..., freq=low)

ser1 = pd.Series(..., index=dti1)
ser2 = pd.Series(..., index=dti2)

_, ax = mpl.pyplot.subplots()

ser1.plot(ax=ax)
ser2.plot(ax=ax)

In this case, ser2 gets silently resampled (period-style, which is different from regular resample i think) so that the x-axis matches the plot for ser1. (I think. We don't have any comments/docstrings explaining "why" for any of the plotting code).

In these cases, "reindex yourself" is a totally valid workaround. Since this is a big use case for kludged state information, I'm hopeful it will move us in the direction of #54485 too.

data = data.tz_localize(None).to_period(freq=freq_str)
elif isinstance(data.index, ABCPeriodIndex):
data.index = data.index.asfreq(freq=freq_str, how="start")
# This will convert e.g. freq="60min" to freq="min", but will
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this bit is unrelated, can revert and do it in a separate branch

@mroeschke mroeschke added Visualization plotting Deprecate Functionality to remove in pandas labels Sep 24, 2025
Comment on lines +84 to +85
"will raise in a future version. Align series frequencies "
"before plotting instead.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could go as far to suggest f"Call series.resample('{freq}') ..."?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

But now im wondering how much this will even help in moving towards #54485. In order to check if we're in this situation we still need the state information attached somehow.

I know "nuke it from space" isn't a viable approach to the plotting code, but it is really really bad.


msg = "Plotting with mixed-frequency series is deprecated"
with tm.assert_produces_warning(Pandas4Warning, match=msg):
s.plot(secondary_y=True)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it isn't clear to me why the warning is emitted here since ax isn't passed. if that keyword isn't the relevant factor in deciding if the statefulness is needed, then #62442 may not achieve its goals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Deprecate Functionality to remove in pandas Visualization plotting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants