ความสำคัญของ flat file ในวิทยาศาสตร์ข้อมูล

Python เบื้องต้น: การนำเข้าข้อมูล

Hugo Bowne-Anderson

Data Scientist at DataCamp

Flat file

titanic.csv

PassengerId,Survived,Pclass,Name,Gender,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked
1,0,3,"Braund, Mr. Owen Harris",male,22,1,0,A/5 21171,7.25,,S
2,1,1,"Cumings, Mrs. John Bradley",female,38,1,0,PC 17599,71.2833,C85,C
3,1,3,"Heikkinen, Miss. Laina",female,26,0,0,STON/O2.3101282,7.925,,S
Python เบื้องต้น: การนำเข้าข้อมูล

Flat file

titanic.csv

PassengerId,Survived,Pclass,Name,Gender,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked

1,0,3,"Braund, Mr. Owen Harris",male,22,1,0,A/5 21171,7.25,,S

2,1,1,"Cumings, Mrs. John Bradley",female,38,1,0,PC 17599,71.2833,C85,C

3,1,3,"Heikkinen, Miss. Laina",female,26,0,0,STON/O2.3101282,7.925,,S

arrow

                        Name      Sex  Cabin  Survived
     Braund, Mr. Owen Harris     male    NaN         0
  Cumings, Mrs. John Bradley   female    C85         1
      Heikkinen, Miss. Laina   female    NaN         1
Futrelle, Mrs. Jacques Heath   female   C123         1
    Allen, Mr. William Henry     male    NaN         0
Python เบื้องต้น: การนำเข้าข้อมูล

Flat file

titanic.csv

titanic.csv ที่มีการไฮไลต์แถว arrow

                        Name      Sex  Cabin  Survived
     Braund, Mr. Owen Harris     male    NaN         0
  Cumings, Mrs. John Bradley   female    C85         1
      Heikkinen, Miss. Laina   female    NaN         1
Python เบื้องต้น: การนำเข้าข้อมูล

Flat file

titanic.csv

titanic.csv ที่มีการไฮไลต์คอลัมน์ arrow

                        Name      Sex  Cabin  Survived
     Braund, Mr. Owen Harris     male    NaN         0
  Cumings, Mrs. John Bradley   female    C85         1
      Heikkinen, Miss. Laina   female    NaN         1
Python เบื้องต้น: การนำเข้าข้อมูล

Flat file

  • ไฟล์ข้อความที่เก็บข้อมูลเป็นระเบียน
  • กล่าวคือ ข้อมูลในรูปแบบตาราง
  • ระเบียน: แถวของฟิลด์หรือแอตทริบิวต์

 

titanic.csv

PassengerId,Survived,Pclass,Name,Gender,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked
1,0,3,"Braund, Mr. Owen Harris",male,22,1,0,A/5 21171,7.25,,S
2,1,1,"Cumings, Mrs. John Bradley",female,38,1,0,PC 17599,71.2833,C85,C
3,1,3,"Heikkinen, Miss. Laina",female,26,0,0,STON/O2.3101282,7.925,,S
Python เบื้องต้น: การนำเข้าข้อมูล

Flat file

  • ไฟล์ข้อความที่เก็บข้อมูลเป็นระเบียน
  • กล่าวคือ ข้อมูลในรูปแบบตาราง
  • ระเบียน: แถวของฟิลด์หรือแอตทริบิวต์
  • คอลัมน์: ฟีเจอร์หรือแอตทริบิวต์

titanic.csv

titanic.csv ที่มีการไฮไลต์แถว arrow

Python เบื้องต้น: การนำเข้าข้อมูล

Flat file

  • ไฟล์ข้อความที่เก็บข้อมูลเป็นระเบียน
  • กล่าวคือ ข้อมูลในรูปแบบตาราง
  • ระเบียน: แถวของฟิลด์หรือแอตทริบิวต์
  • คอลัมน์: ฟีเจอร์หรือแอตทริบิวต์

titanic.csv

titanic.csv ที่มีการไฮไลต์คอลัมน์ arrow

Python เบื้องต้น: การนำเข้าข้อมูล

ส่วนหัว

titanic.csv

________________________________________________________________________
PassengerId,Survived,Pclass,Name,Gender,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked
________________________________________________________________________
1,0,3,"Braund, Mr. Owen Harris",male,22,1,0,A/5 21171,7.25,,S   
2,1,1,"Cumings, Mrs. John Bradley",female,38,1,0,PC 17599,71.2833,C85,C
3,1,3,"Heikkinen, Miss. Laina",female,26,0,0,STON/O2.3101282,7.925,,S
Python เบื้องต้น: การนำเข้าข้อมูล

ส่วนหัว

titanic.csv

________________________________________________________________________
PassengerId,Survived,Pclass,Name,Gender,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked
________________________________________________________________________
1,0,3,"Braund, Mr. Owen Harris",male,22,1,0,A/5 21171,7.25,,S   
2,1,1,"Cumings, Mrs. John Bradley",female,38,1,0,PC 17599,71.2833,C85,C
3,1,3,"Heikkinen, Miss. Laina",female,26,0,0,STON/O2.3101282,7.925,,S
Python เบื้องต้น: การนำเข้าข้อมูล

นามสกุลไฟล์

  • .csv - ค่าที่คั่นด้วยเครื่องหมายจุลภาค
  • .txt - ไฟล์ข้อความ
  • จุลภาค, แท็บ - ตัวคั่น
Python เบื้องต้น: การนำเข้าข้อมูล

ไฟล์ที่คั่นด้วย Tab

MNIST.txt

pixel149    pixel150    pixel151    pixel152    pixel153
0           0           0           0           0    
86          250         254         254         254    
0           0           0           9           254    
0           0           0           0           0    
103         253         253         253         253    
0           0           0           0           0    
0           0           0           0           0        
0           0           0           0           41        
253         253         253         253         253    
Python เบื้องต้น: การนำเข้าข้อมูล

ไฟล์ที่คั่นด้วย Tab

MNIST.txt

pixel149    pixel150    pixel151    pixel152    pixel153
0           0           0           0           0    
86          250         254         254         254    
0           0           0           9           254    
0           0           0           0           0    
103         253         253         253         253    
0           0           0           0           0    
0           0           0           0           0        
0           0           0           0           41        
253         253         253         253         253    

                                         ภาพ MNIST: mnist.png

Python เบื้องต้น: การนำเข้าข้อมูล

นำเข้า flat file อย่างไร?

  • แพ็กเกจหลัก 2 ตัว: NumPy และ pandas

ch_1_2.026.png

  • ในบทนี้จะเรียนรู้การนำเข้า:
    • Flat file ที่มีข้อมูลตัวเลข (MNIST)
    • Flat file ที่มีข้อมูลตัวเลขและข้อความ (titanic.csv)
Python เบื้องต้น: การนำเข้าข้อมูล

มาฝึกกันเถอะ!

Python เบื้องต้น: การนำเข้าข้อมูล

Preparing Video For Download...