Guest User

Untitled

a guest
Jan 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. x = np.array([1,2,3])
  2. y = np.array([4,5,6])
  3. df = pd.DataFrame({"numpy": [x,y]})
  4.  
  5. df["numpy"].mean() #works as expected
  6. Out[231]: array([ 2.5, 3.5, 4.5])
  7.  
  8. df["numpy"].std() #does not work as expected
  9. Out[231]: TypeError: setting an array element with a sequence.
  10.  
  11. df["numpy"].values.mean() #works as expected
  12. Out[231]: array([ 2.5, 3.5, 4.5])
  13.  
  14. df["numpy"].values.std() #works as expected
  15. Out[233]: array([ 1.5, 1.5, 1.5])
  16.  
  17. df["numpy"].dtype
  18. Out[235]: dtype('O')
  19.  
  20. df["numpy"][0].dtype
  21. Out[236]: dtype('int32')
  22.  
  23. df["numpy"].describe()
  24. Out[237]:
  25. count 2
  26. unique 2
  27. top [1, 2, 3]
  28. freq 1
  29. Name: numpy, dtype: object
  30.  
  31. df["numpy"]
  32. Out[238]:
  33. 0 [1, 2, 3]
  34. 1 [4, 5, 6]
  35. Name: numpy, dtype: object
Add Comment
Please, Sign In to add comment