You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect that my arguments passed to .pivot remain unchanged. I understand that lists, being mutable, can be modified by a function when they are used as arguments. I also understand that I can pass a set here instead of a list to keep it from being modified. However, I think it's reasonable to expect functions to be side-effect free in this case, especially when the documentation asks for a list and does not mention side effects. (FWIW, this behavior does not occur if I set the values= parameter).
The issue cropped up when I wanted to .pivot multiple DataFrames using the same index. To do so, I created a partial function of .pivot with an anonymous list as the index= paramter. Here's an MWE using the dataframe from above:
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Minimal Working Example
One of the documentation examples, slightly modified:
Displays:
Problem description
I would expect that my arguments passed to
.pivot
remain unchanged. I understand that lists, being mutable, can be modified by a function when they are used as arguments. I also understand that I can pass a set here instead of a list to keep it from being modified. However, I think it's reasonable to expect functions to be side-effect free in this case, especially when the documentation asks for a list and does not mention side effects. (FWIW, this behavior does not occur if I set thevalues=
parameter).The issue cropped up when I wanted to
.pivot
multiple DataFrames using the same index. To do so, I created a partial function of.pivot
with an anonymous list as theindex=
paramter. Here's an MWE using the dataframe from above:produces the output:
Expected Output
In the MWE above,
produces
Output of
pd.show_versions()
(Version in my project. Confirmed same behavior in
pandas==1.1.4
andmaster
branch.)pandas : 1.1.0
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.2
setuptools : 41.2.0
Cython : None
pytest : None
hypothesis : None
sphinx : 3.2.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.17.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.2
sqlalchemy : 1.3.19
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: