我有以下几行Python代码:
df['small_homes'] = 0 #creates new column set to zero
df.loc[(df['bathrooms'] == 1) or # if one bathroom
(df['bathrooms'] < 2) & # or if less than two bedrooms
(df['bedrooms'] == 1), # and if one bedroom
'small_homes'] = 1 # sets small_homes = 1 if true
df.head()
我想在一个名为“Small_homes”的数据框中创建一个新列,该列只包含一个浴室(bathrooms列)或少于两个浴室和一个卧室(Bethrooms列)的列表。我尝试过使用OR,但它返回的值不明确
我怎么修理
谢谢大家!
目前没有回答
相关问题 更多 >
编程相关推荐