Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas decimal places

# (1) Round to specific decimal places – Single DataFrame column
df['DataFrame column'].round(decimals=number of decimal places needed)

# (2) Round up – Single DataFrame column
df['DataFrame column'].apply(np.ceil)

# (3) Round down – Single DataFrame column
df['DataFrame column'].apply(np.floor)

# (4) Round to specific decimals places – Entire DataFrame
df.round(decimals=number of decimal places needed)
Source by datatofish.com #
 
PREVIOUS NEXT
Tagged: #pandas #decimal #places
ADD COMMENT
Topic
Name
7+6 =