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

FutureWarning: from base.py : _empty_series = pd.Series() #1836

Closed
gene-git opened this issue Jan 22, 2024 · 11 comments
Closed

FutureWarning: from base.py : _empty_series = pd.Series() #1836

gene-git opened this issue Jan 22, 2024 · 11 comments

Comments

@gene-git
Copy link

FYI - today I started getting this warning from latest git ::

.../yfinance/base.py:48: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
  _empty_series = pd.Series()
@ValueRaider
Copy link
Collaborator

@mreiche #1724

@gene-git
Copy link
Author

Yeh thank you @mreiche - Arch is very out of date for some reason - 1.5.3

@gene-git
Copy link
Author

here are lots of version restrictions on building pandas (2.2.0 or git head) so be bit of a pain for me to do - think I'll wait for arch to update.

So, should we close this ?

@mreiche
Copy link
Contributor

mreiche commented Jan 23, 2024

You could try something like suppressing FutureWarnings: https://stackoverflow.com/questions/15777951/how-to-suppress-pandas-future-warning, get back with our solution and then close :)

@gene-git
Copy link
Author

I put this in my application - added these lines (import warnings and import pandas ::

import warnings
import pandas
import yfinance as yf

and then at the top of main I put:

warnings.simplefilter(action='ignore', category=FutureWarning)
_unused_dummy = pd.Series()

then run my program - still emits same warning in yf but not from my dummy

/usr/lib/python3.11/site-packages/yfinance/base.py:48: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
  _empty_series = pd.Series()

@gene-git
Copy link
Author

Is there a reason not to follow the suggestion and simply add dtype to the pd.Series() line?

@mreiche
Copy link
Contributor

mreiche commented Jan 23, 2024

then run my program - still emits same warning in yf but not from my dummy

/usr/lib/python3.11/site-packages/yfinance/base.py:48: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
  _empty_series = pd.Series()

The reason here is, that _empty_series gets instanced at the very beginning of the whole yfinance module, before you disabled warnings.

Try

import warnings

warnings.simplefilter(action='ignore', category=FutureWarning)

import yfinance as yf

Unfortunately, _empty_series still exists due merge conflicts beforehand. This can easily be fixed with another PR. Let me get back here soon.

@mreiche
Copy link
Contributor

mreiche commented Jan 23, 2024

Is there a reason not to follow the suggestion and simply add dtype to the pd.Series() line?

IMHO, it's outdated and fixed in current versions. Why beeing upwards-compatible for these edge cases? It's not my decision to support pandas<2 and not beeing fully compatible. Nobody else complaint about this, so I guess it's not a popular thing.

@gene-git
Copy link
Author

Okidok - moving the warning above import as you suggest works fine too.

thanks

Yeh I am fine with ignoring outdated stuff too. It's rare for arch to be this far behind on package.

@mreiche
Copy link
Contributor

mreiche commented Jan 23, 2024

@gene-git FYI, I'm using Alpine in my experimental branch and I was able to install newer versions of pandas using the python:3.11-alpine base image:

# cat /etc/alpine-release 
3.19.0
# pip list | grep pandas
pandas          2.1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants