ยินดีต้อนรับสู่ Python!

Python สำหรับผู้ใช้สเปรดชีต

Chris Cardillo

Data Scientist

Python คืออะไร?

  • ภาษาโปรแกรมเอนกประสงค์
  • มีแพ็กเกจสำหรับ data science
  • เชิงวัตถุ (Object-oriented)
Python สำหรับผู้ใช้สเปรดชีต

สเปรดชีตเชิงวัตถุ

Sum in Sheets.png

Python สำหรับผู้ใช้สเปรดชีต

สเปรดชีตเชิงวัตถุ

Lookup in Sheets.png

Python สำหรับผู้ใช้สเปรดชีต

Python เชิงวัตถุ

ใน Python
math.SUM(2,3)
ในสเปรดชีต

Sum in Cells.png

Python สำหรับผู้ใช้สเปรดชีต

พลังของจุด (dot)

math.SUM()
  • math คือแพ็กเกจของเรา
  • SUM คือฟังก์ชันในแพ็กเกจ
  • จุด (.) ใช้เข้าถึงฟังก์ชันภายในแพ็กเกจ
Python สำหรับผู้ใช้สเปรดชีต

สคริปต์

สูตรทำขนมปังปิ้งทาเนย

1. Turn on toaster

2. Put bread in toaster for 1 minute

3. Take bread out of toaster

4. Put butter on toast
Python สำหรับผู้ใช้สเปรดชีต

การนำเข้าแพ็กเกจ

import math
Python สำหรับผู้ใช้สเปรดชีต

การนำเข้า pandas

obligatory panda.jpeg

Python สำหรับผู้ใช้สเปรดชีต

การนำเข้า pandas

import pandas
Python สำหรับผู้ใช้สเปรดชีต

โหลดข้อมูล Excel

import pandas

pandas.read_excel('fruit.xlsx')

Fruit Simple.png

  • fruit.xlsx
    • (รูปแบบข้อมูลที่ pandas รองรับ)
Python สำหรับผู้ใช้สเปรดชีต

pandas as pd

ก่อน

import pandas

pandas.read_excel('fruit.xlsx')

หลัง

import pandas as pd

pd.read_excel('fruit.xlsx')
Python สำหรับผู้ใช้สเปรดชีต

การกำหนดตัวแปร

import pandas as pd

fruit = pd.read_excel('fruit.xlsx')

Fruit Simple.png

fruit.xlsx

Python สำหรับผู้ใช้สเปรดชีต

ดูข้อมูลด้วย print()

import pandas as pd

fruit = pd.read_excel('fruit.xlsx')

print(fruit)

simple fruit whole dataset.png

Python สำหรับผู้ใช้สเปรดชีต

แผงสคริปต์และคอนโซลใน DataCamp

print fruit script and console.png

  • script.py คือสคริปต์
  • IPython Shell คือคอนโซล
Python สำหรับผู้ใช้สเปรดชีต

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

Python สำหรับผู้ใช้สเปรดชีต

Preparing Video For Download...