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

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

Pandas Drop 布爾值

Pandas Drop 布爾值

慕少森 2024-01-27 14:57:02
我們得到了一個(gè) file.tsv,我們需要構(gòu)建一個(gè)函數(shù)。其中之一是如果一列(此處稱為“l(fā)ow_confidence_variant”)= True,則刪除每一行。我在某種程度上為這部分而奮斗。另外,有什么優(yōu)化建議嗎?根據(jù)結(jié)果,我們需要制作一個(gè)邁阿密圖。這是我到目前為止所做的。任何提示都會(huì)有用;import numpy as npimport pandas as pdimport matplotlib.pyplot as pltdef read_file(file, chromosome):df = pd.read_csv(file, sep='\t', usecols=['chromosome', 'position', 'pval', 'low_confidence_variant'])df.drop(['low_confidence_variant'], True)df.dropna()sub_data = df.replace({'pval': 0}, 1e-274)sub_data['log10'] = -np.log10(sub_data['pval'])chr_group = sub_data.groupby(['chromosome'])chromosome = chr_group.get_group(chromosome)return chromosomedf1 = read_file('vitamin_d.females.tsv.gz', 1)df2 = read_file('vitamin_d.males.tsv.gz', 1)xa = df2['position']ya = df2['log10']xb = df1['position']yb = df1['log10'] * -1fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1, sharex=True, figsize=(12, 4))ax1.scatter(xa, ya, s=1, c="tab:blue")ax1.set_ylabel('males $\it{-log_{10}(pval)}$')ax1.set_title('vitamin D (nmol/L)', fontweight='bold')ax1.axhline(-np.log10(5*10**-8), c ='darkgray', ls='--')ax2.scatter(xb, yb, s=1, c="tab:blue")ax2.set_ylabel('females $\it{log_{10}(pval)}$')ax2.axhline(np.log10(5*10**-8), c ='darkgray', ls='--')plt.xlabel('Chromosome 1 positions')plt.subplots_adjust(hspace=.0)plt.show()fig.savefig(fname='miami.png', dpi=300, bbox_inches='tight', format='png')
查看完整描述

1 回答

?
largeQ

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

我有點(diǎn)不確定你的意思。


Say Df = 

A   B   low_confidence_variant

10  20    True

2    4    False

6    0    False


So after deleting the rows with low_confidence_variant = True, you should have

df = 

A   B     low_confidence_variant

2   4      False

6   0      False

正確的?


如果這就是您的意思:


### Add below line

df = df[df['low_confidence_variant'] != True]

并刪除這一行


### Delete this line from the code

df.drop(['low_confidence_variant'], True)

您所做的就是刪除整個(gè)列本身。


查看完整回答
反對(duì) 回復(fù) 2024-01-27
  • 1 回答
  • 0 關(guān)注
  • 207 瀏覽
慕課專欄
更多

添加回答

舉報(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)