我是靠谱客的博主 鲤鱼小懒虫,这篇文章主要介绍pandas读取excel文档,每列标题及标题下的内容,总行数,总列数,现在分享给大家,希望可以做个参考。

pandas读取excel文档,每列标题及标题下的内容,总行数,总列数

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pandas ''' ''' # file_path为excel的文件路径 def read_excel(file_path): # 读取excel # df=pandas.read_excel(file_path,sheet_name=excel里的表名) df=pandas.read_excel(file_path) # len出excel的总行数 line_count=len(df) # len出excel的总列数 column_count=len(df.head()) # df.head()方法可以获取excel一列里所有的标题名称, # print(df.head())默认显示前五个标题名称 # 循环每行 for line_i in range(line_count): # 循环每列标题名称,获取指定想要的标题名称下的数据 column_num=0 for i in df.head(): print('i',i) if i=='你想获取的固定标题名称': # 获取此行此列下的参数data # ix为旧版本方法,新版本的方法是df.iloc[line_i, column_num] data = df.ix[line_i, column_num] print('data',data) column_num+=1

最后

以上就是鲤鱼小懒虫最近收集整理的关于pandas读取excel文档,每列标题及标题下的内容,总行数,总列数的全部内容,更多相关pandas读取excel文档,每列标题及标题下内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部