Pandas创建Series/DataFrame

创建Series

#1.通过list创建
a = pd.Series([1,2,3,4,3,3,4])
b = pd.Series([1,2,4,5], index = ["a","b","c","d"])
#2.通过数组创建
a = pd.Series(np.arange(6))
#3.通过字典生成,key ==>index
a = pd.Series({"a":1,"b":2,"c":3})

创建DataFrame

#1.通过字典创建
d = {'col1': [1, 2], 'col2': [3, 4]}
df = pd.DataFrame(data=d,dtype=np.int8)
#2.通过包含Series创建字典





你可能感兴趣的:(Pandas创建Series/DataFrame)