Python Forum
display the result of Dataframe in tabulate format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
display the result of Dataframe in tabulate format
#1
I concated two Dataframes (df1,df2) then return the max values in each cluster,

dff=pd.concat([df1,df2]).drop_duplicates(['cluster','accuercy '],keep='last').sort_values('cluster')

dfs22=dff.groupby(['cluster'], sort=False)['accuercy'].max()
the Dataframe (dff) look like this

+----+-----------+----------+------------+
|cluster | device | accuercy
|----+-----------+----------+------------|
| 0 | 0 | 0.80 |
| 1 | 1 | 0.85 |
| 1 | 2 | 0.81 |
| 1 | 3 | 0.83 |
| 2 | 4 | 0.84 |
| 2 | 5 | 0.83 |
| 0 | 6 | 0.84 |
| 0 | 7 | 0.83 |
| 0 | 8 | 0.81 |
| 0 | 9 | 0.85 |
+----+-----------+----------+------------+
How can I display the result of a dfs22 in tabulate?

+----+-----------+----------+------------+
|cluster | device | accuercy
|----+-----------+----------+---- -------|
| 1 | 1 | 0.85 |
| 2 | 4 | 0.84 |
| 0 | 9 | 0.85 |
+----+-----------+----------+--------- --+
I tried using the following code

print(tabulate(dfs2, headers='keys', tablefmt='psql'))
but idosent work !!!!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to insert Dashed Lines in between Rows of a tabulate output Mudassir1987 0 488 Sep-27-2023, 10:09 AM
Last Post: Mudassir1987
  How to display <IPython.core.display.HTML object>? pythopen 3 45,890 May-06-2023, 08:14 AM
Last Post: pramod08728
  pandas, tabulate, and alignment menator01 3 7,231 Feb-05-2022, 07:04 AM
Last Post: menator01
  dataframe cell conditional format by row SriRajesh 0 1,754 Apr-24-2021, 11:51 AM
Last Post: SriRajesh
Information Unable to display joystick's value from Python onto display box MelfoyGray 2 2,219 Nov-11-2020, 02:23 AM
Last Post: MelfoyGray
  How to tabulate correctly repeated blocks? Xiesxes 4 2,924 Mar-21-2020, 04:57 PM
Last Post: Xiesxes
  Display output in readable format and save hnkrish 1 2,618 Jul-19-2019, 09:29 AM
Last Post: Larz60+
  Trying to Tabulate Information from an Aircraft Website Link(s) eddywinch82 35 13,470 Jun-25-2019, 09:40 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020