Kho lưu trữ này lấy một
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object6 chứa Bảng tổng hợp với dữ liệu nguồn bên ngoài bị ẩn và chuyển đổi bộ đệm ẩn tổng hợp thành một tệp văn bản với các giá trị được phân tách bằng
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object7. Nó tính đến các tệp quá lớn để có trong bộ nhớ và xử lý tình huống này bằng cách chia dữ liệu gốc thành các đợt
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object8
Tài liệu
phương pháp luận
Mã này giải nén tệp
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object9 và trích xuất dữ liệu có trong tệp
x = [1, 2, 3, 4, 5, 6, 7, 8, 9] x[0:3]0. Các bản ghi bộ nhớ cache của trục được phân tích cú pháp và sắp xếp thành một giá trị riêng biệt
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object7
Bắt đầu
điều kiện tiên quyết
- con trăn 3. 6 và píp
cài đặt
- Sao chép dự án từ ocampor/pivot-table-to-csv
- Cài đặt trăn 3. 6 và píp
- Tạo một môi trường ảo ________ 22 và tạo nguồn cho nó ________ 23
- Cài đặt yêu cầu python
x = [1, 2, 3, 4, 5, 6, 7, 8, 9] x[0:3]
4
Mã vận hành
Bạn có thể chạy mã bằng cách thực thi
x = [1, 2, 3, 4, 5, 6, 7, 8, 9] x[0:3]5. Các tùy chọn như sau
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object
70 hoặcList of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object
71 một tùy chọn bắt buộc chỉ định tệp cần chuyển đổi- Tùy chọn tùy chọn
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object
72 hoặcList of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object
73 chỉ định tên tệp đầu ra mong muốn List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object
74 hoặcList of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object
75 số lượng hoặc phần để tách tệp gốc trước khi chuyển đổi. Nên chia nhỏ file thành 5 phần đối với file excel dung lượng 100mb. Khuyến nghị thứ hai cho thiết bị có RAM 16 gbList of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object
76 hoặcList of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object
77 kích hoạt mức ghi GỠ LỖI
Chạy thử nghiệm
- Chạy
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object
78
triển khai
được bao gồm
Đóng góp
Khi đóng góp cho kho lưu trữ này, trước tiên vui lòng thảo luận về thay đổi mà bạn muốn thực hiện thông qua vấn đề, email hoặc bất kỳ phương thức nào khác với chủ sở hữu của kho lưu trữ này trước khi thực hiện thay đổi
Viết chương trình Pandas để trích xuất nhãn cột, hình dạng và kiểu dữ liệu của tập dữ liệu [titanic. csv]. Chuyển đến Trình chỉnh sửa
Giải pháp mẫu
Mã Python
import pandas as pd
import numpy as np
df = pd.read_csv['titanic.csv']
print["List of columns:"]
print[df.columns]
print["\nShape of the Dataset:"]
print[df.shape]
print["\nData types of the Dataset:"]
print[df.dtypes]
Đầu ra mẫu
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object
Trình chỉnh sửa mã Python
Xoay Titanic. csv
Có một cách khác để giải quyết giải pháp này?
Trước. Viết chương trình Pandas để in một bản tóm tắt ngắn gọn về tập dữ liệu [titanic. csv].
Tiếp theo. Viết chương trình Pandas để tạo bảng Pivot với nhiều chỉ mục từ tập dữ liệu của titanic. csv.
Mức độ khó của bài tập này là gì?
Dễ dàng trung bình khóKiểm tra kỹ năng Lập trình của bạn với bài kiểm tra của w3resource
Chia sẻ Hướng dẫn / Bài tập này trên. Facebook và Twitter
con trăn. Lời khuyên trong ngày
Liệt kê các thủ thuật cắt lát
danh sách [bắt đầu. dừng lại. bươc]
x = [1, 2, 3, 4, 5, 6, 7, 8, 9] x[0:3]
đầu ra
[1, 2, 3]
x[3:]
đầu ra
[4, 5, 6, 7, 8, 9]
x[:6]
đầu ra
[1, 2, 3, 4, 5, 6]
x[0:6:2]
đầu ra
[1, 3, 5]
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object0
đầu ra
[1, 2, 3, 4, 5, 6]
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object2
đầu ra
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object3____14
đầu ra
List of columns: Index[['survived', 'pclass', 'sex', 'age', 'sibsp', 'parch', 'fare', 'embarked', 'class', 'who', 'adult_male', 'deck', 'embark_town', 'alive', 'alone', 'Unnamed: 15'], dtype='object'] Shape of the Dataset: [891, 16] Data types of the Dataset: survived int64 pclass int64 sex object age float64 sibsp int64 parch int64 fare float64 embarked object class object who object adult_male bool deck object embark_town object alive object alone bool Unnamed: 15 float64 dtype: object5Đang tải
- bài tập. Top 16 chủ đề phổ biến nhất hàng tuần
- Bài tập SQL, Thực hành, Lời giải - THAM GIA
- Bài tập, Thực hành, Giải pháp SQL - SUBQUERIES
- JavaScript cơ bản - Bài tập, Thực hành, Lời giải
- Mảng Java. Bài tập, Luyện tập, Lời giải
- Bài Tập Lập Trình C, Thực Hành, Lời Giải. Tuyên bố có điều kiện
- Cơ sở dữ liệu nhân sự - SORT FILTER. Bài tập, Luyện tập, Lời giải
- Bài Tập Lập Trình C, Thực Hành, Lời Giải. Sợi dây
- Kiểu dữ liệu Python. Từ điển - Bài tập, Thực hành, Lời giải
- Câu đố lập trình Python - Bài tập, Thực hành, Giải pháp
- Mảng C++. Bài tập, Luyện tập, Lời giải
- Câu lệnh điều kiện và vòng lặp JavaScript - Bài tập, Thực hành, Lời giải
- Thuật toán cơ bản C# Sharp. Bài tập, Luyện tập, Lời giải
- Python Lambda - Bài tập, Thực hành, Giải pháp
- Khung dữ liệu Python Pandas. Bài tập, Luyện tập, Lời giải
- Công cụ chuyển đổi
- JavaScript. Xác thực biểu mẫu HTML