Medical Data Visualizer - problem solving


I’ve had some problems with this project so i Googled for solution… and there’s a thing that I can’t understand :confused:

  df_cat = pd.DataFrame(
          ['variable', 'value', 'cardio'])['value'].count()).rename(
          columns={'value': 'total'}).reset_index()

Inside the pd.DataFrame() we have some column names and also [‘value’].count()
I get why there is count(), but i can’t understend where the second ‘value’ series comes from.

With this hint I have (kind of…) finished job but it’s pointless as i don’t get where does the second ‘value’ comes from.

Anybody can help me?

You’ve probably used the “melt” method at some point before for this dataframe (as the exercise tips to do so).

The pandas melt method receives a list of columns from your dataframe which you wish to analyse and then returns a new dataframe with two new columns, one which is ‘variables’ where you can see the “value_vars” you passed for it, and ‘values’ which is the value for each of these variables you’re analyzing.

Try printing df_cat before this piece of code so you can have a better look, sorry for the poor explanation I’m horrible with these things.