Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a pandas table

Tags:

python

pandas

enter image description here

In using pandas, how can I display a table similar to this one.

I think I have to use a dataframe similar to df = pandas.DataFrame(results) and display it with display.display(df) but from there I don't know what to do?

like image 216
David Avatar asked Sep 08 '26 19:09

David


2 Answers

You can pass in a dictionary as data when you use pd.DataFrame:

>>> import pandas as pd
>>> d = {
...     'Algothime': ['KNN', 'SVM', 'MLP'],
...     'Param. 1': ['-', '-', '-'],
...     'Param. 2': ['-', '-', '-'],
...     'Plage param. 1': ['-', '-', '-'],
...     'Plage param. 2': ['-', '-', '-'],
... }
>>> df = pd.DataFrame(data=d)
>>> df
  Algothime Param. 1 Param. 2 Plage param. 1 Plage param. 2
0       KNN        -        -              -              -
1       SVM        -        -              -              -
2       MLP        -        -              -              -

If you want that specific style you can use Google Colab or something similar if you don't have Jupyter installed locally: Colab Example

like image 200
Sash Sinha Avatar answered Sep 10 '26 10:09

Sash Sinha


I recommend looking at this 10 min tutorial.

To answer your question

df = pd.DataFrame(columns=['Algotihme', 'Param. 1', 'Param. 2', 'Plage Param. 1', 'Plage Param. 2' ])
df['Algotihme'] = ['KNN', 'SVM', 'MLP']
df

To display the dataframe simply put 'df' in an empty cell in Jupyter Notebook and run it

like image 26
Oddaspa Avatar answered Sep 10 '26 10:09

Oddaspa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!