1.df.loc 方法
新建df:
df = pd.DataFrame(columns=['name', 'stu_num'])
添加一行:
df.loc[1] = ['Jack', 1]
运行结果:
2.df.append (python3.11有警告)
df.append(pd.Series({'name':'Jcck','stu_num':1}),ignore_index=True)
警告:pandas以后很可能移除此方法
FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead. df.append(pd.Series({'name':'Jcck','stu_num':1}),ignore_index=True)