pandas 将数据帧转换为多列的系列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52329220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Convert dataframe to series for multiple column
提问by saravanan saminathan
采纳答案by yogkm
Please try the following approach to get a Series object from mentioned data(assuming data
is the DataFrame you're using)
请尝试以下方法从提到的数据中获取 Series 对象(假设data
是您正在使用的 DataFrame)
series = pd.Series(data['Sales'], index=data.index)
Hope that helps.
希望有帮助。
回答by Manmeet Singh
I would suggest you to see the answer by https://stackoverflow.com/a/33247007/3528612You should think of it as a problem of converting multiple column to a series. Hence as suggested in the answer by @dsm you should extract columns out of the dataframe.
我建议您通过https://stackoverflow.com/a/33247007/3528612查看答案 您应该将其视为将多列转换为系列的问题。因此,正如@dsm 在回答中所建议的那样,您应该从数据框中提取列。