0

I would like to create a new column under the following condition:

So basically I have two column Majoy car and Major housetype. I would let all the 'nocar' within Majoy car AND 'Rented' within Major housetype to merge to a new column.

My DataFrame is imd_car_house

I have tried: imd_car_house.loc[(cond1) | (cond2), :] but this is not working.

2
  • Are you using pandas? Commented Nov 4, 2017 at 16:22
  • What do you mean by "merge to a new column" Commented Nov 4, 2017 at 16:23

1 Answer 1

0

As the comments suggest it is unclear if you are using pandas but if you are, and your columns are 'Majoy car' and 'Major housetype' then the following should work if you want all the rows in your dataframe conforming to your requirements.

imd_car_house[(imd_car_house['Majoy car']=='nocar')&(imd_car_house['Major housetype']=='Rented)]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.