La street
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # **Compte Rendu TP AA** ![](https://sgen-cfdt.fr/contenu/uploads/sites/21/2020/04/logo-UCA.jpg =140x140) _Mazzini Kélian_ _Marquet Thomas_ _Goncalves Lucas_ _Auriol Antoine_ Ce compte rendu a été réalisé à partir des certifications disponibles sur le site [Kaggle](https://www.kaggle.com/) ## **Pandas** ### **Creating, Reading and Writing** On a vu qu'on peut importer la librairie pandas: ```python= import pandas as pd ``` Créer des data frames sous forme de tableaux: ```python= pd.DataFrames({'column1Name' : [data1, data2,...], ...}, index=['line1Name',...]) ``` Créer des séries: ```python= pd.Series([data1, data2,...], index=[name1, name2,...]) ``` Lire des fichiers csv: ```python= reviews = pd.read_csv("filepath") ``` Exporter sur des fichiers csv: ```python= reviews.to_csv("filename.csv") ``` ### **Indexing, Selecting & Assigning** On a vu qu'on peut faires des requêtes selon certaines contraintes notamment à l'aide d'un indice dans la table: ```python= reviews.iloc[...] reviews.loc[0:n] reviews.loc[[0,1,2,...,n]] ``` ou alors a l'aide de conditions que l'on peut combiner avec des & et |: ```python= reviews.loc[(reviews.country.isin['data1', 'data2',...])] ``` on avait alors des resultats du type : | | country | points | price | ... | |--------|---------|--------|-------|-----| | 129966 | Germany | 90 | 28 | ... | | 129967 | US | 90 | 75 | ... | | ... | ... | ... | ... | ... | ### **Summary Functions and Maps** On a vu comment récuperer les données pour effectuer les calculs voulu (exemple compter le nombre de villes différentes/calcul de moyennes/de maximum...) à l'aide de fonctions et de maps ```python= reviews.points.mean() reviews.points.map(lambda p : p - reviews.points.mean()) ``` ### **Grouping and Sorting** On peut regrouper dans un dataframe/une serie des données en fonction d'un paramètre pour ensuite en tirer des informations tel que le nombre, le minimum etc... ```python= reviews.groupby('parametre').size() reviews.groupby('parametre').price.min() ``` on peut y ajouter un tri des valeures de sorties par ordre ascendant, descendant ```python= reviews.groupby('variety').price.agg([min,max]).sort_values(by=['min', 'max'] ascending=False) ``` ### **Data Types and Missing Values** On peut connaître le type de données renvoyé par une requête, on peut modifier ce dernier, on peut savoir pour combiens de données, nous n'avons pas d'informations et combler ce vide d'informations avec par exemple une chaine de caractère pour dire que cette information est inconnue. ```python= reviews.points.dtype reviews.points.astype('type') reviews.price.isnull().sum() reviews.region_1.fillna("Unknown").value_count().sort_values(ascending=False) ``` ### **Renaming and Combining** On peut changer le nom des index ou des colonnes spécifiés à l'aide de la fonction rename(). ```python= reviews.rename(columns={'points': 'score'}) reviews.rename(index={0: 'firstEntry', 1: 'secondEntry'}) ``` La méthode complémentaire rename_axis() permet aussi de changer les noms des colonnes ou de lignes ```python= reviews.rename_axis("wines", axis='rows').rename_axis("fields", axis='columns') ``` Parfois nous avons besoin de fusionner des dataframes afin d'effectuer des opérations sur un ensemble de données ```python= canadian_youtube = pd.read_csv("../input/youtube-new/CAvideos.csv") british_youtube = pd.read_csv("../input/youtube-new/GBvideos.csv") pd.concat([canadian_youtube, british_youtube]) ``` ```python= left = canadian_youtube.set_index(['title', 'trending_date']) right = british_youtube.set_index(['title', 'trending_date']) left.join(right, lsuffix='_CAN', rsuffix='_UK') ``` ## **Data Visualization** ### **Hello, Seaborn** Seaborn est un outil qui permet d'obtenir différentes visualisations des données d'un dataset. On peut charger les données avec une commande vu plus tôt dans le tutoriel de pandas puis utiliser les bibliothèques matplotlib et seaborn pour représenter ces données: ```python= plt.figure(figsize=(width,height)) sns.lineplot(data=fifa_data) ``` ### **Line Charts** On peut analyser uniquement le début ou la fin des données avec les fonctions head() et tail(), on peut également montrer ces données avec un affichage graphique en définissant avec plt.figure() la taille de l'affichage, et avec plt.title() le titre puis avec la précédente commande sns.lineplot, les afficher ### **Bar Charts and Heatmaps** On apprend deux nouvelles visualisation des données , le diagramme en batons et la heatmap ```python= sns.barplot(x=flight_data.index, y=flight_data['NK']) ``` ```python= sns.heatmap(data=flight_data, annot=True) ``` ### **Scatter Plots** On peut visualiser sous forme de nuages de points les données, avec des droites de regressions et/ou de la couleur: ```python= sns.scatterplot(x=candy_data['sugarpercent'], =candy_data['winpercent']) ``` ```python= sns.regplot(x=candy_data['sugarpercent'], y=candy_data['winpercent']) ``` ```python= sns.lmplot(x="pricepercent", y="winpercent", hue="chocolate", data=candy_data) ``` ```python= sns.swarmplot(x="chocolate", y="winpercent", data=candy_data) ``` ### **Distributions** On a vu d'autres fonctions de visualisations de données. ```python= sns.displot(a=cancer_b_data['Area (mean)']) ``` ```python= sns.kdeplot(data=cancer_b_data['Radius (worst)'], shade=True) ``` ### **Choosing Plot Types and Custom Styles** On a vu qu'en fonctions des données qu'on a, on peut choisir parmis toutes les différentes représentations possibles vus précédemment. On a également vu différents moyens de personnaliser les figures, notamment la taille et les couleurs. ### **Final Project** Pour le projet final, on utilise un dataset sur les espèces d'iris, on cherches donc à afficher les données, pour cela, on execute le code suivant: ```python= my_filepath = "../input/iris/Iris.csv" my_data = pd.read_csv(my_filepath) my_data.head() sns.barplot(x=my_data.index, y=my_data['SepalLengthCm']) ``` ## **Data Cleaning** ### **Handling Missing Values** On a revu les méthodes pour detecter et manipuler des données manquantes dans un dataset: ```python= percent_missing = (sf_permits.isnull().sum().sum()/np.product(sf_permits.shape))*100 sf_permits_with_na_dropped = sf_permits.dropna(axis=1) dropped_columns = (sf_permits.shape[1])-(sf_permits_with_na_dropped.shape[1]) sf_permits_with_na_imputed = sf_permits.fillna(method='bfill', axis=0).fillna(0) ``` ### **Scaling and Normalization** On a vu que l'on peut modifier l'echelle des données afin d'avoir un affichage de ces dernière plus clair et précis grâce a la fonction minmax_scaling() ```python= original_goal_data = pd.DataFrame(kickstarters_2017.goal) scaled_goal_data = minmax_scaling(original_goal_data, columns=['goal']) ``` ### **Parsing Dates** On a vu que l'on peut convertir des colonne de dates en Datetime au format voulu : ```python= earthquakes.loc[3378, "Date"] = "02/23/1975" earthquakes.loc[7512, "Date"] = "04/28/1985" earthquakes.loc[20650, "Date"] = "03/13/2011" earthquakes['date_parsed'] = pd.to_datetime(earthquakes['Date'], format="%m/%d/%Y") ``` On peut également selectionner le jour du mois d'une date: ```python= day_of_month_landslides = landslides['date_parsed'].dt.day ``` ### **Character Encodings** On peut décoder et encoder à different format de caractères: ```python= before = "This is the euro symbol: €" after = before.encode("utf-8", errors="replace") print(after.decode("utf-8")) ``` On peut également le faire sur des fichiers qu'on lit ou que l'on créé. ### **Inconsistant Data Entry** On a vu que l'on peut selectionner la liste des valeurs sans répétitions pour certaines colonnes d'un dataset: ```python= countries = professors['Country'].unique() ``` On peut également modifier la casse des chaînes de caractères ainsi que supprimer les espaces: ```python= professors['Country'] = professors['Country'].str.lower() professors['Country'] = professors['Country'].str.strip() ``` On a vu le package fuzzywuzzy qui permet de detecter les erreurs dans les données en faisant un ratio de ressemblance entre des chaines de caractères par rapport à une chaine donnée en paramètres: ```python= matches = fuzzywuzzy.process.extract("south korea", countries, limit=10, scorer=fuzzywuzzy.fuzz.token_sort_ratio) ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully