Skip to content

Instantly share code, notes, and snippets.

@Celia-code
Created March 11, 2020 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Celia-code/24fb7bb2fa5474e6e22f892b55c4b729 to your computer and use it in GitHub Desktop.
Save Celia-code/24fb7bb2fa5474e6e22f892b55c4b729 to your computer and use it in GitHub Desktop.
This is for pandas
import pandas as pd
data = pd.DataFrame({
"name":["Amy", "Bob", "Chole"],
"score":[100, 80, 69]
})
#取得row的Series資料
print("取得第二列:", data.iloc[1], sep = "\n")
#取得column的Series資料
print("取得name欄位:", data["name"], sep = "\n")
#打印出
"""
取得第二列:
name Bob
score 80
Name: 1, dtype: object
取得name欄位:
0 Amy
1 Bob
2 Chole
Name: name, dtype: object
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment