第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何創(chuàng)建一個(gè)具有小而簡(jiǎn)單功能的新列

如何創(chuàng)建一個(gè)具有小而簡(jiǎn)單功能的新列

幕布斯6054654 2023-08-22 16:53:52
我對(duì) Pandas 很陌生,所以我不知道該怎么做。我有一個(gè)帶有 Pandas 的 Python 腳本,用于從在線 .csv 中檢索數(shù)據(jù),其中包含西班牙各省的 covid 數(shù)據(jù)。我想創(chuàng)建一個(gè)新列來創(chuàng)建一個(gè)新變量。這些將是(每日新增死亡人數(shù)/100.000 人口) 有可能嗎?在 csv 中,我們已經(jīng)有了人口數(shù)據(jù),因此函數(shù)為:(population/1.000.000)*daily_deaths這是我的代碼,所以我不知道如何開始import requestsimport pandas as pddf1 = pd.read_csv("https://raw.githubusercontent.com/montera34/escovid19data/master/data/output/covid19-provincias-spain_consolidated.csv")df1  = pd.DataFrame(df1) #no indexAlbacete = df1.loc[df1["province"] == "Albacete"]Alicante = df1[df1['ine_code'] == 3][['date',"PCR","TestAc",'province',"new_cases","activos","hospitalized","intensive_care","deceased","cases_accumulated","recovered","cases_per_cienmil","intensive_care_per_1000000","deceassed_per_100000","hospitalized_per_100000","daily_deaths","deaths_last_week"]]Almeria  = df1.loc[df1['ine_code'] == 3]Alava    = df1.loc[df1['ine_code'] == 1]Asturias = df1.loc[df1['ine_code'] == 33]Avila    = df1.loc[df1['ine_code'] == 5]Badajoz  = df1.loc[df1['ine_code'] == 6]Baleares = df1.loc[df1['ine_code'] == 7]Barcelona= df1.loc[df1['ine_code'] == 8]Bizcaia  = df1.loc[df1['ine_code'] == 48]Burgos   = df1.loc[df1['ine_code'] == 9]Caceres  = df1.loc[df1['ine_code'] == 10]Cadiz    = df1.loc[df1['ine_code'] == 11]Cantabria= df1.loc[df1['ine_code'] == 39] Castellon= df1.loc[df1['ine_code'] == 12]Ceuta    = df1.loc[df1['ine_code'] == 51]Ciudad_R = df1.loc[df1['ine_code'] == 13]Cordoba  = df1.loc[df1['ine_code'] == 14]Cuenca   = df1.loc[df1['ine_code'] == 16]Guipuzcoa= df1.loc[df1['ine_code'] == 20]Girona   = df1.loc[df1['ine_code'] == 17] Madrid   = df1[df1['ine_code'] == 28][['date',"PCR","TestAc",'province',"new_cases","activos","hospitalized","intensive_care","deceased","cases_accumulated","recovered","cases_per_cienmil","intensive_care_per_1000000","deceassed_per_100000","hospitalized_per_100000","daily_deaths","deaths_last_week"]]
查看完整描述

2 回答

?
慕斯王

TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超2個(gè)贊

我無法輕松查看所有 DataFrame 列,但請(qǐng)嘗試以下操作:

df1['percent_per_day'] = (df1['population']/1000000) * df1['daily_deaths']

在哪里:

df1['percent_per_day']是你的新專欄

df1['population']以及df1['daily_deaths']這些列在 df1 中的名稱


查看完整回答
反對(duì) 回復(fù) 2023-08-22
?
森林海

TA貢獻(xiàn)2011條經(jīng)驗(yàn) 獲得超2個(gè)贊

不確定這是否是您正在尋找的內(nèi)容,但根據(jù) csv 中的列,嘗試在“poblacion”為人口的情況下嘗試此操作

df1['death_rate'] = (df1['poblacion']/1000000) *df1['daily_deaths']


查看完整回答
反對(duì) 回復(fù) 2023-08-22
  • 2 回答
  • 0 關(guān)注
  • 188 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)