您非常亲密,首先
to_frame通过
T:
s = pd.Series([1159730, 1], index=['product_id_y','count'], name=6159402)print (s)product_id_y 1159730count 1Name: 6159402, dtype: int64df = s.to_frame().Tprint (df) product_id_y count6159402 1159730 1
df = s.rename(None).to_frame().Tprint (df) product_id_y count0 1159730 1
Dataframe构造函数的另一个解决方案:
df = pd.Dataframe([s])print (df) product_id_y count6159402 1159730 1
df = pd.Dataframe([s.rename(None)])print (df) product_id_y count0 1159730 1
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)