小代码是。。。你知道吗
import pandas as pd
#INPUT FILE INFORMATION
path = 'C:\Users\BDomitz\Desktop\Python\Stack_Example.xlsx'
sheet = "Sheet1"
#READ FILE
dataframe = pd.io.excel.read_excel(path, sheet)
当前数据帧的输出。。。你知道吗
date animals quantity
0 2015-02-10 dogs 1
1 2015-02-11 cats 2
2 2015-02-11 pigs 5
我希望它看起来像什么。。。你知道吗
date animals quantity dogs cats pigs
0 2015-02-10 dogs 1 1 0 0
1 2015-02-11 cats, pigs 2 0 2 5
我会很感激你的帮助。你知道吗
从数据帧开始:
可以使用
pivot
方法指定应将哪些列用作索引、列名和值:除了“animals”和“quantity”列之外,这将获得所需的输出。他们需要在那里吗?你知道吗
相关问题 更多 >
编程相关推荐