# Converting Pandas Dataframe returned from PyCall to Julia DataFrame

**URL:** <https://discourse.julialang.org/t/converting-pandas-dataframe-returned-from-pycall-to-julia-dataframe/43001>\
**Category:** General Usage\
**Tags:** pycall, dataframes\
**Created:** [July 13, 2020, 7:43pm UTC](https://discourse.julialang.org/t/converting-pandas-dataframe-returned-from-pycall-to-julia-dataframe/43001 "2020-07-13T19:43:47Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![lungben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lungben/32/12314_2.png) [@lungben](https://discourse.julialang.org/u/lungben)\
**Post date:** [July 13, 2020, 8:20pm UTC](https://discourse.julialang.org/t/converting-pandas-dataframe-returned-from-pycall-to-julia-dataframe/43001/2 "2020-07-13T20:20:14Z")

</div>

Pandas DataFrames and Julia DataFrames.jl cannot directly be converted to my knowledge.  
However, the underlying data structures, Numpy arrays and Julia Arrays, can be passed very efficiently with PyCall.

```julia
using PyCall
using DataFrames

pd = pyimport("pandas")
df= pd.read_csv("test_data.csv")

function pd_to_df(df_pd)
    df= DataFrame()
    for col in df_pd.columns
        df[!, col] = getproperty(df_pd, col).values
    end
    df
end

df_julia = pd_to_df(df)

```

Performance is very good - 0.1s for 450k rows and 20 columns on my quite weak machine.

---

_[View the full topic](https://discourse.julialang.org/t/converting-pandas-dataframe-returned-from-pycall-to-julia-dataframe/43001)._
