pandas中主要有两种数据结构:Series 和 DataFrame
可以存储在pkl文件中
在python3中可以直接读取pkl文件:
import pickle
word = pickle.load(open('./i2s_dict.pkl','rb'), encoding='utf-8')#有中文
print(word)
把对象写入pkl文件:
output = open('./source1.pkl', 'wb')
pickle.dump(word_series, output)
output.close()
遍历series:
for i, v in s.iteritems():
print('index: ', i, 'value: ', v)
for i, v in s.items():
print('index: ', i, 'value: ', v)
for i in s.index:
print(i)
print(s[i])
series可以从多种python格式转换过来:
import pandas as pd
word_series = pd.Series(word_dict)