[PYTHON] I want to align the significant figures in the Numpy array

Align the significant figures of the Numpy array in Python Note.

※ Things necessary

import numpy as np
import pandas as pd

numpy_data = np.array([0.123456, 0.654321, 0.987654321])

#Convert numpy array to Pandas DataFrame
panda_data = pd.DataFrame(numpy_data)

#Round with 3 significant digits
panda_data = panda_data.round(3)

#Revert to Numpy format if needed
numpy_data2 = np.array(panda_data.values)

print(numpy_data2) --> [0.123, 0.654, 0.988]

In Pandas DataFrame

.round(Significant figures)

By, you can specify significant figures.

Isn't there any other good way?

Recommended Posts

I want to align the significant figures in the Numpy array
I want to judge the authenticity of the elements of numpy array
I want to display the progress in Python!
I want to write in Python! (3) Utilize the mock
I want to use the R dataset in python
I want to change the Japanese flag to the Palau flag with Numpy
I want to make the Dictionary type in the List unique
I didn't want to write the AWS key in the program
[Linux] I want to know the date when the user logged in
numpy: I want to convert a single type ndarray to a structured array
LINEbot development, I want to check the operation in the local environment
I want to make the second line the column name in pandas
I want to pass the G test in one month Day 1
I want to know the population of each country in the world.
I want to pin Spyder to the taskbar
I want to output to the console coolly
I want to print in a comprehension
I want to handle the rhyme part1
I want to handle the rhyme part3
I want to display the progress bar
I want to embed Matplotlib in PySimpleGUI
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
I want to change the color by clicking the scatter point in matplotlib
[C language] I want to generate random numbers in the specified range
I want to explain the abstract class (ABCmeta) of Python in detail.
I want to sort a list in the order of other lists
I want to use the Django Debug Toolbar in my Ajax application
For the first time in Numpy, I will update it from time to time
How to sort by specifying a column in the Python Numpy array.
I want to do Dunnett's test in Python
I want to pin Datetime.now in Django tests
I want to create a window in Python
I want to handle the rhyme part7 (BOW)
I want to store DB information in list
I want to merge nested dicts in Python
I want to customize the appearance of zabbix
I want to use the activation function Mish
I want to visualize where and how many people are in the factory
[Python] I want to know the variables in the function when an error occurs!
Set the number of elements in a NumPy one-dimensional array to a power of 2 (0 padded)
I want to use Python in the environment of pyenv + pipenv on Windows 10
[Django memo] I want to set the login user information in the form in advance
I want to set a life cycle in the task definition of ECS
I want to see a list of WebDAV files in the Requests module
I want to get the file name, line number, and function name in Python 3.4
I want to write in Python! (1) Code format check
I want to see the file name from DataLoader
I tried to graph the packages installed in Python
I want to embed a variable in a Python string
I want to easily implement a timeout in python
Various ways to extract columns in a NumPy array
I want to transition with a button in flask
I want to use self in Backpropagation (tf.custom_gradient) (tensorflow)
I want to grep the execution result of strace
I want to scroll the Django shift table, but ...
Convert NumPy array "ndarray" to lilt in Python [tolist ()]
Even in JavaScript, I want to see Python `range ()`!
I want to inherit to the back with python dataclass
I want to work with a robot in python.