python 学习笔记【pandas 】

一、基本数据集操作

(1)读取 CSV 格式的数据集

pd.DataFrame.from_csv(“csv_file”)

或者:

pd.read_csv(“csv_file”)

(2)读取 Excel 数据集

pd.read_excel("excel_file")

(3)将 DataFrame 直接写入 CSV 文件

如下采用逗号作为分隔符,且不带索引:

df.to_csv("data.csv", sep=",", index=False)

(4)基本的数据集特征信息

df.info()

(5)基本的数据集统计信息

print(df.describe())

(6) Print data frame in a table

将 DataFrame 输出到一张表:

print(tabulate(print_table, headers=headers))

当「print_table」是一个列表,其中列表元素还是新的列表,「headers」为表头字符串组成的列表。

(7)列出所有列的名字

df.columns

猜你喜欢

转载自blog.csdn.net/weixin_37805635/article/details/86133233