Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [X] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

price = [np.NaN, 10, 13, np.NaN, np.NaN, 9]
df = pd. DataFrame(price, columns = ['price'])
period = 1
pct = df.price.pct_change(periods=period, fill_method=None)
print(pct)

# https://stackoverflow.com/questions/75395345/how-to-avoid-bfill-or-ffill-when-calculating-pct-change-with-nans

Issue Description

There's a code path specifically for fill_method=None:

https://github.com/pandas-dev/pandas/blob/13db83ad3f1245107151e6a626537a8ea7f72df1/pandas/core/generic.py#L10904-L10905

But no test hits it (check pandas-coverage.herokuapp.com/), and the type hints don't allow None

Expected Behavior

This was recently added to the docs https://github.com/pandas-dev/pandas/pull/51262 - seeing as it does work, it should probably be tested, type hints updated, and documented?

Installed Versions

Replace this line with the output of pd.show_versions()

Comment From: phofl

yep makes sense

Comment From: FlynnOwen

Can I pick this up?

Comment From: MarcoGorelli

sure

Comment From: FlynnOwen

Thanks @MarcoGorelli, could I be set as the 'assignee'?

Comment From: FlynnOwen

take