C1_W1_Assignment df_distribution_pct

Can anyone explain me about this ?

df_distribution_pct = pd.DataFrame(distribution).transpose().apply(
lambda num_sentiments: num_sentiments/sum(num_sentiments)*100, axis=1

Thanks for the response

Hi @noah360,

Welcome to PDS. I hope you understood distribution dictionary datastructure mentioned in the above cell. Here you are converting the dictionary into Pandas dataframe and passing a function on a column. lambda is used in python to write one line functions.

Best Regards,
A. Sriharsha

1 Like