Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various comments #128

Open
bkamins opened this issue Dec 8, 2022 · 3 comments
Open

Various comments #128

bkamins opened this issue Dec 8, 2022 · 3 comments

Comments

@bkamins
Copy link

bkamins commented Dec 8, 2022

The index is stored in the Index column of coredata.

x-link to Index is missing

If coredata only has a single column then a new sequential index is generated.

  1. What if it has no columns?
  2. What if I want this single column already has name Index?

In general mention in the description the second argument in the constructor.

Mention that any Tables.jl table is also accepted.

:Index => index_at => :Index,

What if index column is not called :Index? (the same with other places - the docs above said that the index column does not have to be called Index, but maybe I misunderstood)

error("periods must be a postive int")

I would throw ArgumentError for easier error handling (also in other places)

V<:Union{

Why not just Period (this would allow for supporting user extensions of special date/time types)

j::AbstractVector{T}) where {T<:Union{String, Symbol}}

This is minor, but it is incorrect as it allows:

julia> Union{String, Symbol}[:s, "s"]
2-element Vector{Union{String, Symbol}}:
 :s
 "s"

Indexing with string

  1. You allow only String, while it would be better to allow for AbstractString
  2. You do not allow for indexing with vector of Bool (neither rows nor columns) - maybe this is intended
  3. You do not allow special selectors like Between, Not etc. (maybe this is intended?)

return (f == :coredata) ? getfield(ts, :coredata) : getproperty(ts.coredata, f)

This is incorrect. coredata can have :coredata column name. fields and properties should not be mixed. I would use a function to expose :coredata field instead. Eg. getdataframe(tsf::TSFrame) = getfield(tsf, :coredata)

Base.join

People did not like extending this function in packages. Better add methods for innerjoin etc.
You might consider allowing passing kwargs like renamecols.

DataFrames.Matrix(ts.coredata[!, Not(:Index)])

DataFrames prefix is not needed

general question (maybe I missed something)

Maybe you want TSFrame to be iterable? I.e. have length and support something like:

for row in tsf
# here have DataFrameRow with data
end

general question (maybe I missed something)

How do you want to support panel data (so essentially TSFrame grouped by some column)

@chiraganand
Copy link
Member

Thanks @bkamins for the very useful comments. I have responded below.

The index is stored in the Index column of coredata.

x-link to Index is missing

Sorry, did not understand this. What is the purpose of cross linking?

If coredata only has a single column then a new sequential index is generated.

1. What if it has no columns?

There is a constructor for creating an empty TSFrame object but currently it does not work with a DataFrame without any columns. Ideally, TSFrame(DataFrame()) should create a TSFrame with an Index column and 0 other non-index columns and 0 rows.

2. What if I want this single column already has name `Index`?

Right now, TSFrame(DataFrame(Index=[1, 2])) throws an error because a DataFrame cannot be constructed with two Index column names. This only happens when the DataFrame has only one column named Index. In other cases, the column named Index is taken as the index column of TSFrame, this is the intended behaviour. The single column DataFrame implementation will have to be fixed.

In general mention in the description the second argument in the constructor.
Mention that any Tables.jl table is also accepted.

Yes, to both.

:Index => index_at => :Index,

What if index column is not called :Index? (the same with other places - the docs above said that the index column does not have to be called Index, but maybe I misunderstood)

It means that the original DataFrame does not need to have a column named Index because the TSFrame index can be constructed using an existing column by specifying the column index (Int) or the name (Symbol/String).

If the column number or name isn't specified in the constructor then Index named column is looked up and if that doesn't exist then Index is generated.

error("periods must be a postive int")

I would throw ArgumentError for easier error handling (also in other places)

Yes.

V<:Union{

Why not just Period (this would allow for supporting user extensions of special date/time types)

Yes, of course. Got missed.

j::AbstractVector{T}) where {T<:Union{String, Symbol}}

This is minor, but it is incorrect as it allows:

julia> Union{String, Symbol}[:s, "s"]
2-element Vector{Union{String, Symbol}}:
 :s
 "s"

Thanks, did not know about this.

Indexing with string

1. You allow only `String`, while it would be better to allow for `AbstractString`

Yes.

2. You do not allow for indexing with vector of `Bool` (neither rows nor columns) - maybe this is intended
3. You do not allow special selectors like `Between`, `Not` etc. (maybe this is intended?)

Not that both of these are not intended but were lower priority earlier. I believe these would be good enhancements.

return (f == :coredata) ? getfield(ts, :coredata) : getproperty(ts.coredata, f)

This is incorrect. coredata can have :coredata column name. fields and properties should not be mixed. I would use a function to expose :coredata field instead. Eg. getdataframe(tsf::TSFrame) = getfield(tsf, :coredata)

Alright, will fix this.

Base.join

People did not like extending this function in packages. Better add methods for innerjoin etc. You might consider allowing passing kwargs like renamecols.

This is done to keep the API simple with a single join method supporting all kinds of joins. R zoo/xts follow this convention.

DataFrames.Matrix(ts.coredata[!, Not(:Index)])

DataFrames prefix is not needed

Okay.

general question (maybe I missed something)

Maybe you want TSFrame to be iterable? I.e. have length and support something like:

for row in tsf # here have DataFrameRow with data end

This is possible with Tables.jl implementation: for row in Tables.rows(tsf)

general question (maybe I missed something)

How do you want to support panel data (so essentially TSFrame grouped by some column)

There hasn't been much thought about taking this path actually. Not sure if TSFrames should handle panel data use cases or another package which uses composition with TSFrame?

@bkamins
Copy link
Author

bkamins commented Dec 15, 2022

What is the purpose of cross linking?

So that in the generated documentation you can click on Index and go to its definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants