This is the <class 'pandas.core.frame.DataFrame'> from my csv file. This is because i want to group all Header A that has "happy" value in Header C
print(df.loc[df["Header C"] == "happy"])
and this is the output:
Header A Header B Header C Header D Header E
0 rowa.a rowa.c happy rowa.d rowa.e
3 rowc.a rowc.c happy rowd.d rowc.e
5 rowe.a rowe.c happy rowe.d rowe.e
Is there any way i can make the the output Header's into a list and store it in a variable ?
same with the rows, i also want it to make a list and store it in a variable.
(like this):
a = ["Header A", "Header B", "Header C", "Header D", "Header E"]
n = ["rowa.a", "rowa.c", "happy", "rowa.d", "rowa.e"]
o = ["rowc.a", "rowc.c", "happy", "rowc.d", "rowc.e"]
What i want to be as a final output is a prettytable
from prettytable import PrettyTable
x = PrettyTable()
x.field_names = a
x.add_row(n)
x.add_row(o)
print(x)
and an output of this:
+----------+----------+----------+----------+----------+
| Header A | Header B | Header C | Header D | Header E |
+----------+----------+----------+----------+----------+
| rowa.a | rowa.c | happy | rowa.d | rowa.e |
+----------+----------+----------+----------+----------+
Thank you very much!