Introduction à d'autres types de fichiers

Introduction à l'importation de données en Python

Hugo Bowne-Anderson

Data Scientist at DataCamp

Autres types de fichiers

  • Tableurs Excel
  • Fichiers MATLAB
  • Fichiers SAS
  • Fichiers Stata
  • Fichiers HDF5
Introduction à l'importation de données en Python

Fichiers Pickle

  • Type de fichier natif de Python
  • Motivation : nombreux types de données pour lesquels la méthode de stockage n'est pas évidente
  • Les fichiers Pickle sont sérialisés
  • Sérialiser = convertir un objet en flux d'octets
Introduction à l'importation de données en Python

Fichiers Pickle

import pickle
with open('pickled_fruit.pkl', 'rb') as file:
    data = pickle.load(file)    
print(data)
{'peaches': 13, 'apples': 4, 'oranges': 11}
Introduction à l'importation de données en Python

Importation de feuilles de calcul Excel

import pandas as pd
file = 'urbanpop.xlsx'
data = pd.ExcelFile(file)
print(data.sheet_names)
['1960-1966', '1967-1974', '1975-2011']
df1 = data.parse('1960-1966') # sheet name, as a string
df2 = data.parse(0) # sheet index, as a float
Introduction à l'importation de données en Python

Vous apprendrez :

  • Comment personnaliser votre importation
  • Ignorer des lignes
  • Importer certaines colonnes
  • Modifier les noms des colonnes
Introduction à l'importation de données en Python

Passons à la pratique !

Introduction à l'importation de données en Python

Preparing Video For Download...