開始使用免費開始

更正欄位選取錯誤

一位資淺偵探嘗試存取 credit_records 的地點相關欄位,但他犯了一些錯誤。請協助更正他的程式碼,好讓我們能搜尋可疑的消費。

在接下來的所有練習中,pandas 會以 pd 匯入。 DataFrame credit_records 已經匯入。

本練習屬於課程

Python 的資料科學入門

檢視課程

練習說明

  • 更正程式碼,讓它能在沒有錯誤的情況下執行。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# One or more lines of code contain errors.
# Fix the errors so that the code runs.

# Select the location column in credit_records
location = credit_records[location]

# Select the item column in credit_records
items = credit_records."item"

# Display results
print(location)
編輯並執行程式碼