Feature Type

  • [x] Adding new functionality to pandas

  • [ ] Changing existing functionality in pandas

  • [ ] Removing existing functionality in pandas

Problem Description

I wish i could write one function which will create view for normalizied data and non-normalized data while calliing thi function.

Feature Description

i see this function in this way

def value_counts_with_normalization(self, subset=None,sort=True, ascending=False, dropna=True,percentage = False):
    ----
    non_normalized_df = self.value_counts(subset = subset
                 ,sort = True,ascending=ascending
                ,dropna = dropna, normalization = False).reset_index()

    normalized_df = self.value_counts(subset = subset,sort = True,ascending=ascending,dropna = dropna, normalization = False).reset_index()
    multiplier = 100 if percentage else 1
    normalized_df['proportion'] = normalized_df['proportion']*multiplier
return non_normalized_df.merge(normalized_df , on = subset)

Alternative Solutions

I couln't find alternative solution

Additional Context

Example of output

Image

Comment From: dont-4get-me-men

Also. If it will be okay to add this i would like to write this code by myself)

Comment From: jbrockmendel

this is effectively the same as

left = ser.value_counts()
right = ser.value_counts(normalize=True)
result = pd.concat([left.to_frame("count"), right.to_frame("proportion")])

right? i dont think we want to add new API for this.