Skip to content

Pandas broadcast with numpy scalars #8116

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

Closed
tritemio opened this issue Aug 26, 2014 · 0 comments · Fixed by #8119
Closed

Pandas broadcast with numpy scalars #8116

tritemio opened this issue Aug 26, 2014 · 0 comments · Fixed by #8119
Labels
Compat pandas objects compatability with Numpy or Python functions Dtype Conversions Unexpected or buggy dtype conversions Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@tritemio
Copy link

Pandas objects (Series, DataFrame, etc...) can broadcast operations with python scalars. For example:

import pandas as pd
pd.DataFrame([1,2,3])*2

But when performing the same operation with a numpy scalar array:

import pandas as pd
import numpy as np
pd.DataFrame([1,2,3])*np.array(2)

pandas returns an error:

ValueError: Incompatible argument shape: ()

I can't find an explicit mention of scalar broadcasting in Pandas docs but this seems a natural case to be supported.

See also the original SO question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Dtype Conversions Unexpected or buggy dtype conversions Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants