日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

python 熊猫,Python熊猫

發(fā)布時(shí)間:2025/3/11 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 熊猫,Python熊猫 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

我試圖連續(xù)分組和計(jì)算相同的信息:

#Functions

def postal_saude ():

global df, lista_solic

#List of solicitantes in Postal Saude

list_sol = [lista_solic["name1"], lista_solic["name2"]]

#filter Postal Saude Solicitantes

df = df[(df['Cliente']==lista_clientes["6"])

& (df['Nome do solicitante'].isin(list_sol))]

#Alphabetical order

df = df.sort_index(by=['Nome do solicitante', 'nomeCorrespondente'])

#Grouping data of column

grouping = df.groupby('Tipo do servi?os');

print (grouping)

postal_saude()

當(dāng)它到達(dá)df.groupby時(shí)會(huì)產(chǎn)生錯(cuò)誤

我試過(guò)搜索同樣的錯(cuò)誤,但我沒(méi)有找到一個(gè)有效的答案,以幫助我解決我的問(wèn)題.

請(qǐng)幫忙

請(qǐng)查看有關(guān)

Group By的此文檔

Group series using mapper (dict or key function, apply given function

to group, return result as series) or by a series of columns

上一個(gè)是從here開(kāi)始的

這是一個(gè)簡(jiǎn)單的例子:

df = pd.DataFrame({'a':[1,1,1,2,2,2,3,3,3,3],'b':np.random.randn(10)})

df

a b

0 1 1.048099

1 1 -0.830804

2 1 1.007282

3 2 -0.470914

4 2 1.948448

5 2 -0.144317

6 3 -0.645503

7 3 -1.694219

8 3 0.375280

9 3 -0.065624

groups = df.groupby('a')

groups # Tells you what "df.groupby('a')" is, not an error

groups.count() # count the number of 1 present in the 'a' column

b

a

1 3

2 3

3 4

groups.sum() # sums the 'b' column values based on 'a' grouping

b

a

1 1.224577

2 1.333217

3 -2.030066

你明白了,你可以使用我提供的第一個(gè)鏈接從這里構(gòu)建.

df_count = groups.count()

df_count

b

a

1 3

2 3

3 4

type(df_count) # assigning the `.count()` output to a variable create a new df

pandas.core.frame.DataFrame

總結(jié)

以上是生活随笔為你收集整理的python 熊猫,Python熊猫的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。