没有合适的资源?快使用搜索试试~ 我知道了~
python基础教程:Python 中pandas.read_excel详细介绍
7 下载量 198 浏览量
2020-12-22
06:43:46
上传
评论
收藏 42KB PDF 举报
温馨提示


试读
2页
这篇文章主要介绍了Python 中pandas.read_excel详细介绍的相关资料,需要的朋友可以参考下 Python 中pandas.read_excel详细介绍 #coding:utf-8 import pandas as pd import numpy as np filefullpath = r"/home/geeklee/temp/all_gov_file/pol_gov_mon/downloads/1.xls" #filefullpath = r"/home/geeklee/temp/all_gov_file/pol_gov_mon/downloads/26368f3a-ea0
资源详情
资源评论
资源推荐

python基础教程:基础教程:Python 中中pandas.read_excel详细介绍详细介绍
这篇文章主要介绍了Python 中pandas.read_excel详细介绍的相关资料,需要的朋友可以参考下
Python 中pandas.read_excel详细介绍
#coding:utf-8
import pandas as pd
import numpy as np
filefullpath = r"/home/geeklee/temp/all_gov_file/pol_gov_mon/downloads/1.xls"
#filefullpath = r"/home/geeklee/temp/all_gov_file/pol_gov_mon/downloads/26368f3a-ea03-46b9-8033-73615ed07816.xls"
df = pd.read_excel(filefullpath,skiprows=[0])
#df = pd.read_excel(filefullpath, sheetname=[0,2],skiprows=[0])
#sheetname指定为读取几个sheet,sheet数目从0开始
#如果sheetname=[0,2],那代表读取第0页和第2页的sheet
#skiprows=[0]代表读取跳过的行数第0行,不写代表不跳过标题
#df = pd.read_excel(filefullpath, sheetname=None ,skiprows=[0])
print df
print type(df)
#若果有多页,type(df)就为
#如果就一页,type(df)就为
#{0:dataframe,1:dataframe,2:dataframe}
pandas.read_excel(io, sheetname=0, header=0, skiprows=None, skip_footer=0,
index_col=None, names=None, parse_cols=None, parse_dates=False, date_parser=None,
na_values=None, thousands=None, convert_float=True, has_index_names=None, converters=None,
engine=None, squeeze=False, **kwds)
Read an Excel table into a pandas DataFrame
参数解析:
io : string, path object (pathlib.Path or py._path.local.LocalPath),
file-like object, pandas ExcelFile, or xlrd workbook. The string could be a URL. Valid URL schemes include http, ftp, s3, and
file. For file URLs, a host is expected. For instance, a local file could be file://localhost/path/to/workbook.xlsx
sheetname : string, int, mixed list of strings/ints, or None, default 0
Strings are used for sheet names, Integers are used in zero-indexed sheet positions.
Lists of strings/integers are used to request multiple sheets.
Specify None to get all sheets.
str|int -> DataFrame is returned. list|None -> Dict of DataFrames is returned, with keys representing sheets.
Available Cases
Defaults to 0 -> 1st sheet as a DataFrame
1 -> 2nd sheet as a DataFrame
“Sheet1” -> 1st sheet as a DataFrame
[0,1,”Sheet5”] -> 1st, 2nd & 5th sheet as a dictionary of DataFrames
None -> All sheets as a dictionary of DataFrames
header : int, list of ints, default 0
Row (0-indexed) to use for the column labels of the parsed DataFrame. If a list of integers is passed those row positions will
be combined into a MultiIndex
skiprows : list-like
Rows to skip at the beginning (0-indexed)
skip_footer : int, default 0
Rows at the end to skip (0-indexed)
index_col : int, list of ints, default None
Column (0-indexed) to use as the row labels of the DataFrame. Pass None if there is no such column. If a list is passed,
those columns will be combined into a MultiIndex





















weixin_38708223
- 粉丝: 5
- 资源: 915
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制

评论0