为什么我无法在pandas上添加新行?
data="""lname fname rno_cd eri_cd
0 CRUISE TOM E 1
1 DEPP JOHNNY Y 0
2 DICAPR LENARDO Nan 1
3 PITT BRAD Nan 1
4 MOST JEFF A 0
5 HANKS TOM Nan 1
6 BRANDO MARLON C 1
7 WILLIAMS ROBIN F 1
8 DOWNEY ROBERT B 1
9 PACINO AL E 1"""
import pandas as pd
from io import StringIO
df= pd.read_csv(StringIO(data.decode('UTF-8')),delim_whitespace=True )
df.loc[-1]= ['2','3','4','4']
每当我尝试执行代码时,我都会收到错误消息。
我也试过了:
df.loc[len(df)+1]