Why I couldn't add a new row on 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']
I am getting an error whenever I try to excute the code.
I tried also:
df.loc[len(df)+1]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.