Affichage des resultats dans Jupyter
%%html
<style>
h1 {border: 1.5px solid #000;
padding: 10px;
background-image: linear-gradient(180deg, #fff, #aaa);}
</style>
import pandas as pd
import seaborn as sns
from IPython.display import HTML
dtf = sns.load_dataset("penguins")
dtf1 = dtf.copy()
dtf1.columns = dtf.columns + "1"
dtf2 = dtf.copy()
dtf2.columns = dtf.columns + "2"
manchots = pd.concat([dtf, dtf1,dtf2], axis=1)[:70]
manchots
species | island | bill_length_mm | bill_depth_mm | flipper_length_mm | body_mass_g | sex | species1 | island1 | bill_length_mm1 | ... | flipper_length_mm1 | body_mass_g1 | sex1 | species2 | island2 | bill_length_mm2 | bill_depth_mm2 | flipper_length_mm2 | body_mass_g2 | sex2 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | Adelie | Torgersen | 39.1 | 18.7 | 181.0 | 3750.0 | Male | Adelie | Torgersen | 39.1 | ... | 181.0 | 3750.0 | Male | Adelie | Torgersen | 39.1 | 18.7 | 181.0 | 3750.0 | Male |
1 | Adelie | Torgersen | 39.5 | 17.4 | 186.0 | 3800.0 | Female | Adelie | Torgersen | 39.5 | ... | 186.0 | 3800.0 | Female | Adelie | Torgersen | 39.5 | 17.4 | 186.0 | 3800.0 | Female |
2 | Adelie | Torgersen | 40.3 | 18.0 | 195.0 | 3250.0 | Female | Adelie | Torgersen | 40.3 | ... | 195.0 | 3250.0 | Female | Adelie | Torgersen | 40.3 | 18.0 | 195.0 | 3250.0 | Female |
3 | Adelie | Torgersen | NaN | NaN | NaN | NaN | NaN | Adelie | Torgersen | NaN | ... | NaN | NaN | NaN | Adelie | Torgersen | NaN | NaN | NaN | NaN | NaN |
4 | Adelie | Torgersen | 36.7 | 19.3 | 193.0 | 3450.0 | Female | Adelie | Torgersen | 36.7 | ... | 193.0 | 3450.0 | Female | Adelie | Torgersen | 36.7 | 19.3 | 193.0 | 3450.0 | Female |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
65 | Adelie | Biscoe | 41.6 | 18.0 | 192.0 | 3950.0 | Male | Adelie | Biscoe | 41.6 | ... | 192.0 | 3950.0 | Male | Adelie | Biscoe | 41.6 | 18.0 | 192.0 | 3950.0 | Male |
66 | Adelie | Biscoe | 35.5 | 16.2 | 195.0 | 3350.0 | Female | Adelie | Biscoe | 35.5 | ... | 195.0 | 3350.0 | Female | Adelie | Biscoe | 35.5 | 16.2 | 195.0 | 3350.0 | Female |
67 | Adelie | Biscoe | 41.1 | 19.1 | 188.0 | 4100.0 | Male | Adelie | Biscoe | 41.1 | ... | 188.0 | 4100.0 | Male | Adelie | Biscoe | 41.1 | 19.1 | 188.0 | 4100.0 | Male |
68 | Adelie | Torgersen | 35.9 | 16.6 | 190.0 | 3050.0 | Female | Adelie | Torgersen | 35.9 | ... | 190.0 | 3050.0 | Female | Adelie | Torgersen | 35.9 | 16.6 | 190.0 | 3050.0 | Female |
69 | Adelie | Torgersen | 41.8 | 19.4 | 198.0 | 4450.0 | Male | Adelie | Torgersen | 41.8 | ... | 198.0 | 4450.0 | Male | Adelie | Torgersen | 41.8 | 19.4 | 198.0 | 4450.0 | Male |
70 rows × 21 columns
Le module pandas a vite tendance a tronque les lignes et les colonnes d'un dataframe. On peut le forcer a afficher l'integralite des donnees comme suit.
with pd.option_context("display.max_columns", None, "display.max_rows", None):
display(manchots)
species | island | bill_length_mm | bill_depth_mm | flipper_length_mm | body_mass_g | sex | species1 | island1 | bill_length_mm1 | bill_depth_mm1 | flipper_length_mm1 | body_mass_g1 | sex1 | species2 | island2 | bill_length_mm2 | bill_depth_mm2 | flipper_length_mm2 | body_mass_g2 | sex2 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | Adelie | Torgersen | 39.1 | 18.7 | 181.0 | 3750.0 | Male | Adelie | Torgersen | 39.1 | 18.7 | 181.0 | 3750.0 | Male | Adelie | Torgersen | 39.1 | 18.7 | 181.0 | 3750.0 | Male |
1 | Adelie | Torgersen | 39.5 | 17.4 | 186.0 | 3800.0 | Female | Adelie | Torgersen | 39.5 | 17.4 | 186.0 | 3800.0 | Female | Adelie | Torgersen | 39.5 | 17.4 | 186.0 | 3800.0 | Female |
2 | Adelie | Torgersen | 40.3 | 18.0 | 195.0 | 3250.0 | Female | Adelie | Torgersen | 40.3 | 18.0 | 195.0 | 3250.0 | Female | Adelie | Torgersen | 40.3 | 18.0 | 195.0 | 3250.0 | Female |
3 | Adelie | Torgersen | NaN | NaN | NaN | NaN | NaN | Adelie | Torgersen | NaN | NaN | NaN | NaN | NaN | Adelie | Torgersen | NaN | NaN | NaN | NaN | NaN |
4 | Adelie | Torgersen | 36.7 | 19.3 | 193.0 | 3450.0 | Female | Adelie | Torgersen | 36.7 | 19.3 | 193.0 | 3450.0 | Female | Adelie | Torgersen | 36.7 | 19.3 | 193.0 | 3450.0 | Female |
5 | Adelie | Torgersen | 39.3 | 20.6 | 190.0 | 3650.0 | Male | Adelie | Torgersen | 39.3 | 20.6 | 190.0 | 3650.0 | Male | Adelie | Torgersen | 39.3 | 20.6 | 190.0 | 3650.0 | Male |
6 | Adelie | Torgersen | 38.9 | 17.8 | 181.0 | 3625.0 | Female | Adelie | Torgersen | 38.9 | 17.8 | 181.0 | 3625.0 | Female | Adelie | Torgersen | 38.9 | 17.8 | 181.0 | 3625.0 | Female |
7 | Adelie | Torgersen | 39.2 | 19.6 | 195.0 | 4675.0 | Male | Adelie | Torgersen | 39.2 | 19.6 | 195.0 | 4675.0 | Male | Adelie | Torgersen | 39.2 | 19.6 | 195.0 | 4675.0 | Male |
8 | Adelie | Torgersen | 34.1 | 18.1 | 193.0 | 3475.0 | NaN | Adelie | Torgersen | 34.1 | 18.1 | 193.0 | 3475.0 | NaN | Adelie | Torgersen | 34.1 | 18.1 | 193.0 | 3475.0 | NaN |
9 | Adelie | Torgersen | 42.0 | 20.2 | 190.0 | 4250.0 | NaN | Adelie | Torgersen | 42.0 | 20.2 | 190.0 | 4250.0 | NaN | Adelie | Torgersen | 42.0 | 20.2 | 190.0 | 4250.0 | NaN |
10 | Adelie | Torgersen | 37.8 | 17.1 | 186.0 | 3300.0 | NaN | Adelie | Torgersen | 37.8 | 17.1 | 186.0 | 3300.0 | NaN | Adelie | Torgersen | 37.8 | 17.1 | 186.0 | 3300.0 | NaN |
11 | Adelie | Torgersen | 37.8 | 17.3 | 180.0 | 3700.0 | NaN | Adelie | Torgersen | 37.8 | 17.3 | 180.0 | 3700.0 | NaN | Adelie | Torgersen | 37.8 | 17.3 | 180.0 | 3700.0 | NaN |
12 | Adelie | Torgersen | 41.1 | 17.6 | 182.0 | 3200.0 | Female | Adelie | Torgersen | 41.1 | 17.6 | 182.0 | 3200.0 | Female | Adelie | Torgersen | 41.1 | 17.6 | 182.0 | 3200.0 | Female |
13 | Adelie | Torgersen | 38.6 | 21.2 | 191.0 | 3800.0 | Male | Adelie | Torgersen | 38.6 | 21.2 | 191.0 | 3800.0 | Male | Adelie | Torgersen | 38.6 | 21.2 | 191.0 | 3800.0 | Male |
14 | Adelie | Torgersen | 34.6 | 21.1 | 198.0 | 4400.0 | Male | Adelie | Torgersen | 34.6 | 21.1 | 198.0 | 4400.0 | Male | Adelie | Torgersen | 34.6 | 21.1 | 198.0 | 4400.0 | Male |
15 | Adelie | Torgersen | 36.6 | 17.8 | 185.0 | 3700.0 | Female | Adelie | Torgersen | 36.6 | 17.8 | 185.0 | 3700.0 | Female | Adelie | Torgersen | 36.6 | 17.8 | 185.0 | 3700.0 | Female |
16 | Adelie | Torgersen | 38.7 | 19.0 | 195.0 | 3450.0 | Female | Adelie | Torgersen | 38.7 | 19.0 | 195.0 | 3450.0 | Female | Adelie | Torgersen | 38.7 | 19.0 | 195.0 | 3450.0 | Female |
17 | Adelie | Torgersen | 42.5 | 20.7 | 197.0 | 4500.0 | Male | Adelie | Torgersen | 42.5 | 20.7 | 197.0 | 4500.0 | Male | Adelie | Torgersen | 42.5 | 20.7 | 197.0 | 4500.0 | Male |
18 | Adelie | Torgersen | 34.4 | 18.4 | 184.0 | 3325.0 | Female | Adelie | Torgersen | 34.4 | 18.4 | 184.0 | 3325.0 | Female | Adelie | Torgersen | 34.4 | 18.4 | 184.0 | 3325.0 | Female |
19 | Adelie | Torgersen | 46.0 | 21.5 | 194.0 | 4200.0 | Male | Adelie | Torgersen | 46.0 | 21.5 | 194.0 | 4200.0 | Male | Adelie | Torgersen | 46.0 | 21.5 | 194.0 | 4200.0 | Male |
20 | Adelie | Biscoe | 37.8 | 18.3 | 174.0 | 3400.0 | Female | Adelie | Biscoe | 37.8 | 18.3 | 174.0 | 3400.0 | Female | Adelie | Biscoe | 37.8 | 18.3 | 174.0 | 3400.0 | Female |
21 | Adelie | Biscoe | 37.7 | 18.7 | 180.0 | 3600.0 | Male | Adelie | Biscoe | 37.7 | 18.7 | 180.0 | 3600.0 | Male | Adelie | Biscoe | 37.7 | 18.7 | 180.0 | 3600.0 | Male |
22 | Adelie | Biscoe | 35.9 | 19.2 | 189.0 | 3800.0 | Female | Adelie | Biscoe | 35.9 | 19.2 | 189.0 | 3800.0 | Female | Adelie | Biscoe | 35.9 | 19.2 | 189.0 | 3800.0 | Female |
23 | Adelie | Biscoe | 38.2 | 18.1 | 185.0 | 3950.0 | Male | Adelie | Biscoe | 38.2 | 18.1 | 185.0 | 3950.0 | Male | Adelie | Biscoe | 38.2 | 18.1 | 185.0 | 3950.0 | Male |
24 | Adelie | Biscoe | 38.8 | 17.2 | 180.0 | 3800.0 | Male | Adelie | Biscoe | 38.8 | 17.2 | 180.0 | 3800.0 | Male | Adelie | Biscoe | 38.8 | 17.2 | 180.0 | 3800.0 | Male |
25 | Adelie | Biscoe | 35.3 | 18.9 | 187.0 | 3800.0 | Female | Adelie | Biscoe | 35.3 | 18.9 | 187.0 | 3800.0 | Female | Adelie | Biscoe | 35.3 | 18.9 | 187.0 | 3800.0 | Female |
26 | Adelie | Biscoe | 40.6 | 18.6 | 183.0 | 3550.0 | Male | Adelie | Biscoe | 40.6 | 18.6 | 183.0 | 3550.0 | Male | Adelie | Biscoe | 40.6 | 18.6 | 183.0 | 3550.0 | Male |
27 | Adelie | Biscoe | 40.5 | 17.9 | 187.0 | 3200.0 | Female | Adelie | Biscoe | 40.5 | 17.9 | 187.0 | 3200.0 | Female | Adelie | Biscoe | 40.5 | 17.9 | 187.0 | 3200.0 | Female |
28 | Adelie | Biscoe | 37.9 | 18.6 | 172.0 | 3150.0 | Female | Adelie | Biscoe | 37.9 | 18.6 | 172.0 | 3150.0 | Female | Adelie | Biscoe | 37.9 | 18.6 | 172.0 | 3150.0 | Female |
29 | Adelie | Biscoe | 40.5 | 18.9 | 180.0 | 3950.0 | Male | Adelie | Biscoe | 40.5 | 18.9 | 180.0 | 3950.0 | Male | Adelie | Biscoe | 40.5 | 18.9 | 180.0 | 3950.0 | Male |
30 | Adelie | Dream | 39.5 | 16.7 | 178.0 | 3250.0 | Female | Adelie | Dream | 39.5 | 16.7 | 178.0 | 3250.0 | Female | Adelie | Dream | 39.5 | 16.7 | 178.0 | 3250.0 | Female |
31 | Adelie | Dream | 37.2 | 18.1 | 178.0 | 3900.0 | Male | Adelie | Dream | 37.2 | 18.1 | 178.0 | 3900.0 | Male | Adelie | Dream | 37.2 | 18.1 | 178.0 | 3900.0 | Male |
32 | Adelie | Dream | 39.5 | 17.8 | 188.0 | 3300.0 | Female | Adelie | Dream | 39.5 | 17.8 | 188.0 | 3300.0 | Female | Adelie | Dream | 39.5 | 17.8 | 188.0 | 3300.0 | Female |
33 | Adelie | Dream | 40.9 | 18.9 | 184.0 | 3900.0 | Male | Adelie | Dream | 40.9 | 18.9 | 184.0 | 3900.0 | Male | Adelie | Dream | 40.9 | 18.9 | 184.0 | 3900.0 | Male |
34 | Adelie | Dream | 36.4 | 17.0 | 195.0 | 3325.0 | Female | Adelie | Dream | 36.4 | 17.0 | 195.0 | 3325.0 | Female | Adelie | Dream | 36.4 | 17.0 | 195.0 | 3325.0 | Female |
35 | Adelie | Dream | 39.2 | 21.1 | 196.0 | 4150.0 | Male | Adelie | Dream | 39.2 | 21.1 | 196.0 | 4150.0 | Male | Adelie | Dream | 39.2 | 21.1 | 196.0 | 4150.0 | Male |
36 | Adelie | Dream | 38.8 | 20.0 | 190.0 | 3950.0 | Male | Adelie | Dream | 38.8 | 20.0 | 190.0 | 3950.0 | Male | Adelie | Dream | 38.8 | 20.0 | 190.0 | 3950.0 | Male |
37 | Adelie | Dream | 42.2 | 18.5 | 180.0 | 3550.0 | Female | Adelie | Dream | 42.2 | 18.5 | 180.0 | 3550.0 | Female | Adelie | Dream | 42.2 | 18.5 | 180.0 | 3550.0 | Female |
38 | Adelie | Dream | 37.6 | 19.3 | 181.0 | 3300.0 | Female | Adelie | Dream | 37.6 | 19.3 | 181.0 | 3300.0 | Female | Adelie | Dream | 37.6 | 19.3 | 181.0 | 3300.0 | Female |
39 | Adelie | Dream | 39.8 | 19.1 | 184.0 | 4650.0 | Male | Adelie | Dream | 39.8 | 19.1 | 184.0 | 4650.0 | Male | Adelie | Dream | 39.8 | 19.1 | 184.0 | 4650.0 | Male |
40 | Adelie | Dream | 36.5 | 18.0 | 182.0 | 3150.0 | Female | Adelie | Dream | 36.5 | 18.0 | 182.0 | 3150.0 | Female | Adelie | Dream | 36.5 | 18.0 | 182.0 | 3150.0 | Female |
41 | Adelie | Dream | 40.8 | 18.4 | 195.0 | 3900.0 | Male | Adelie | Dream | 40.8 | 18.4 | 195.0 | 3900.0 | Male | Adelie | Dream | 40.8 | 18.4 | 195.0 | 3900.0 | Male |
42 | Adelie | Dream | 36.0 | 18.5 | 186.0 | 3100.0 | Female | Adelie | Dream | 36.0 | 18.5 | 186.0 | 3100.0 | Female | Adelie | Dream | 36.0 | 18.5 | 186.0 | 3100.0 | Female |
43 | Adelie | Dream | 44.1 | 19.7 | 196.0 | 4400.0 | Male | Adelie | Dream | 44.1 | 19.7 | 196.0 | 4400.0 | Male | Adelie | Dream | 44.1 | 19.7 | 196.0 | 4400.0 | Male |
44 | Adelie | Dream | 37.0 | 16.9 | 185.0 | 3000.0 | Female | Adelie | Dream | 37.0 | 16.9 | 185.0 | 3000.0 | Female | Adelie | Dream | 37.0 | 16.9 | 185.0 | 3000.0 | Female |
45 | Adelie | Dream | 39.6 | 18.8 | 190.0 | 4600.0 | Male | Adelie | Dream | 39.6 | 18.8 | 190.0 | 4600.0 | Male | Adelie | Dream | 39.6 | 18.8 | 190.0 | 4600.0 | Male |
46 | Adelie | Dream | 41.1 | 19.0 | 182.0 | 3425.0 | Male | Adelie | Dream | 41.1 | 19.0 | 182.0 | 3425.0 | Male | Adelie | Dream | 41.1 | 19.0 | 182.0 | 3425.0 | Male |
47 | Adelie | Dream | 37.5 | 18.9 | 179.0 | 2975.0 | NaN | Adelie | Dream | 37.5 | 18.9 | 179.0 | 2975.0 | NaN | Adelie | Dream | 37.5 | 18.9 | 179.0 | 2975.0 | NaN |
48 | Adelie | Dream | 36.0 | 17.9 | 190.0 | 3450.0 | Female | Adelie | Dream | 36.0 | 17.9 | 190.0 | 3450.0 | Female | Adelie | Dream | 36.0 | 17.9 | 190.0 | 3450.0 | Female |
49 | Adelie | Dream | 42.3 | 21.2 | 191.0 | 4150.0 | Male | Adelie | Dream | 42.3 | 21.2 | 191.0 | 4150.0 | Male | Adelie | Dream | 42.3 | 21.2 | 191.0 | 4150.0 | Male |
50 | Adelie | Biscoe | 39.6 | 17.7 | 186.0 | 3500.0 | Female | Adelie | Biscoe | 39.6 | 17.7 | 186.0 | 3500.0 | Female | Adelie | Biscoe | 39.6 | 17.7 | 186.0 | 3500.0 | Female |
51 | Adelie | Biscoe | 40.1 | 18.9 | 188.0 | 4300.0 | Male | Adelie | Biscoe | 40.1 | 18.9 | 188.0 | 4300.0 | Male | Adelie | Biscoe | 40.1 | 18.9 | 188.0 | 4300.0 | Male |
52 | Adelie | Biscoe | 35.0 | 17.9 | 190.0 | 3450.0 | Female | Adelie | Biscoe | 35.0 | 17.9 | 190.0 | 3450.0 | Female | Adelie | Biscoe | 35.0 | 17.9 | 190.0 | 3450.0 | Female |
53 | Adelie | Biscoe | 42.0 | 19.5 | 200.0 | 4050.0 | Male | Adelie | Biscoe | 42.0 | 19.5 | 200.0 | 4050.0 | Male | Adelie | Biscoe | 42.0 | 19.5 | 200.0 | 4050.0 | Male |
54 | Adelie | Biscoe | 34.5 | 18.1 | 187.0 | 2900.0 | Female | Adelie | Biscoe | 34.5 | 18.1 | 187.0 | 2900.0 | Female | Adelie | Biscoe | 34.5 | 18.1 | 187.0 | 2900.0 | Female |
55 | Adelie | Biscoe | 41.4 | 18.6 | 191.0 | 3700.0 | Male | Adelie | Biscoe | 41.4 | 18.6 | 191.0 | 3700.0 | Male | Adelie | Biscoe | 41.4 | 18.6 | 191.0 | 3700.0 | Male |
56 | Adelie | Biscoe | 39.0 | 17.5 | 186.0 | 3550.0 | Female | Adelie | Biscoe | 39.0 | 17.5 | 186.0 | 3550.0 | Female | Adelie | Biscoe | 39.0 | 17.5 | 186.0 | 3550.0 | Female |
57 | Adelie | Biscoe | 40.6 | 18.8 | 193.0 | 3800.0 | Male | Adelie | Biscoe | 40.6 | 18.8 | 193.0 | 3800.0 | Male | Adelie | Biscoe | 40.6 | 18.8 | 193.0 | 3800.0 | Male |
58 | Adelie | Biscoe | 36.5 | 16.6 | 181.0 | 2850.0 | Female | Adelie | Biscoe | 36.5 | 16.6 | 181.0 | 2850.0 | Female | Adelie | Biscoe | 36.5 | 16.6 | 181.0 | 2850.0 | Female |
59 | Adelie | Biscoe | 37.6 | 19.1 | 194.0 | 3750.0 | Male | Adelie | Biscoe | 37.6 | 19.1 | 194.0 | 3750.0 | Male | Adelie | Biscoe | 37.6 | 19.1 | 194.0 | 3750.0 | Male |
60 | Adelie | Biscoe | 35.7 | 16.9 | 185.0 | 3150.0 | Female | Adelie | Biscoe | 35.7 | 16.9 | 185.0 | 3150.0 | Female | Adelie | Biscoe | 35.7 | 16.9 | 185.0 | 3150.0 | Female |
61 | Adelie | Biscoe | 41.3 | 21.1 | 195.0 | 4400.0 | Male | Adelie | Biscoe | 41.3 | 21.1 | 195.0 | 4400.0 | Male | Adelie | Biscoe | 41.3 | 21.1 | 195.0 | 4400.0 | Male |
62 | Adelie | Biscoe | 37.6 | 17.0 | 185.0 | 3600.0 | Female | Adelie | Biscoe | 37.6 | 17.0 | 185.0 | 3600.0 | Female | Adelie | Biscoe | 37.6 | 17.0 | 185.0 | 3600.0 | Female |
63 | Adelie | Biscoe | 41.1 | 18.2 | 192.0 | 4050.0 | Male | Adelie | Biscoe | 41.1 | 18.2 | 192.0 | 4050.0 | Male | Adelie | Biscoe | 41.1 | 18.2 | 192.0 | 4050.0 | Male |
64 | Adelie | Biscoe | 36.4 | 17.1 | 184.0 | 2850.0 | Female | Adelie | Biscoe | 36.4 | 17.1 | 184.0 | 2850.0 | Female | Adelie | Biscoe | 36.4 | 17.1 | 184.0 | 2850.0 | Female |
65 | Adelie | Biscoe | 41.6 | 18.0 | 192.0 | 3950.0 | Male | Adelie | Biscoe | 41.6 | 18.0 | 192.0 | 3950.0 | Male | Adelie | Biscoe | 41.6 | 18.0 | 192.0 | 3950.0 | Male |
66 | Adelie | Biscoe | 35.5 | 16.2 | 195.0 | 3350.0 | Female | Adelie | Biscoe | 35.5 | 16.2 | 195.0 | 3350.0 | Female | Adelie | Biscoe | 35.5 | 16.2 | 195.0 | 3350.0 | Female |
67 | Adelie | Biscoe | 41.1 | 19.1 | 188.0 | 4100.0 | Male | Adelie | Biscoe | 41.1 | 19.1 | 188.0 | 4100.0 | Male | Adelie | Biscoe | 41.1 | 19.1 | 188.0 | 4100.0 | Male |
68 | Adelie | Torgersen | 35.9 | 16.6 | 190.0 | 3050.0 | Female | Adelie | Torgersen | 35.9 | 16.6 | 190.0 | 3050.0 | Female | Adelie | Torgersen | 35.9 | 16.6 | 190.0 | 3050.0 | Female |
69 | Adelie | Torgersen | 41.8 | 19.4 | 198.0 | 4450.0 | Male | Adelie | Torgersen | 41.8 | 19.4 | 198.0 | 4450.0 | Male | Adelie | Torgersen | 41.8 | 19.4 | 198.0 | 4450.0 | Male |
Une cellule Jupyter ne peut afficher qu'un seul resultat, ou alors on obtient quelque chose de laid.
dtf1 = pd.DataFrame({"col1":range(3), "col2":[True, False, True]})
dtf2 = pd.DataFrame({"col3":range(4), "col4":[1.1,1.2,1.3,1.4], "col5":["A", "B", "C", "D"]})
phrase = "une phrase comme une autre"
dtf1
dtf2
col3 | col4 | col5 | |
---|---|---|---|
0 | 0 | 1.1 | A |
1 | 1 | 1.2 | B |
2 | 2 | 1.3 | C |
3 | 3 | 1.4 | D |
dtf1, dtf2
( col1 col2 0 0 True 1 1 False 2 2 True, col3 col4 col5 0 0 1.1 A 1 1 1.2 B 2 2 1.3 C 3 3 1.4 D)
print(dtf1)
print(dtf2)
col1 col2 0 0 True 1 1 False 2 2 True col3 col4 col5 0 0 1.1 A 1 1 1.2 B 2 2 1.3 C 3 3 1.4 D
Premiere solution : on utilise la fonction display dans la cellule voulue.
display(dtf1, phrase, dtf2)
col1 | col2 | |
---|---|---|
0 | 0 | True |
1 | 1 | False |
2 | 2 | True |
'une phrase comme une autre'
col3 | col4 | col5 | |
---|---|---|---|
0 | 0 | 1.1 | A |
1 | 1 | 1.2 | B |
2 | 2 | 1.3 | C |
3 | 3 | 1.4 | D |
On peut meme ajouter un peu de mise en forme html.
dtf1_style = dtf1.style.set_properties(color = 'red', subset= ['col2']
).bar(color = 'orange', subset='col1')
display(HTML("<p style='color:forestgreen;''><font size='3'>Premier dataframe</font></p>" +dtf1_style.to_html() + "<br>"))
display(HTML("<p style='color:blue;''><font size='3'>Second dataframe</font></p>" + dtf2.to_html()))
Premier dataframe
col1 | col2 | |
---|---|---|
0 | 0 | True |
1 | 1 | False |
2 | 2 | True |
Second dataframe
col3 | col4 | col5 | |
---|---|---|---|
0 | 0 | 1.1 | A |
1 | 1 | 1.2 | B |
2 | 2 | 1.3 | C |
3 | 3 | 1.4 | D |
Seconde solution : on modifie les sorties de toutes les cellules du notebook.
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
dtf1
phrase
dtf2
col1 | col2 | |
---|---|---|
0 | 0 | True |
1 | 1 | False |
2 | 2 | True |
'une phrase comme une autre'
col3 | col4 | col5 | |
---|---|---|---|
0 | 0 | 1.1 | A |
1 | 1 | 1.2 | B |
2 | 2 | 1.3 | C |
3 | 3 | 1.4 | D |
On peut preferer avoir des dataframes cote a cote plutot que les uns au-dessus des autres.
def cote_a_cote(liste_dtf):
html = '<div style="display:flex">'
for dtf in liste_dtf:
html = html + '<div style="margin-right: 40px">' + dtf.to_html() + '</div>'
html = html + '</div>'
display(HTML(html))
cote_a_cote([dtf1_style, dtf2])
col1 | col2 | |
---|---|---|
0 | 0 | True |
1 | 1 | False |
2 | 2 | True |
col3 | col4 | col5 | |
---|---|---|---|
0 | 0 | 1.1 | A |
1 | 1 | 1.2 | B |
2 | 2 | 1.3 | C |
3 | 3 | 1.4 | D |