We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In [91]: from pandas import DataFrame
In [92]: a = DataFrame([1,2, None, 3, 4])
In [93]: a Out[93]: 0 0 1 1 2 2 None 3 3 4 4
In [94]: a.apply(lambda x: str(x[0]), axis=1) Out[94]: 0 1 1 2 2 None 3 3 4 4
In [95]: a.apply(lambda x: int(x[0]), axis=1) Out[95]: 0 1 1 2 2 NaN 3 NaN 4 NaN
I was expecting elements 3 and 4 to still evaluate properly in this case to something like this:
0 1 1 2 2 NaN 3 3 4 4
i am using windows xp 32 bit with pandas 0.7.1 on python 2.7.2
The text was updated successfully, but these errors were encountered:
You spotted a bug that I fixed earlier today. This should have raised an exception:
In [4]: a.apply(lambda x: int(x[0]), axis=1) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/wesm/code/pandas/<ipython-input-4-77655858a2f4> in <module>() ----> 1 a.apply(lambda x: int(x[0]), axis=1) /home/wesm/code/pandas/pandas/core/frame.pyc in apply(self, func, axis, broadcast, raw, args, **kwds) 3346 return self._apply_raw(f, axis) 3347 else: -> 3348 return self._apply_standard(f, axis) 3349 else: 3350 return self._apply_broadcast(f, axis) /home/wesm/code/pandas/pandas/core/frame.pyc in _apply_standard(self, func, axis, ignore_failures) 3401 try: 3402 for k, v in series_gen: -> 3403 results[k] = func(v) 3404 except Exception, e: 3405 try: /home/wesm/code/pandas/<ipython-input-4-77655858a2f4> in <lambda>(x) ----> 1 a.apply(lambda x: int(x[0]), axis=1) TypeError: ("int() argument must be a string or a number, not 'NoneType'", 'occurred at index 2')
I'm unsure about propagating NAs silently. Going to table it for future work
Sorry, something went wrong.
RLS: release note for #1243
ae3a966
No branches or pull requests
In [91]: from pandas import DataFrame
In [92]: a = DataFrame([1,2, None, 3, 4])
In [93]: a
Out[93]:
0
0 1
1 2
2 None
3 3
4 4
In [94]: a.apply(lambda x: str(x[0]), axis=1)
Out[94]:
0 1
1 2
2 None
3 3
4 4
In [95]: a.apply(lambda x: int(x[0]), axis=1)
Out[95]:
0 1
1 2
2 NaN
3 NaN
4 NaN
I was expecting elements 3 and 4 to still evaluate properly in this case to something like this:
0 1
1 2
2 NaN
3 3
4 4
i am using windows xp 32 bit with pandas 0.7.1 on python 2.7.2
The text was updated successfully, but these errors were encountered: