简体   繁体   中英

How to remove blank line from index of a Dataframe while printing in Python

I had a dataframe wherein there were several values of 'adani' and I grouped them by security used sum() funtion to get the below output. There are several more values below it.

There is an odd blank lines generated above security and below Notional while they both are column headers. Security now being the Index name. How to remove the 2 blank cell lines?

sample of my output

have you tried strip() function? This should work Assuming col as your column name:

dataframe[col] = dataframe[col].str.strip()

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM