Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QST: I receive a message from pandas which is "FutureWarning: PeriodDtype[B] is deprecated and will be removed in a future version. Use a DatetimeIndex with freq='B' instead" #55316

Closed
2 tasks done
Jacques2101 opened this issue Sep 28, 2023 · 6 comments
Labels
Needs Info Clarification about behavior needed to assess issue Usage Question

Comments

@Jacques2101
Copy link

Jacques2101 commented Sep 28, 2023

Research

  • I have searched the [pandas] tag on StackOverflow for similar questions.

  • I have asked my usage related question on StackOverflow.

Link to question on StackOverflow

no question like mine

Question about pandas

I receive a message from pandas 2.1.1 for which I don't know how to react. it is "FutureWarning: PeriodDtype[B] is deprecated and will be removed in a future version. Use a DatetimeIndex with freq='B' instead"
What should I do ?

@Jacques2101 Jacques2101 added Needs Triage Issue that has not been reviewed by a pandas team member Usage Question labels Sep 28, 2023
@lithomas1
Copy link
Member

Can you post a minimum reproducible example with code?

@lithomas1 lithomas1 added Needs Info Clarification about behavior needed to assess issue and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 28, 2023
@Jacques2101
Copy link
Author

Jacques2101 commented Sep 28, 2023

i have data that are like this:

Amundi energies Vertes SAS | Amundi Euroland Eq Dyn MultiFact A EUR C | Amundi Bavarian Equity Fund I-C/D
-- | -- | --

99.79 | 123.03 | 139.03
99.79 | 122.72 | 138.20
99.79 | 122.44 | 138.21
99.79 | 122.16 | 137.75
99.79 | 121.50 | 137.43
99.79 | 121.15 | 136.23
99.79 | 121.57 | 136.30
99.79 | 122.10 | 136.79
99.79 | 121.75 | 136.20
99.79 | 121.38 | 135.61
99.79 | 122.74 | 136.97
99.99 | 123.17 | 137.85
NaN | 121.95 | 136.03
NaN | 122.10 | 135.25
NaN | 123.13 | 136.53
NaN | 121.60 | 134.72
NaN | 121.24 | 134.97
NaN | 120.24 | 133.52
NaN | 119.33 | 132.45

I must add that my data is generated by a function:

def data(...):
   # Data generates from other dataframe
   df['date'] = pd.to_datetime(df['date'])
   return df.set_index('date').asfreq('b')

and i do:
df.plot();

and then I get message (but the graph also!)

/Users/jacques/opt/anaconda3/envs/data/lib/python3.10/site-packages/matplotlib/axis.py:1732: FutureWarning: Period with BDay freq is deprecated and will be removed in a future version. Use a DatetimeIndex with BDay freq instead.
  ret = self.converter.convert(x, self.units, self)
/Users/jacques/opt/anaconda3/envs/data/lib/python3.10/site-packages/matplotlib/axis.py:1732: FutureWarning: PeriodDtype[B] is deprecated and will be removed in a future version. Use a DatetimeIndex with freq='B' instead
  ret = self.converter.convert(x, self.units, self)
/Users/jacques/opt/anaconda3/envs/data/lib/python3.10/site-packages/matplotlib/axis.py:1732: FutureWarning: PeriodDtype[B] is deprecated and will be removed in a future version. Use a DatetimeIndex with freq='B' instead
  ret = self.converter.convert(x, self.units, self)
/Users/jacques/opt/anaconda3/envs/data/lib/python3.10/site-packages/matplotlib/axis.py:1732: FutureWarning: PeriodDtype[B] is deprecated and will be removed in a future version. Use a DatetimeIndex with freq='B' instead
  ret = self.converter.convert(x, self.units, self)
/Users/jacques/opt/anaconda3/envs/data/lib/python3.10/site-packages/matplotlib/axis.py:1484: FutureWarning: Period with BDay freq is deprecated and will be removed in a future version. Use a DatetimeIndex with BDay freq instead.
  return self.major.locator()
/Users/jacques/opt/anaconda3/envs/data/lib/python3.10/site-packages/matplotlib/axis.py:1484: FutureWarning: PeriodDtype[B] is deprecated and will be removed in a future version. Use a DatetimeIndex with freq='B' instead
  return self.major.locator()
/Users/jacques/opt/anaconda3/envs/data/lib/python3.10/site-packages/matplotlib/ticker.py:218: FutureWarning: Period with BDay freq is deprecated and will be removed in a future version. Use a DatetimeIndex with BDay freq instead.
  return [self(value, i) for i, value in enumerate(values)]

@mroeschke
Copy link
Member

Thanks for the report. This is being addressed in #55138 so closing

@Jacques2101
Copy link
Author

Jacques2101 commented Sep 29, 2023 via email

@mroeschke
Copy link
Member

You can filter warnings for now while this is being fixed

@amanlai
Copy link
Contributor

amanlai commented Dec 14, 2023

@Jacques2101 Period with freq='B' is being deprecated; that's why removing asfreq('b') "solves" the issue; although when you do that, the plot will look different.

You can filter this specific warning by running: warnings.filterwarnings(action='ignore', category=FutureWarning, message=r".*Use a DatetimeIndex.*"). See this post for a working example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Info Clarification about behavior needed to assess issue Usage Question
Projects
None yet
Development

No branches or pull requests

4 participants