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

DataFrame.clip() bug when bound a frame when columns not sorted #20911

Closed
amanhanda opened this issue May 1, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@amanhanda
Copy link

commented May 1, 2018

Code Sample, a copy-pastable example if possible

In [14]: import pandas as pd

In [15]: df1 = pd.DataFrame([[1., 0.], [3., 0.]], columns=['A', 'B'])

In [16]: df2 = pd.DataFrame([[100., 1.], [100., 2.]], columns=['B', 'A'])

In [17]: df1.clip(lower=0, upper=df2)
Out[17]:
       A    B
0    1.0  0.0
1  100.0  0.0
In [18]: df1
Out[18]:
     A    B
0  1.0  0.0
1  3.0  0.0

# selecting columns in order produces the correct results
In [20]: df1.clip(lower=0, upper=df2[df1.columns])
Out[20]:
     A    B
0  1.0  0.0
1  2.0  0.0

Problem description

The behavior was correct in 0.18.1. df1.A = 3.0 is being clipped to 100.0. This not expected.

Expected Output

In [39]: df1.clip(lower=0, upper=df2)
Out[39]:
     A    B
0  1.0  0.0
1  2.0  0.0

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.14.final.0
python-bits: 64
OS: Linux
OS-release: 3.10.0-327.36.3.el7.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: C
LANG: en_US.UTF-8
LOCALE: None.None

pandas: 0.22.0
pytest: 3.5.0
pip: 9.0.3
setuptools: 39.0.1
Cython: 0.28.2
numpy: 1.14.2
scipy: 1.0.1
pyarrow: 0.9.0
xarray: 0.10.2
IPython: 5.6.0
sphinx: 1.7.2
patsy: 0.5.0
dateutil: 2.7.2
pytz: 2018.4
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.2.2
openpyxl: 2.5.2
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.2
lxml: 4.2.1
bs4: 4.3.2
html5lib: 0.999
sqlalchemy: 1.2.6
pymysql: None
psycopg2: 2.7.4 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@jreback jreback referenced this issue Dec 28, 2018

Merged

BUG: clip doesn't preserve dtype by column #24458

4 of 4 tasks complete

@cgangwar11 cgangwar11 referenced this issue Dec 28, 2018

Merged

Bug : Fixes #20911 #24467

4 of 4 tasks complete

@jreback jreback added the Bug label Dec 28, 2018

@jreback jreback added this to the 0.24.0 milestone Dec 28, 2018

jreback added a commit that referenced this issue Dec 28, 2018

Pingviinituutti added a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019

Pingviinituutti added a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.