wesm/pandas — Issue #314: Series.apply() does not always return a Series
Author: creeson
Created: 2011-11-01 18:56:52+00:00
State: open

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. ]