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

Series.apply() does not always return a Series #314

Closed
creeson opened this issue Nov 1, 2011 · 1 comment
Closed

Series.apply() does not always return a Series #314

creeson opened this issue Nov 1, 2011 · 1 comment
Labels
Milestone

Comments

@creeson
Copy link

creeson commented Nov 1, 2011

Example below of it returning a NumPy array. This seems unexpected, given the documentation in the function.

Thanks!

Example:
Code:
import pandas as ps
import numpy as np

test = ps.Series(np.linspace(start=0, stop=1, num=20))
print test
print test.apply(lambda x: np.round(x, 1))

Note : this is equivalent to np.round(test, 1)

Output:

0 0.0
1 0.0526315789474
2 0.105263157895
3 0.157894736842
4 0.210526315789
5 0.263157894737
6 0.315789473684
7 0.368421052632
8 0.421052631579
9 0.473684210526
10 0.526315789474
11 0.578947368421
12 0.631578947368
13 0.684210526316
14 0.736842105263
15 0.789473684211
16 0.842105263158
17 0.894736842105
18 0.947368421053
19 1.0
Name: None, Length: 20
[ 0. 0.1 0.1 0.2 0.2 0.3 0.3 0.4 0.4 0.5 0.5 0.6 0.6 0.7 0.7
0.8 0.8 0.9 0.9 1. ]

@wesm
Copy link
Member

wesm commented Nov 3, 2011

Took care of 2 things here-- you're right Series.apply should always return a Series, and also need to override ndarray.round (though not immediately clear why), the root cause of this particular issue

@wesm wesm closed this as completed Nov 3, 2011
dan-nadler pushed a commit to dan-nadler/pandas that referenced this issue Sep 23, 2019
Set and read user defined metadata. This metadata is per symbol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants