single column indexing of DataFrames return different types

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

single column indexing of DataFrames return different types

Christian Groll
Is the following single column indexing behaviour wanted?

> df = convert(DataFrame, rand(8, 4))
> typeof(df[1])
Array{Float64,1}

> df2 = DataFrame(a = rand(8), b = rand(8))
> typeof(df2[1])
DataArray{Float64,1}

And if yes: how can I predict what type will be returned?

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: single column indexing of DataFrames return different types

John Myles White
For df2, we should probably stop doing the automatic promotion to DataArray from Array. But this depends upon a part of the semantics that were always contentious: should the default column in a DataFrame be like SQL's NOT NULL or should it be ready to accept NULL?

 -- John

On Jul 25, 2014, at 9:21 AM, Christian Groll <[hidden email]> wrote:

Is the following single column indexing behaviour wanted?

> df = convert(DataFrame, rand(8, 4))
> typeof(df[1])
Array{Float64,1}

> df2 = DataFrame(a = rand(8), b = rand(8))
> typeof(df2[1])
DataArray{Float64,1}

And if yes: how can I predict what type will be returned?

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: single column indexing of DataFrames return different types

John Myles White
In reply to this post by Christian Groll
For future reference, this issue doesn't have anything to do with indexing. This has to do with conversions during DataFrame construction.

 -- John

On Jul 25, 2014, at 9:21 AM, Christian Groll <[hidden email]> wrote:

Is the following single column indexing behaviour wanted?

> df = convert(DataFrame, rand(8, 4))
> typeof(df[1])
Array{Float64,1}

> df2 = DataFrame(a = rand(8), b = rand(8))
> typeof(df2[1])
DataArray{Float64,1}

And if yes: how can I predict what type will be returned?

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: single column indexing of DataFrames return different types

Christian Groll
Thanks for answering - I hope I did get the point now. For the sake of clarity, I guess the following sentence of the documentation is outdated:

"The DataFrame type can be used to represent data tables, each column of which is a DataArray."

And the problem of my example was that df did store the data as Array, and not as DataArray (like df2).

On Friday, 25 July 2014 19:00:16 UTC+2, John Myles White wrote:
For future reference, this issue doesn't have anything to do with indexing. This has to do with conversions during DataFrame construction.

 -- John

On Jul 25, 2014, at 9:21 AM, Christian Groll <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="4H8Q6GZmExIJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">groll.chr...@...> wrote:

Is the following single column indexing behaviour wanted?

> df = convert(DataFrame, rand(8, 4))
> typeof(df[1])
Array{Float64,1}

> df2 = DataFrame(a = rand(8), b = rand(8))
> typeof(df2[1])
DataArray{Float64,1}

And if yes: how can I predict what type will be returned?

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="4H8Q6GZmExIJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">julia-stats...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: single column indexing of DataFrames return different types

John Myles White
We should change the docs a bit. We should also finally standardize on the behavior with regard to acceptable column types. This has gotten a lot better, but needs to be formalized well enough that we agree how things will behave throughout the whole ecosystem.

 -- John

On Jul 25, 2014, at 10:53 AM, Christian Groll <[hidden email]> wrote:

Thanks for answering - I hope I did get the point now. For the sake of clarity, I guess the following sentence of the documentation is outdated:

"The DataFrame type can be used to represent data tables, each column of which is a DataArray."

And the problem of my example was that df did store the data as Array, and not as DataArray (like df2).

On Friday, 25 July 2014 19:00:16 UTC+2, John Myles White wrote:
For future reference, this issue doesn't have anything to do with indexing. This has to do with conversions during DataFrame construction.

 -- John

On Jul 25, 2014, at 9:21 AM, Christian Groll <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="4H8Q6GZmExIJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">groll.chr...@...> wrote:

Is the following single column indexing behaviour wanted?

> df = convert(DataFrame, rand(8, 4))
> typeof(df[1])
Array{Float64,1}

> df2 = DataFrame(a = rand(8), b = rand(8))
> typeof(df2[1])
DataArray{Float64,1}

And if yes: how can I predict what type will be returned?

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="4H8Q6GZmExIJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">julia-stats...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.