| 255 | |
| 256 | |
| 257 | def test_table_dataframe(pd): |
| 258 | # Test if Pandas Data Frame can be passed in cellText |
| 259 | |
| 260 | data = { |
| 261 | 'Letter': ['A', 'B', 'C'], |
| 262 | 'Number': [100, 200, 300] |
| 263 | } |
| 264 | |
| 265 | df = pd.DataFrame(data) |
| 266 | fig, ax = plt.subplots() |
| 267 | table = ax.table(df, loc='center') |
| 268 | |
| 269 | for r, (index, row) in enumerate(df.iterrows()): |
| 270 | for c, col in enumerate(df.columns if r == 0 else row.values): |
| 271 | assert table[r if r == 0 else r+1, c].get_text().get_text() == str(col) |
| 272 | |
| 273 | |
| 274 | def test_table_fontsize(): |