I have this code:
from tabulate import tabulate
import pandas
df = pandas.DataFrame({'Col2' : ['Hello', 'How' , 'Are', 'You'],
'Col3' : ['Hi', 'I', 'am', 'fine']})
nice_table = tabulate(df, headers='keys', tablefmt='psql')
print(nice_table)
It prints this:
+----+--------+--------+
| | Col2 | Col3 |
|----+--------+--------|
| 0 | Hello | Hi |
| 1 | How | I |
| 2 | Are | am |
| 3 | You | fine |
+----+--------+--------+
Is there a way to access and print the content of a given cell of nice_table
?
No. Keep in mind that tabulate
's sole purpose is as mentioned in the documentation is to:
Pretty-print tabular data in Python
Moreover if you run type(nice_table)
you'll see that tabulate
returns a string
. Therefore for any operations other than pretty printing the dataframe you will have to work with df
.