python 建立一对多的数据结构:Series,DataFrame值为列表
Series值为列表会报错,诸如:
Length of passed values is 10, index implies 1,
值的形式应为:值修改为Series数据结构,再将其加入列表中,如下:
import pandas as pd
import numpy as np
a=pd.Series(["a","b","c"])
list1 = []
list1.append(a)
c = ["公司"]
b = pd.Series(list1,index = c)
若为DataFrame数据结构:
import pandas as pd
import numpy as np
a=pd.Series(["a","b","c"])
list1 = []
list1.append(a)
a=pd.Series(["f","g","k"])
list1.append(a)
c = ["上海分公司","北京分公司"]
b = pd.Series(list1,index = c)