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

Breaking change multiplication bool and int #22047

Closed
Tux1 opened this issue Jul 25, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@Tux1
Copy link
Contributor

commented Jul 25, 2018

Code Sample, a copy-pastable example if possible

import pandas as pd
a = pd.DataFrame([[False, True], [False, False]])
print(a.dtypes)
b = a * 1
print(b.dtypes)

Problem description

With 0.20.3, I get b as DataFrame int32.
With 0.23.3, I get b as DataFrame object.

Expected Output

With 0.20.3

a.dtypes =
0 bool
1 bool
dtype: object

b.dtypes =
0 int32
1 int32
dtype: object

With 0.23.3

a.dtypes =
0 bool
1 bool
dtype: object

b.dtypes =
0 object
1 object
dtype: object

Versions

pandas 0.20.3 vs pandas 0.23.3

@jbrockmendel

This comment has been minimized.

Copy link
Member

commented Jul 25, 2018

What do you get if you multiply a series instead of a dataframe?

@Tux1

This comment has been minimized.

Copy link
Contributor Author

commented Jul 25, 2018

Don't understand your question
EDIT: I amended my example adding .dtypes. maybe it is clearer for you now

@jorisvandenbossche

This comment has been minimized.

Copy link
Member

commented Jul 25, 2018

A Series works infers the dtype correctly:

In [71]: a[0]
Out[71]: 
0    False
1    False
Name: 0, dtype: bool

In [72]: a[0] * 1
Out[72]: 
0    0
1    0
Name: 0, dtype: int64

@Tux1

This comment has been minimized.

Copy link
Contributor Author

commented Jul 28, 2018

Any idea about the root cause ? If you give me some tips, I can have a look

@jbrockmendel

This comment has been minimized.

Copy link
Member

commented Jul 28, 2018

No idea what changed it, but it'll be fixed by the follow-up after #22074.

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.