简体   繁体   中英

Suppress scientific notation for a whole column line with Pandas

Hi I am quite new in Python, but after a lot of videos and requests i´ve managed to get somewhere. My problem now is that I have a whole column in a CSV written in scientific notation (float) and what I am trying is to display the whole column in an XML but showing the whole number as a string.

Here´s my code:

pd.options.display.float_format = '{:.0f}'.format
data = pd.read_csv(report, delimiter=',') 
commissioned = data.loc[data['SerialNumberState'] == 'Commissioned'] 
commissioned.to_csv('C:/Users/Engineering/Desktop/Commisioned.csv', index=False) 
commissioned.reset_index(drop=True, inplace=True) 
com_sn = commissioned['SerialNumber']
com_sscc = commissioned['ParentSerialNumber'] 
sscc = com_sscc.drop_duplicates() 
print(sscc)

And this is what i get:

TypeError: write() argument must be str, not Series

So i thought about using print(str(sscc)) function but it prints a lot of stuff that i don´t need (as the index and data information), as shown below:

0    257138440200000160
1    257138440200000288
2    257138440200000224
3    257138440200000256
4    257138440200000192
12                  nan
15   257138440200000096
21   257138440200000032
22   257138440200000064
Name: ParentSerialNumber, dtype: float64 

I only need the SerialNumbers.

Try

import pandas as pd
pd.options.display.float_format = '{:,.2f}'.format

You can see more about styling here and here

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