0

I have dataframe

ID  RuCitySize  qsex    age ranges  url used_at active_seconds
 f78f67101c3aeb099212b8aa9a95dfd2   500-млн Женский 18-24   lada.ru 03.01.2016 20:18    66.25557348
 f78f67101c3aeb099212b8aa9a95dfd2   500-млн Женский 18-24   lada.ru/cars/vesta/sedan/tth.html   03.01.2016 20:18    51.5321127
 f78f67101c3aeb099212b8aa9a95dfd2   500-млн Женский 18-24   lada.ru/cars/4x4/3dv/prices.html    03.01.2016 20:20    22.08519116
 f78f67101c3aeb099212b8aa9a95dfd2   500-млн Женский 18-24   lada.ru/cars/4x4/3dv/1.7_8_mkpp/lux/017/114/card.html   03.01.2016 20:20    29.44692154
 740e2b36a4fa2d145436293522f5f5d5   500-млн Женский 18-24   penza-avto.lada.ru/ds/cars  05.01.2016 12:51    7.361730386
 740e2b36a4fa2d145436293522f5f5d5   500-млн Женский 18-24   penza-avto.lada.ru/ds/cars/granta/liftback/prices.html  05.01.2016 12:51    66.25557348

And df

qsex    age ranges  RuCitySize  FOM_quota
Женский 18-24   100-500 3.680865193
Женский 18-24   500-млн 1.764538469
Женский 18-24   Миллионники 2.295797363

I need if values in columns qsex, age ranges, RuCitySIze are equal, multiplicate value from active_seconds to FOM_quota. How can I do that?

1
  • 1
    can you show desired output? Commented Aug 23, 2016 at 17:46

1 Answer 1

1

you can do it this way:

In [33]: df1['new'] = (df1['active_seconds'] *
   ....:               pd.merge(df1, df2,
   ....:                        on=['qsex', 'age ranges', 'RuCitySize'],
   ....:                        how='left')['FOM_quota'])

In [34]: df1[['active_seconds','new']]
Out[34]:
   active_seconds         new
0       66.255573  116.910508
1       51.532113   90.930395
2       22.085191   38.970169
3       29.446922   51.960226
4        7.361730   12.990056
5       66.255573  116.910508
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.