pandas模組的統計指標 實現眾數和眾數的頻數

2021-09-24 13:53:47 字數 1254 閱讀 5302

max()

最大值min()

最小值ptp()

極差mean()

平均值var()

方差std()

標準差mode()

眾數        (返回乙個dataframe格式的資料)

count()

非空數目

median()

中位數cov()

協方差count   mean  std  min  25%  50%  75%  max

import pandas as pd

detail=pd.read_excel('./meal_order_detail.xlsx',sep=',',encoding='gbk')

print('amounts的describe統計指標:',detail['amounts'].describe())

# 選擇dishes_name 型別為object

# 眾數

print('dishes_name的眾數:', detail['dishes_name'].mode())

print('dishes_name的非空數目:', detail['dishes_name'].count())

# 使用describe()進行非數值型資料統計分析

print('dishes_name的describe統計指標:', detail['dishes_name'].describe()) # 返回4種指標

先將數值型資料轉換成類別型資料,然後用describe()進行統計

型別轉換用astype()實現

detail['amounts'] = detail['amounts'].astype('category')

# 再進行describe()統計分析

Redis Zset實現統計模組

檢視總體配置的數量以及活躍的數量 檢視每一條配置的使用量 直接在mysql中count即可得到 實現方式有很多,經過選擇之後,選取了用redis的zset來實現 使用hashmap,當獲取到配置的使用,那配置的key獲取value加1即可 可能存在的問題,併發問題,集群中每個節點的資料怎麼聚合 在m...

Pandas的主要模組

pd.read csv 讀取文字檔案 csv tsv txt等格式 pd.read excel 讀取電子 xls或xlsx格式 pd.read sql 讀取資料庫資料 需要pymysql或pymssql模組的配合 df.to csv 寫入文字檔案 df為dataframe物件 df.to csv 寫...

pandas 常見的統計方法

pandas 常見的統計方法方法 說明count 非 na 值的數量 describe 針對 series 或 df 的列計算匯 計 min max 最小值和最大值 argmin argmax 最小值和最大值的索引位置 整數 idxmin idxmax 最小值和最大值的索引值 quantile 樣本...