0

I am working with a large Pandas Dataframe in Python I am doing a comparison of three product types being compared together. I would like to do a pd Series value_counts() for the columns at the same time. For example, if the values for productA, productB, and productC that were searched and the combination of the values are the same. I would like to do a value_count() for that.

To further elaborate:

Product A - 24, Product B - 32, Product -64 appeared 4 times, in simple terms.

Here is a sample of my DataFrame:

import pandas as pd
import numpy as np

pd.DataFrame({'product_A': {0: '165',
  1: '166',
  2: '920',
  3: '920',
  4: '920',
  5: '923',
  6: '124',
  7: '124',
  8: '920',
  9: '920',
  10: '165',
  11: '920',
  12: '124',
  13: '132',
  14: '162',
  15: '166',
  16: '166',
  17: '755',
  18: '804',
  19: '923'},
 'product_B': {0: '1920',
  1: '868',
  2: '470',
  3: '470',
  4: '470',
  5: '427',
  6: '125',
  7: '575',
  8: '470',
  9: '470',
  10: '698',
  11: '212',
  12: '576',
  13: '469',
  14: '662',
  15: '466',
  16: '945',
  17: '939',
  18: '469',
  19: '145'},
 'product_C': {0: '1670',
  1: '274',
  2: '212',
  3: '212',
  4: '212',
  5: '453',
  6: np.nan,
  7: '196',
  8: '212',
  9: '212',
  10: '932',
  11: np.nan,
  12: np.nan,
  13: '855',
  14: '160',
  15: '254',
  16: '254',
  17: np.nan,
  18: '1779',
  19: '431'}})
JA-pythonista
  • 1,225
  • 1
  • 21
  • 44

0 Answers0