0

I am trying to filter the rows of a DataFrame according to the below conditions and want to replace the values by a new value of a column. The error I am getting is:

TypeError: unsupported operand type(s) for &: 'float' and 'bool'

The picture of df is in link.

dataset**

data1=data.loc[data['dob_years']==0] & data.loc[data['income_type']=='retiree']
replace value of dob_years==0 by 60.0
Henry Ecker
  • 34,399
  • 18
  • 41
  • 57

1 Answers1

0

Try:

data1 = data[(data['dob_years']==0) & (data['income_type']=='retiree')]

And then:

data1['dob_years'].replace(0,60, inplace=True)
gioarma
  • 418
  • 2
  • 15