Sufficiency Economy
Group Blog
 
All blogs
 
Python : Machine Learning [3]

วันนี้เรียน บทที่ 5 ซึ่งจะพูดถึง การ covert ข้อมูล การสรุปข้อมูลพื้นฐาน และการเลือกข้อมูล ใน pandas
รูปแบบ การ covert วันเวลา
pd.to_datetime("2020-02-16")
สามารถใส่เป็น list ได้ คือ pd.to_datetime(["2020-02-16","2001-03-18"])
ถ้าต้องการตรวจสอบว่าใส่วันที่ผิดหรือไม่ให้ใช้ 
pd.to_datetime(["2020-02-16","abc"],errors="coerce") มันจะไม่ error

การ convert ตัวเลขให้ ใช้ to_numeric

การสรุปข้อมูลพื้นฐาน เช่น
df.describe(include="all")
df.info
df["START*"].value_counts() ทำให้รู้  unique data

การเลือกข้อมูล df.iloc[0:5,0:4] 
ถ้าต้องการระบุชื่อ column ให้ใช้ df.loc["START*"] คือใส่ชื่อ column ที่ต้องการเลือก

ข้อสังเกต ถ้าเราเลือก column เดียว type จะเปลี่ยนจาก dataframe เป็น series ??

key short cut : run command ให้กด control + enter (ใน mac)
อีกอย่าง ถ้าต้องเก็บข้อมูลที่ทดลอง key ให้ save จะได้ file นามสกุล .ipynb ทำให้ไม่ต้องเสียเวลามาพิมพ์ใหม่






 


Create Date : 12 สิงหาคม 2563
Last Update : 20 สิงหาคม 2563 20:33:47 น. 0 comments
Counter : 948 Pageviews.

ชื่อ :
Comment :
  *ใช้ code html ตกแต่งข้อความได้เฉพาะสมาชิก
 

wink99_th
Location :
พิษณุโลก Thailand

[Profile ทั้งหมด]

ฝากข้อความหลังไมค์
Rss Feed
Smember
ผู้ติดตามบล็อก : 8 คน [?]




New Comments
Friends' blogs
[Add wink99_th's blog to your web]
Links
 

 Pantip.com | PantipMarket.com | Pantown.com | © 2004 BlogGang.com allrights reserved.