簡體   English   中英

Pandas 列表列:如何獲取該列列表長度的平均值、最大長度和標准差

[英]Pandas column of lists: How to get the average, max length, and standard deviation of the list lengths of that column

我有一個 pandas 列,其中包含長度不同的整數列表。

我想知道如何獲得這些列表長度的最大值、平均值和標准差。

到目前為止,我找到了這個命令

df['lists'].str.len()

這似乎給出了每一行的長度。 雖然我不是 100% 確定這是否適合我的情況。 但如果是,那么我需要獲取這些值的平均值、最大值和標准差。

是的, df['lists'].str.len()為您提供系列中列表的長度。 要獲取統計信息:

df['lists'].str.len().agg(['mean','max','std'])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM