data:
Format Type Data Description Reader Writer
0 text CSV read_csv to_csv
1 text JSON read_json to_json
2 text HTML read_html to_html
3 text Local clipboard read_clipboard to_clipboard
4 binary MS Excel read_excel to_excel
5 binary HDF5 Format read_hdf to_hdf
6 binary Feather Format read_feather to_feather
7 binary Msgpack read_msgpack to_msgpack
8 binary Stata read_stata to_stata
9 binary SAS read_sas
10 binary Python Pickle Format read_pickle to_pickle
11 SQL SQL read_sql to_sql
12 SQL Google Big Query read_gbq to_gbq
df.shape(形状)
head(size)——显示前size行数据,默认前五行
tail(size)——显示后size行数据,默认后五行
loc通过标签或布尔数组访问一组行和列
iloc 纯整数位置的索引为选择的位置。
df2.head()
Out[151]:
Format Type Data Description Reader Writer
0 text CSV read_csv to_csv
1 text JSON read_json to_json
2 text HTML read_html to_html
3 text Local clipboard read_clipboard to_clipboard
4 binary MS Excel read_excel to_excel
df2.tail()
Out[152]:
Format Type Data Description Reader Writer
8 binary Stata read_stata to_stata
9 binary SAS read_sas
10 binary Python Pickle Format read_pickle to_pickle
11 SQL SQL read_sql to_sql
12 SQL Google Big Query read_gbq to_gbq
new_df2= df2[['Format Type ', 'Data Description ']]
new_df2
Out[156]:
Format Type Data Description
0 text CSV
1 text JSON
2 text HTML
3 text Local clipboard
4 binary MS Excel
5 binary HDF5 Format
6 binary Feather Format
7 binary Msgpack
8 binary Stata
9 binary SAS
10 binary Python Pickle Format
11 SQL SQL
12 SQL Google Big Query
new_df2.iloc[10:12,:] #通过index去定位我们需要的内容 "10:12" 切片;":" 所有列
new_df2.iloc[10:12,:]
Out[157]:
Format Type Data Description
10 binary Python Pickle Format
11 SQL SQL
df2.iloc[10:20,0:2]
Out[159]:
Format Type Data Description
10 binary Python Pickle Format
11 SQL SQL
12 SQL Google Big Query
new_df2.loc[8:10,] # 通过label name定位
Out[161]:
Format Type Data Description
8 binary Stata
9 binary SAS
10 binary Python Pickle Format
new_df2.loc[8:10,'Format Type ']
Out[163]:
8 binary
9 binary
10 binary
Name: Format Type , dtype: object