How to Format or Suppress Scientific Notation in NumPy?

Given a Pandas DataFrame, we have to format or suppress scientific notation.
Submitted by Pranit Sharma, on June 01, 2022

Scientific notations are nothing but the minimized long float values. Whenever we have a large number of values after the decimal point, the compiler converts it into the scientific notations.

To convert the format of these notations or to suppress scientific notations in pandas DataFrame. We will use:

    precision = 1, 

By using the above syntax, we will be able to write a value in scientific notation. Here, arr is the array which we will create, note that the length of the arr will be 1.

To work with pandas, we need to import pandas package first, below is the syntax:

import pandas as pd

Let us understand with the help of an example,

# Importing numpy package
import numpy as np

# Creating a Array
arr = np.array([10**20])

# Showing result in scientific notation
arr = np.format_float_scientific(arr, precision = 1, exp_digits=2)

# Display Created Array with scientific notations
print("Created Array\n",arr)


Example: Format or Suppress Scientific Notation

Python Pandas Programs »


Comments and Discussions!


Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.