-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
pandas.plotting.parallel_coordinates resets random seed! #17525
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
Comments
Checked it on another computer and it resets to the same random seed, yielding the same output from random.random() Here is the version info for that computer:
|
Thanks for the bug report. Looks like the issue is at pandas/pandas/plotting/_style.py Lines 113 to 120 in f11bbf2
Could you submit a fix @jasonzutty? |
I'll take a crack at it, just remove the seed? |
Maybe a numpy RandomContext, to get reproducible colors? I haven't looked closely. |
Just submitted a pull request with a fix using random.getstate and random.setstate. Here's some output showing that the behavior looks right: >>> # The random seed isn't reset by the function now:
>>> x = pandas.DataFrame(numpy.zeros((10,10)))
>>> pandas.plotting.parallel_coordinates(x,0)
<matplotlib.axes._subplots.AxesSubplot object at 0x7fc1408b7d68>
>>> random.random()
0.5274572977380592
>>> pandas.plotting.parallel_coordinates(x,0)
<matplotlib.axes._subplots.AxesSubplot object at 0x7fc1408b7d68>
>>> random.random()
0.23087467871474676
>>> # And the function still produces consistent colors:
>>> pandas.plotting._style._get_standard_colors(1, color_type='random')
[[0.8444218515250481, 0.7579544029403025, 0.420571580830845]]
>>> pandas.plotting._style._get_standard_colors(1, color_type='random')
[[0.8444218515250481, 0.7579544029403025, 0.420571580830845]] |
Code Sample, a copy-pastable example if possible
Problem description
A call to the pandas.plotting.parallel_coordinates method resets the random seed
Expected Output
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]INSTALLED VERSIONS
commit: None
python: 2.7.13.final.0
python-bits: 64
OS: Darwin
OS-release: 16.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None
pandas: 0.20.3
pytest: 3.2.1
pip: 9.0.1
setuptools: 36.2.7
Cython: 0.26
numpy: 1.13.1
scipy: 0.19.1
xarray: None
IPython: 5.3.0
sphinx: 1.6.3
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.2
openpyxl: None
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: 0.999999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: