【问题标题】:Selecting multiple values in a column with a specific name with python for plotting使用python在具有特定名称的列中选择多个值进行绘图
【发布时间】:2021-03-19 03:11:33
【问题描述】:
df4=df3[['occ_title','tot_emp']]
df4.loc[df4['occ_title'] == 'Cooks, Fast Food']

此代码返回快餐厨师,但我不确定如何选择多个 occ_title。我将使用这些数据在图表中进行投影。

The dataframe can be seen in the image and I want to select several "occ_titles" with their tot_emp number as well

【问题讨论】:

    标签: python pandas matplotlib charts


    【解决方案1】:

    你试过 .isin() 方法吗?

    df4 = df3.loc[df3['occ_title'].isin(['Cooks, Fast Food','Second, Title']), ['occ_title','tot_emp']]

    【讨论】:

    • 不要这样链接你的索引器。做df4 = df3.loc[<row indexer>, <col indexer>]
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-10
    • 1970-01-01
    • 1970-01-01
    • 2017-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多