Skip to content

Instantly share code, notes, and snippets.

@mepsrajput
Last active April 23, 2022 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mepsrajput/c1551455befe813cc20f14653fe7e8d5 to your computer and use it in GitHub Desktop.
Save mepsrajput/c1551455befe813cc20f14653fe7e8d5 to your computer and use it in GitHub Desktop.
from IPython.display import display
def multiFreq(dataset, variable_list):
for i in variable_list:
datax = dataset[f'{i}'].value_counts()
datay = pd.DataFrame({
f'{i}': datax.index,
'Frequency': datax.values,
'Percent': ((datax.values/datax.values.sum())*100).round(2),
'Cumulative Frequency': datax.values.cumsum(),
'Cumulative Percent': ((datax.values.cumsum()/datax.values.sum())*100).round(2)
})
display(datay)
multiFreq(data, ['GENRE', 'MOVIE'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment