diff --git a/src/Pandas.jl b/src/Pandas.jl index 57820b9..55203f7 100644 --- a/src/Pandas.jl +++ b/src/Pandas.jl @@ -110,14 +110,17 @@ end function Base.values(x::PandasWrapped) - # Zero-copy conversion to a Julia native type is possible - x_kind = x.pyo.dtype.kind - if x_kind in ["i", "u", "f", "b"] - pyarray = convert(PyArray, x.pyo."values") - unsafe_wrap(Array, pyarray.data, size(pyarray)) - else # Convert element by element otherwise - collect(x) + # Check if zero-copy conversion to a Julia native type + # is possible. + if hasproperty(x.pyo, :dtype) + x_kind = x.pyo.dtype.kind + if x_kind in ["i", "u", "f", "b"] + pyarray = convert(PyArray, x.pyo."values") + return unsafe_wrap(Array, pyarray.data, size(pyarray)) + end end + # Convert element by element otherwise + Array(x) end """ diff --git a/test/runtests.jl b/test/runtests.jl index 93642a0..fc8e498 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -81,3 +81,7 @@ df3 = Pandas.Series(3:4) @test all(df1 == df1) @test all(df1 == df2) @test df1 != [1, 2] + +# Issue #93 +df = DataFrame(:a=>[1,2], :b=>[4,5], :c=>["a","b"]) +@test values(df) == [1 4 "a"; 2 5 "b"]