python从excel中读取数据写⼊word_在python3中从excel到
word的数据传输
只是为了展⽰您使⽤pandas的⽰例性功能:import pandas as pd
df = pd.read_csv('whereverfilemayroam/filename')
Participant ID Breakfasts Lunches/dinners Snacks
0 1111 Full english Risotto Granola
1 1111 Full english Risotto Granola
2 1111 Full english Risotto Granola
3 1111 Full english Risotto Granola
4 1111 Full english Risotto Granola
5 1111 Full english Risotto Granola
6 1111 Full english Risotto Granola
7 1111 None Risotto Granola
8 1111 None Risotto Granola
python怎么读取excel文件数据9 1111 None Risotto Granola
10 1111 None Risotto Granola
11 1111 None Risotto Granola
12 1111 None Risotto Granola
13 1111 None Risotto Granola
14 2222 Avocado toast Bean chilli Apple
15 2222 Avocado toast Bean chilli Apple
16 2222 Avocado toast Bean chilli Apple
17 2222 Avocado toast Bean chilli Apple
18 2222 Avocado toast Bean chilli Apple
19 2222 Avocado toast Bean chilli Apple
20 2222 Avocado toast Bean chilli Apple
21 2222 None Bean chilli Apple
22 2222 None Bean chilli Apple
23 2222 None Bean chilli Apple
24 2222 None Bean chilli Apple
25 2222 None Bean chilli Apple
26 2222 None Bean chilli Apple
27 2222 None Bean chilli Apple
这是pandas数据帧中的⽂件,pandas中的标准容器,如果您愿意的话。现在你可以⽤它做⼤量的统计数据。。。只需在docs中挖掘⼀点⽰例:
^{pr2}$
当然,您可以按参与者ID分开:oneoneoneone = df[df['Participant ID'] == 1111]
oneoneoneone
Participant ID Breakfasts Lunches/dinners Snacks
0 1111 Full english Risotto Granola
1 1111 Full english Risotto Granola
2 1111 Full english Risotto Granola
3 1111 Full english Risotto Granola
4 1111 Full english Risotto Granola
5 1111 Full english Risotto Granola
6 1111 Full english Risotto Granola
7 1111 None Risotto Granola
8 1111 None Risotto Granola
9 1111 None Risotto Granola
10 1111 None Risotto Granola
11 1111 None Risotto Granola
12 1111 None Risotto Granola
13 1111 None Risotto Granola
<_csv('target_file')
也许也是_csv('another_target_file')
也可以迭代组,然后对每个组应⽤相同的操作。
e、 g.:for name, group upby('Participant ID'):
print(name)
upby('Breakfasts').unt().to_string())
upby('Lunches/dinners')['Lunches/dinners'].count().to_string())
upby('Snacks').unt().to_string(), '\n')
退货:1111
Breakfasts
Full english 7
Lunches/dinners
Risotto 14
Snacks
Granola 14
2222
Breakfasts Avocado toast 7 Lunches/dinners Bean chilli 14 Snacks
Apple 14

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。