Guest User

Untitled

a guest
Jun 14th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. import pandas as pd
  2. a = [['a', [11,22]],['b',[33,44]]]
  3. df = pd.DataFrame(a)
  4. df = df.transpose()
  5. print(df)
  6. print(df[1][1])
  7. print(type(df[1][1]))
  8. b = df[1][1]
  9. print(b[1])
  10. print(type(b[1]))
  11. df.to_csv('i.csv', sep = ',', header = None, encoding='1251', index = False)
  12. dff = pd.read_csv('ii.csv',sep = ',', header = None, encoding='1251')
  13. print(dff)
  14. print(type(dff))
  15. ind = dff[1][1]
  16. print(ind)
  17. print(type(ind))
  18. ii = ind[0]
  19. print(ii)
  20. print(type(ii))
  21.  
  22. In [2]: df
  23. Out[2]:
  24. 0 1
  25. 0 a b
  26. 1 [11, 22] [33, 44]
  27.  
  28. In [3]: df.dtypes
  29. Out[3]:
  30. 0 object
  31. 1 object
  32. dtype: object
  33.  
  34. a,b
  35. "[11, 22]","[33, 44]"
  36.  
  37. In [7]: d2 = pd.read_csv(r'D:tempi.csv')
  38.  
  39. In [8]: d2
  40. Out[8]:
  41. a b
  42. 0 [11, 22] [33, 44]
  43.  
  44. In [9]: d2.iat[0,0]
  45. Out[9]: '[11, 22]'
  46.  
  47. In [10]: type(d2.iat[0,0])
  48. Out[10]: str
  49.  
  50. In [11]: df
  51. Out[11]:
  52. 0 1
  53. 0 a b
  54. 1 [11, 22] [33, 44]
  55.  
  56. In [12]: df.sum()
  57. Out[12]: Series([], dtype: float64)
  58.  
  59. In [13]: df.sum(axis=1)
  60. Out[13]:
  61. 0 ab
  62. 1 [11, 22, 33, 44]
  63. dtype: object
  64.  
  65. In [14]: df.max()
  66. Out[14]: Series([], dtype: float64)
  67.  
  68. In [15]: df.max(axis=1)
  69. Out[15]:
  70. 0 b
  71. 1 [33, 44]
  72. dtype: object
Add Comment
Please, Sign In to add comment