Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révisionLes deux révisions suivantes | ||
teaching:progappchim:pandas [2019/03/10 10:12] – [Références] villersd | teaching:progappchim:pandas [2019/03/11 06:54] – villersd | ||
---|---|---|---|
Ligne 12: | Ligne 12: | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | |||
+ | ===== Applications, | ||
+ | |||
+ | ==== Statistiques sur les dimensions des humains (body dimensions) ==== | ||
+ | Programme basé sur [[http:// | ||
+ | |||
+ | Extensions : | ||
+ | * Tester et utiliser en mode " | ||
+ | * créer des régressions | ||
+ | * autres représentations | ||
+ | * différentiation suivant le genre, l'âge | ||
+ | * ... | ||
+ | |||
+ | <code python > | ||
+ | # | ||
+ | # -*- coding: utf-8 -*- | ||
+ | """ | ||
+ | Created on Tue Mar 5 04:13:51 2019 | ||
+ | Statistics on Body dimensions : | ||
+ | http:// | ||
+ | |||
+ | without requests lib, using pandas.read_csv | ||
+ | |||
+ | @author: Didier Villers | ||
+ | """ | ||
+ | import matplotlib.pyplot as plt | ||
+ | import numpy as np | ||
+ | import pandas as pd | ||
+ | |||
+ | # using this VARIABLE DESCRIPTIONS with PEP 8 Python style : | ||
+ | names = [ | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | 'Chest depth', | ||
+ | 'Chest diameter', | ||
+ | 'Elbow diameter', | ||
+ | 'Wrist diameter', | ||
+ | 'Knee diameter', | ||
+ | 'Ankle diameter', | ||
+ | ' | ||
+ | 'Chest girth', | ||
+ | 'Waist girth', | ||
+ | 'Navel girth', | ||
+ | 'Hip girth', | ||
+ | 'Thigh girth', | ||
+ | 'Bicep girth', | ||
+ | ' | ||
+ | 'Knee girth', | ||
+ | 'Calf maximum girth', | ||
+ | 'Ankle minimum girth', | ||
+ | 'Wrist minimum girth', | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ] | ||
+ | # using Pandas column names without white spaces | ||
+ | names = [name.replace(' | ||
+ | print(names) | ||
+ | |||
+ | namesfr = [ | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | 'Tour d’épaules', | ||
+ | 'Tour de poitrine', | ||
+ | 'Tour de taille', | ||
+ | 'Tour au niveau du nombril', | ||
+ | 'Tour de hanches', | ||
+ | 'Tour de cuisse', | ||
+ | 'Tour du biceps', | ||
+ | 'Tour de l’avant-bras', | ||
+ | 'Tour de genou', | ||
+ | 'Plus grande circonférence du mollet', | ||
+ | 'Plus petite circonférence de la cheville', | ||
+ | 'Plus petite circonférence du poignet', | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ] | ||
+ | |||
+ | dict_names_fr = dict(zip(names, | ||
+ | print(dict_names_fr) | ||
+ | |||
+ | file_url = " | ||
+ | #file_url = " | ||
+ | # using read_csv | ||
+ | # https:// | ||
+ | # https:// | ||
+ | |||
+ | df = pd.read_csv(file_url, | ||
+ | # | ||
+ | print(df) | ||
+ | |||
+ | # pandas misc | ||
+ | # https:// | ||
+ | # | ||
+ | print(df.columns) | ||
+ | print(df.Age) | ||
+ | print(df.dtypes) | ||
+ | print(df.describe()) | ||
+ | print(df[df.Gender == 1].describe()) | ||
+ | print(df[df.Age == 20].describe()) | ||
+ | print(df.sort_values(by = ' | ||
+ | |||
+ | print(df.query(' | ||
+ | print(df.query(' | ||
+ | |||
+ | plt.figure() | ||
+ | ax = df[df.Gender == 1].plot.scatter(x=' | ||
+ | df[df.Gender == 0].plot.scatter(x=' | ||
+ | |||
+ | plt.figure() | ||
+ | df.Height.plot.hist() | ||
+ | |||
+ | plt.figure() | ||
+ | df.Weight.plot.hist() | ||
+ | </ | ||
===== Références ===== | ===== Références ===== | ||
Ligne 24: | Ligne 150: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
Ligne 31: | Ligne 160: | ||
* [[http:// | * [[http:// | ||
* [[https:// | * [[https:// | ||
+ | * régressions linéaires : | ||
+ | * [[http:// | ||