文章目录
1、csv文件读取
- 使用函数:pd.read_csv(“file_name”),此函数的返回值是DataFrame
2、DataFrame常用函数
-
分组函数groupby
该函数最棒的一点就是能够分组地使用DataFrame的一些常用函数 -
去空值处理dropna
对DataFrame进行去空值处理通常用dropna()函数 -
按行遍历
for row in data.itertuples():
dic[getattr(row,'year')] = dic[getattr(row,'year')] + getattr(row,'births')#year、births为列名
- 样题:https://www.educoder.net/tasks/3bqg5w4yhipl.
A题代码如下:
plt.figure(figsize=(10,10))
a = pd.read_csv(file_path)#读取csv文件
data