Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = np.array([1,2,3])
- y = np.array([4,5,6])
- df = pd.DataFrame({"numpy": [x,y]})
- df["numpy"].mean() #works as expected
- Out[231]: array([ 2.5, 3.5, 4.5])
- df["numpy"].std() #does not work as expected
- Out[231]: TypeError: setting an array element with a sequence.
- df["numpy"].values.mean() #works as expected
- Out[231]: array([ 2.5, 3.5, 4.5])
- df["numpy"].values.std() #works as expected
- Out[233]: array([ 1.5, 1.5, 1.5])
- df["numpy"].dtype
- Out[235]: dtype('O')
- df["numpy"][0].dtype
- Out[236]: dtype('int32')
- df["numpy"].describe()
- Out[237]:
- count 2
- unique 2
- top [1, 2, 3]
- freq 1
- Name: numpy, dtype: object
- df["numpy"]
- Out[238]:
- 0 [1, 2, 3]
- 1 [4, 5, 6]
- Name: numpy, dtype: object
Add Comment
Please, Sign In to add comment