小编Nik*_*eri的帖子

如何在pandas DataFrame中按索引仅保留一组特定的行

我通过对 .fits 文件执行以下操作创建了一个 DataFrame:

data_dict= dict()
for obj in sortedpab:
    for key in ['FIELD', 'ID',  'RA' , 'DEC' , 'Z_50', 'Z_84','Z_16' , 'PAB_FLUX', 'PAB_FLUX_ERR']:
        data_dict.setdefault(key, list()).append(obj[key])

gooddf = pd.DataFrame(data_dict)
gooddf['Z_ERR']= ((gooddf['Z_84'] - gooddf['Z_50']) + (gooddf['Z_50'] - gooddf['Z_16'])) / (2 * 
gooddf['Z_50'])
gooddf['OBS_PAB'] = 12820 * (1 + gooddf['Z_50'])
gooddf.loc[gooddf['FIELD'] == "ERS" , 'FIELD'] = "ERSPRIME"
gooddf = gooddf[['FIELD' , 'ID' , 'RA' , 'DEC' , 'Z_50' , 'Z_ERR' , 'PAB_FLUX' , 'PAB_FLUX_ERR' , 
'OBS_PAB']]
gooddf = gooddf[gooddf.OBS_PAB <= 16500]
Run Code Online (Sandbox Code Playgroud)

这给了我一个有 …

python astronomy pandas

5
推荐指数
1
解决办法
8941
查看次数

标签 统计

astronomy ×1

pandas ×1

python ×1