python - 将数据框转换为多列系列

标签 python pandas dataframe series

This is also a dataset contain 2 dimension but it is series type Convert dat frame to series

我尝试将数据框转换为系列但它显示以下错误。我使用 pandas.Series(Dataframe) -> 将 Dataframe 转换为系列

我想要第一张图片格式的输出

最佳答案

请尝试以下方法从提到的数据中获取 Series 对象(假设 data 是您正在使用的 DataFrame)

series = pd.Series(data['Sales'], index=data.index)

希望对您有所帮助。

关于python - 将数据框转换为多列系列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52329220/

相关文章:

python - python 总是同步调用 __del__ 吗?

python - 如何将变量与文本字符串混合?

Python/ Pandas : Selecting dataframe rows with multiple conditions - col 1 matches col 2 OR col 3

python - 动态评估 Pandas 公式中的表达式?

python - 比较文件夹内容

python - 如何将多个 pandas 数据帧写入单个输出 excel 文件?

python - 在 Pandas 中使用 PeriodIndex 与 DateTimeIndex ?

python - 如何找到今天和 future 日期之间的天数?

python - 在 Python pandas 中有选择地将 float 转换为整数和小数

python - 从python中的列表列表构造共现矩阵