Skip to content

Instantly share code, notes, and snippets.

@Keycatowo
Created February 4, 2022 08:39
Show Gist options
  • Save Keycatowo/b4f0483a1566ef60fd17f012a5e39e4d to your computer and use it in GitHub Desktop.
Save Keycatowo/b4f0483a1566ef60fd17f012a5e39e4d to your computer and use it in GitHub Desktop.
pandas中對DataFrame進行統計之描述型方法
# 統計敘述(個別)
df.max()
df.mean()
df.count() # 回傳非nan數量
# 統計敘述(統合)
df.describe()
# 唯一值
df.apply(lambda x:x.unique(),axis=0) # uniques by columns
@Keycatowo
Copy link
Author

describe輸出為一個DataFrame,數值類型欄位都會被送入考慮
image

@Keycatowo
Copy link
Author

唯一值可以用apply的方式達到
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment