Home Forums Main Forums Python Forum Issues trying to add two columns together

  • Issues trying to add two columns together

     Datura updated 4 years ago 2 Members · 2 Posts
  • norahx

    Member
    October 22, 2020 at 2:14 am
    Up
    0
    Down

    I tried to generate a new column by adding two other columns.

    hh_rfm['eRFM']=hh_rfm['MF']+hh_rfm['R']

    This way usually works, however it doesn’t work sometimes.

    I found out the reason being is the type of hh_rfm[‘MF’] is numpy.int64

    and hh_rfm[‘R’] is int

    Is there any easy way to add these two different type columns together instead of using extra function to add two columns?

    Thanks,

  • Datura

    Member
    October 22, 2020 at 10:15 am
    Up
    1
    Down

    A better way is to convert all the R/F/M index to character strings, then concatenate them together. Use a character RFM index rather than numeric.

    • This reply was modified 4 years ago by  Datura.

Log in to reply.

Original Post
0 of 0 posts June 2018
Now