how to make all columns in the last row as NAN in pandas dataframe
I have a DataFrame df which consists of the following,
Name Age Company Occupation
Gerald 30 Greenways Doctor
Tippi 25 Pathsect Engineer
Herbi 26 Neways Engineer
The end result should contain the following,
Name Age Company Occupation
Gerald 30 Greenways Doctor
Tippi 25 Pathsect Engineer
NAN NAN NAN NAN
I'm new to pandas
Use selection last row and set NaN
:
df.iloc[-1] = np.nan
print (df)
Name Age Company Occupation
0 Gerald 30.0 Greenways Doctor
1 Tippi 25.0 Pathsect Engineer
2 NaN NaN NaN NaN
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.