Sep-09-2020, 02:22 PM
I concated two Dataframes (df1,df2) then return the max values in each cluster,
+----+-----------+----------+------------+
|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 !!!!
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 !!!!