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

pandas.Categorical not preserved during DataFrame conversion and jl.convert fails

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

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

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

Hướng nghiên cứu

Bắt đầu với đường dẫn chuyển đổi pandas.DataFrame và trường hợp jl.convert(CategoricalArray, col) được mô tả trong issue. Theo dõi cách các cột pandas.Categorical được biểu diễn, sau đó xác minh rằng việc chuyển đổi bảo toàn ngữ nghĩa của CategoricalArray và việc chuyển đổi trực tiếp không còn thất bại.

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

Mô tả

question

Hi and thanks for the great package!

While working with juliacall + PythonCall.jl, I ran into two issues related to pandas.Categorical handling.

(In all examples below, jlrefers to Main from juliacall, i.e., from juliacall import Main as jl.)

DataFrame conversion ignores Categorical columns
When passing a pandas.DataFrame with categorical columns (i.e., dtype='category'), those columns are silently converted to Int64 vectors in Julia (presumably the .codes). This results in CategoricalArray semantics being lost — so interactions in Julia formulas like id & η1 are treated as numeric rather than generating dummy variables.

jl.convert() can’t convert pandas.Categorical to any Julia type
I tried using jl.convert(CategoricalArray, col) directly on a pandas.Series with categorical dtype, but got a MethodError. It appears PythonCall doesn’t yet support converting pandas.Categorical to any Julia-native type.

To work around this, I convert the column to str in Python (so it arrives as a Vector{String}), then manually wrap it in categorical(...) on the Julia side. This works, but it's not ideal for type fidelity or automatic translation.

Let me know if there's a cleaner workaround — or if you'd be open to a PR to improve automatic CategoricalArray support.

Thanks again!

Ngôn ngữ chính
Julia
Star
1.1k
Fork
89
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
7

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 JuliaPy/PythonCall.jl

Tất cả issue của JuliaPy/PythonCall.jl

Issue tương tự

Thêm issue về Julia

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.