Pandas crosstab - How to print rows/columns for values that don't exist in the data sets?
<p>I am a beginner with pandas at best and I couldn't find a solution to this problem anywhere.</p>

<p>Let's say I have two variables: variable1, variable2.</p>

<p>They can have the following <strong>predefined</strong> values:</p>

<pre><code>variable1 = ['1', '4', '9', '15', '20']
variable2 = ['2', '5', '6']
</code></pre>

<p>However, the current data set only has some of those values:</p>

<pre><code>df = pd.DataFrame({variable1 : ['1', '9', '20'],
                  variable2 : ['2', '2', '6']})
</code></pre>

<p>When crossing the variables:</p>

<pre><code>pd.crosstab(df.variable1, df.variable2)
</code></pre>

<p>I get:</p>

<pre><code>variable2  2  6
variable1      
1          1  0
20         0  1
9          1  0
</code></pre>

<p>Is there a way to put all the possible categorical values in both the columns and the rows even if the current data set does not have all of them? The goal is to have a table of the same size when running the script with an updated data set which may have the values that were not present in the previous data set.</p>