0

I have this dataframe

ind inc xx cc
number one one
number two one
NaN one

So what i'm going to do

df['ind inc'] = df3.apply(lambda x:str(x.'ind inc')+str(x.['xx cc']) if str(x.['xx cc']) in str(x.'ind inc') else x.['ind inc'], axis=1)

And this code doesn't work. But if I change columns name on 1 word this will work. For example

A B
number one one
number two one
NaN one
df['B'] = df3.apply(lambda x:str(x.A)+str(x.B) if str(x.B) in str(x.A) else x.A, axis=1)

So my question is how to work with first dataframe where column name have more then 1 word?

red_eyes
  • 3
  • 4

0 Answers0