Skip to content

How to convert a Pandas DataFrame to Julia one without copy? #135

Closed
@ShuhuaGao

Description

@ShuhuaGao

In Python 3.9:

import pandas as pd
import numpy as np

from juliacall import Main as jl

pd_df = pd.DataFrame({'Name': ['Tom', 'nick', 'krish', 'jack'],
                      'Age': [20, 21, 19, 18]})
jl.seval("using DataFrames")
jl_df = jl.DataFrame(pd_df)
jl_df[1, 2] = -100
pd_df.iloc[0, 1]  # still 20

Since PythonCall.PyPandasDataFrame is compatible with Table.jl and Julia DataFrame's constructor does not copy a table by default, how to explain the above behaviour? Is there any way to avoid data copying?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions