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?
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?
You can pass in a dictionary for the data when you create the 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:

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
In an interactive environment, you can always display a Pandas dataframe (or any other Python object) just by typing its name as its own command, e.g., type df on its own line.
However, the appearance of the table will differ depending on the environment you are using. Pandas has two ways of showing tables: plain text and HTML. The one you showed in your question is the HTML version.
If you use Python in an ordinary text terminal, you will get the plain text version. The easiest way to see the HTML version is by using one of these:
If you are using one of these, whenever you display a dataframe (type df on its own line), you will automatically see the HTML version. If you use the same command in a plain-text terminal, you will get the plain-text version.
UPDATE. As an example using Google Colab:
import pandas as pd
d = {
'Algorithme': ['KNN', 'SVM','MLP'],
'Param. 1': ['-', '-', '-'],
'Param. 2': ['-', '-', '-'],
'Plage param. 1': ['-', '-', '-'],
'Plage param. 2': ['-', '-', '-']
}
df = pd.DataFrame(data=d)
df
df in its own cell and run that later to see the dataframe again.You can try this:
import pandas as pd
df = pd.DataFrame([('KNN', '-', '-', '-', '-'),
('SVM', '-', '-', '-', '-'),
('gold', '-', '-', '-', '-')],
columns=('Algotihme', 'Param. 1', 'Param. 2', 'Plage Param. 1', 'Plage Param. 2' ))