Python之pandas
文章目录
环境:jupyter Notebook(Anaconda)
1.引入pandas库和numpy库
import pandas as pd
import numpy as np
2. 读取文件
t1=pd.read_excel('D:\scores.xlsx',header=[0,1],index_col=0) #读取文件
t1
#index_col 接收int、sequence或者False。表示设定的列作为行名,如果是一个数列,则是多重索引,默认为None
3. index函数
index 接收boolean。表示是否将行索引作为数据传入数据库。默认为True
index_label 接收string或者sequence.代表是否引用索引名称,如果index参数为true,此参数为None,则使用默认名称。如果为多重索引,则必须使用sequence形式。默认为None
sorted_obj=t1.sort_index(ascending=True)
sorted_obj