Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add a section to read and parse data into a DataFrame

Đang mở
#610 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tài liệu
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
pandas, python
Lĩnh vực
data, documentation

Hướng nghiên cứu

Đọc các phần “Automating data processing using For Loops” và “Reading CSV Data Using Pandas” được liên kết trong issue, cùng với cấu trúc xung quanh của bài học. Công việc được xem là hoàn tất khi bài học bao gồm một phần rõ ràng về việc phân tích các hàng CSV thành một DataFrame bằng ví dụ generator được đề xuất và giải thích khi nào cách tiếp cận này hữu ích với các tập dữ liệu lớn.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

How could the content be improved?

The following section introduce how data can be processed using loops

Automating data processing using For Loops

I believe it would also be advantageous to have a similar section in the following

Reading CSV Data Using Pandas

Here we can briefly introduce python generators as well. For example, consider a CSV file where entries are name, age, location. We can parse this data to a dataframe using a generator. Image location is a comma separated string field and we want to read latitude and longitude separately.

name age location
John 50 123341,123321
Emily 25 321321,123321
Wick 35 123341,654789
Raj 40 987789,123321
import csv
import pandas as pd


def transform_lines(csv_path):
    reader = csv.reader(open(csv_path))

    for line_no, line in enumerate(reader):
        if line_no == 0:
            yield ["Name", "Age", "Latitude", "Longitude"]
        else:
            name, age, location = line
            lat, lng = location.split(",")
            yield [name, int(age), float(lat), float(lng)]


lines = transform_lines("./data.csv")
df = pd.DataFrame(lines)

print(df.head())

This is specially useful in large datasets where loading large amount of data in text form is memory consuming.

Ngôn ngữ chính
Jupyter Notebook
Star
176
Fork
316
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của datacarpentry/python-ecology-lesson

Tất cả issue của datacarpentry/python-ecology-lesson

Issue tương tự

Thêm issue về Data Engineering

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.