Variable Inspector

Hello all,

Anyone know what is the idea behind variable inspector?
In general, we can run the code correctly without it. Why we mention an exact number (question1 = 6 and question2 = 3) ? What happen if we work on a large dataframe that we don’t know the exact number of rows and columns? I guess we will explore the concantenated dataframe with


hey @rpmuayyad

Would you please elaborate on your question.

Do you want to understand the overall purpose of the variable inspector? Or this question is specific to a particular mission/ course. Please attach a link to the source, where the instructions are causing confusion to you.

Hi @Rucha

Thank you for your respond.
Yes I’d like to understand the overall purpose of the variable inspector.

In the mission 344-2, it is used to view concat_axis0 and concat_axis1 :
I wonder why we use the exact numbers to view concat_axis0 and concat_axis1 ?


hi @rpmuayyad

In general, the variable inspector works as an intermediate output window. It shows the various variables involved in our code including the temporary ones such as iterators in the for loop.

Let’s understand this with the help of this code:

sum_val = 0
for each in [1, 2, "a", 4]:
    sum_val += each


Since the list is so small, you would instantly understand the “a” value is a string type and hence won’t add to the int type values (1, 2, & 4). However, if we look at the output window, we get this error. Now the highlighted part doesn’t give us any information about what actually caused the error as in what exact value led to the error.


Imagine, identifying that when we have a dataframe column with 5000 values. Now in the variable inspector if we look at the iterator “each” we see the last value it tried to execute is “a”. This is where the variable inspector comes in handy, to help in identifying and debug the code


Coming to the mission-specific requirement. Here again, the concat_axis0 is a small resultant dataframe. so you won’t be wrong to look at it in the output window. however try to see the first two rows from happiness2016 dataframe in the output window and the variable inspector.
It’s easier to read in the latter.


Finally, question1 and question2 are actually created for the checking purpose of the mission, and nope they don’t need the hardcoded values to be correct. This must have been taken up in a former mission. use the df.shape method to complete this part.

Try the code, and let us know if you face any issue.

I hope the above response helps you somewhat.


Hi @Rucha

Thank you very much for your explanation.
I now understand it well.


1 Like