-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Milestone
Description
Not sure if this is a bug, but it was surprising.
import pandas as pd
import numpy as np
In [24]: s = pd.Series(np.random.randn(10))
In [25]: norm = colors.Normalize(s.min() + .2, s.max() - .2)
In [26]: s
Out[26]:
0 -0.767090
1 -0.236357
2 0.031890
3 1.339422
4 0.994139
5 -1.481244
6 -0.253904
7 -0.032531
8 0.777265
9 -0.315098
dtype: float64
# normalize numpy array, doesn't modify
In [27]: norm(s.values)
Out[27]:
masked_array(data = [ 0.21240206 0.43165251 0.54246791 1.08262188 0.93998197 -0.08262188
0.42440363 0.51585521 0.85038937 0.39912391],
mask = False,
fill_value = 1e+20)
In [28]: s
Out[28]:
0 -0.767090
1 -0.236357
2 0.031890
3 1.339422
4 0.994139
5 -1.481244
6 -0.253904
7 -0.032531
8 0.777265
9 -0.315098
dtype: float64
In [29]: norm(s) # normalize series...
Out[29]:
masked_array(data = [ 0.21240206 0.43165251 0.54246791 1.08262188 0.93998197 -0.08262188
0.42440363 0.51585521 0.85038937 0.39912391],
mask = False,
fill_value = 1e+20)
In [30]: s # does modify.
Out[30]:
0 0.212402
1 0.431653
2 0.542468
3 1.082622
4 0.939982
5 -0.082622
6 0.424404
7 0.515855
8 0.850389
9 0.399124
dtype: float64
In [43]: matplotlib.__version__
Out[43]: '1.5.0'Strangely, if s in a integer series (s = pd.Series(range(10))), it will not be modified. FWIW, a list of floats aren't modified either.
Reactions are currently unavailable