Search code examples
pythonpandasdata-analysisdata-science

Pandas: Multiplying two columns of same dataframe thats dependent on third column


How can I multiply two columns of within a same dataframe? My dataframe looks like below image and I want to output like this. However, I cannot find how to multiply two columns that are dependent on first row of same dataframe. I would really appreciate some help on this.

request                            totalbytes
/login                              8520
/shuttle/countdown/                 7970
/shuttle/countdown/liftoff.html     0

enter image description here

So far my output is below, but how can I get unique rows. enter image description here


Solution

  • Now that you explained what you want... You actually want to drop duplicates:

    (df['bytesbytes']*df['bytesfrequency']).drop_duplicates()