Форум сайта python.su
0
Добрый день, товарищи.
Есть вопросик.
Юзаю модуль pandas для сбора статистики.
Есть объект series, который в свою очередь состоит из данных типа float64.
Считаю среднее, квантили и прочую канитель.
После хочу увидеть целые значения.
Потому применяю функцию round()
метод df.round у пандаса почему-то ругается на округление int, что в общем-то логично.
bmin = df_delta_msec.min() min = round(bmin) y = type (min) print ("Min", min, y) bmean=df_delta_msec.mean() mean = round(bmean) z = type(mean) print ("Среднее", mean, z) bmedian=df_delta_msec.median() median = round(bmedian) print ("Медиана", median) bquantile990=df_delta_msec.quantile(.99) quantile990 = round(bquantile990) v = type(quantile990) print ("Квантиль99,0", quantile990, v) bquantile999=df_delta_msec.quantile(.999) quantile999 = round (bquantile999) print ("Квантиль 99,9", quantile999) bStandardDeviation=df_delta_msec.std() StandardDeviation = round(bStandardDeviation) print ("Стандартное отклонение", StandardDeviation) bmax=df_delta_msec.max() max = round(bmax) print ("Макс", max) quotity=df_delta_msec.count() print ("Количество", quotity)
Отредактировано polinaruru (Дек. 27, 2016 14:35:01)
Офлайн
857
>>> n = round(123.0) >>> n, type(n) (123, <class 'int'>) >>> >>> n = round(123.0, 1) >>> n, type(n) (123.0, <class 'float'>) >>>
>>> print(round.__doc__)
round(number[, ndigits]) -> number
Round a number to a given precision in decimal digits (default 0 digits).
This returns an int when called with one argument, otherwise the
same type as the number. ndigits may be negative.
>>>
Отредактировано py.user.next (Дек. 28, 2016 04:35:37)
Офлайн