Pengenalan tipe file lain

Pengantar Mengimpor Data di Python

Hugo Bowne-Anderson

Data Scientist at DataCamp

Tipe file lain

  • Spreadsheet Excel
  • File MATLAB
  • File SAS
  • File Stata
  • File HDF5
Pengantar Mengimpor Data di Python

File Pickle

  • Tipe file asli Python
  • Motivasi: banyak tipe data yang tidak jelas cara penyimpanannya
  • File pickle diserialisasi
  • Serialisasi = ubah objek jadi bytestream
Pengantar Mengimpor Data di Python

File Pickle

import pickle
with open('pickled_fruit.pkl', 'rb') as file:
    data = pickle.load(file)    
print(data)
{'peaches': 13, 'apples': 4, 'oranges': 11}
Pengantar Mengimpor Data di Python

Impor spreadsheet 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
Pengantar Mengimpor Data di Python

Anda akan mempelajari:

  • Cara menyesuaikan impor Anda
  • Lewati baris
  • Impor kolom tertentu
  • Ganti nama kolom
Pengantar Mengimpor Data di Python

Ayo berlatih!

Pengantar Mengimpor Data di Python

Preparing Video For Download...