round a column in dataframe
Question:
I have a dataframe ‘dayData’ and I am trying to round a zero decimal places one of the columns (the column is called ‘trace’)
I have tried using the following but with no success:
dayData["trace"] = dayData["trace"].round(0)
I get the exception:
AttributeError: 'numpy.float64' object has no attribute 'rint'
What is the correct syntax?
Answers:
With import numpy as np
, do
dayData["trace"] = dayData["trace"].apply(np.round)
I have a dataframe ‘dayData’ and I am trying to round a zero decimal places one of the columns (the column is called ‘trace’)
I have tried using the following but with no success:
dayData["trace"] = dayData["trace"].round(0)
I get the exception:
AttributeError: 'numpy.float64' object has no attribute 'rint'
What is the correct syntax?
With import numpy as np
, do
dayData["trace"] = dayData["trace"].apply(np.round)