新建一个excel表格(table1.csv)用于案例讲解:
导库
import pandas as pd
import numpy as np
读取数据
df = pd.read_excel('table1.xlsx') # 相对路径
# df = pd.read_excel(r'E:\Anaconda\hc\dataScience\table1.csv') # 绝对路径
显示数据
显示数据的行与列数
df.shape
(6, 5)
显示数据格式dtpyes
df.dtypes
Name object
Age int64
Sex int64
Class int64
Score float64
dtype: object
显示列名
df.columns
Index(['Name', 'Age', 'Sex', 'Class', 'Score'], dtype='object')
显示前数据前2行
df.hea