Title: selecting a column from pandas pivot table
Tags: python;pandas;pivot-table;python-3.5
Question: I have the below pivot table which I created from a dataframe using the following code:

```table = pd.pivot_table(df, values='count', index=['days'],columns['movements'], aggfunc=np.sum)

movements 0    1   2   3   4   5   6   7
days
0         2777 51  2                    
1         6279 200 7   3                
2         5609 110 32  4                
3         4109 118 101 8   3            
4         3034 129 109 6   2   2        
5         2288 131 131 9   2   1        
6         1918 139 109 13  1   1        
7         1442 109 153 13  10  1        
8         1085 76  111 13  7           1
9         845  81  86  8   8            
10        646  70  83  1   2   1   1
```

As you can see from pivot table that it has 8 columns from 0-7 and now I want to plot some specific columns instead of all. I could not manage to select columns. Lets say I want to plot column 0 and column 2 against index. what should I use for y to select column 0 and column 2? 

```plt.plot(x=table.index, y=??)
```

I tried with ```y = table.value['0', '2']``` and ```y=table['0','2']``` but nothing works.


Here is the accepted answer: You cannot select ndarray for ```y``` if you need those two column values in a single plot you can use:

```plt.plot(table['0'])
plt.plot(table['2'])
```

If column names are intergers then:

```plt.plot(table[0])
plt.plot(table[2])
```

Comment for this answer: Thanks. The column names are integers. When I do plt.plot(x=table.index, y=table[0]), I do not get any error but somehow plotting function does something wrong. It just shows an empty plot with x and y range of -0.5 - 0.5. However, doing print(table[0]) does show right data. Somehow, plt.plot(table[0]) and later plt.plot(table[2]) seems to work.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2018:00:09/07/18', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><pandas><pivot-table><python-3.5>', 'Title': 'selecting a column from pandas pivot table', 'ViewCount': 9797, 'id': 52221761, 'user_AboutMe': None, 'user_AccountId': 12881365.0, 'user_DisplayName': 'HT121', 'user_Reputation': 421.0, 'user_Views': 47.0, 'user_id': 9316299.0}}