Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- a = [['a', [11,22]],['b',[33,44]]]
- df = pd.DataFrame(a)
- df = df.transpose()
- print(df)
- print(df[1][1])
- print(type(df[1][1]))
- b = df[1][1]
- print(b[1])
- print(type(b[1]))
- df.to_csv('i.csv', sep = ',', header = None, encoding='1251', index = False)
- dff = pd.read_csv('ii.csv',sep = ',', header = None, encoding='1251')
- print(dff)
- print(type(dff))
- ind = dff[1][1]
- print(ind)
- print(type(ind))
- ii = ind[0]
- print(ii)
- print(type(ii))
- In [2]: df
- Out[2]:
- 0 1
- 0 a b
- 1 [11, 22] [33, 44]
- In [3]: df.dtypes
- Out[3]:
- 0 object
- 1 object
- dtype: object
- a,b
- "[11, 22]","[33, 44]"
- In [7]: d2 = pd.read_csv(r'D:tempi.csv')
- In [8]: d2
- Out[8]:
- a b
- 0 [11, 22] [33, 44]
- In [9]: d2.iat[0,0]
- Out[9]: '[11, 22]'
- In [10]: type(d2.iat[0,0])
- Out[10]: str
- In [11]: df
- Out[11]:
- 0 1
- 0 a b
- 1 [11, 22] [33, 44]
- In [12]: df.sum()
- Out[12]: Series([], dtype: float64)
- In [13]: df.sum(axis=1)
- Out[13]:
- 0 ab
- 1 [11, 22, 33, 44]
- dtype: object
- In [14]: df.max()
- Out[14]: Series([], dtype: float64)
- In [15]: df.max(axis=1)
- Out[15]:
- 0 b
- 1 [33, 44]
- dtype: object
Add Comment
Please, Sign In to add comment