Skip to content

Commit

Permalink
Merge branch 'xKDR:main' into t175_julia_version
Browse files Browse the repository at this point in the history
  • Loading branch information
siddjain444 authored Apr 25, 2024
2 parents 0bc8081 + 1cb4746 commit 56440c4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 35 deletions.
32 changes: 25 additions & 7 deletions src/TSFrame.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,33 @@
`::TSFrame` - A type to hold ordered data with an index.
A TSFrame object is essentially a `DataFrame` with a specific column marked
as an index. The input `DataFrame` is sorted during construction and
is stored under the property `coredata`. The index is stored in the
`Index` column of `coredata`.
A TSFrame object is essentially a
[DataFrame](https://dataframes.juliadata.org/) with a specific column
marked as an index. The first argument can accept a DataFrame, Vector,
or an Array with 2-dimensions. Any
[Tables.jl](https://github.com/JuliaData/Tables.jl) compatible table
is also accepted as an input.
If the first argument is a `DataFrame` then the DataFrame may contain
an indexing column also. The indexing column can be identified by
providing either the column number or the column name as `String` or
`Symbol` in the DataFrame as the second argument `index`.
In case, an indexing column is not present in the DataFrame then a
sequential index is created automatically.
The input `DataFrame` is sorted during construction and is stored
in the property `coredata`. The index is stored in the column
called `Index` of the `coredata` DataFrame. This index can be fetched
using the [`index()`](@ref) method.
Providing an empty DataFrame to the constructor results in a TSFrame
object with an empty index and no columns. Similarly, providing empty
Vector or empty Array as the first argument results in an empty
TSFrame with no columns.
Permitted data inputs to the constructors are `DataFrame`, `Vector`,
and 2-dimensional `Array`. If an index is already not present in the
constructor then a sequential integer index is created
automatically.
and 2-dimensional `Array`.
`TSFrame(coredata::DataFrame)`: Here, the constructor looks for a column
named `Index` in `coredata` as the index column, if this is not found
Expand Down
30 changes: 2 additions & 28 deletions src/endpoints.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
"""
# Computing end points
```julia
endpoints(timestamps::AbstractVector{T}, on::V) where {T<:Union{Date, DateTime, Time},
V<:Union{
Year,
Quarter,
Month,
Week,
Day,
Hour,
Minute,
Second,
Millisecond,
Microsecond,
Nanosecond
}}
endpoints(timestamps::AbstractVector{T}, on::V) where {T<:Union{Date, DateTime, Time}, V<:Dates.Period}
endpoints(ts::TSFrame, on::T) where {T<:Dates.Period}
endpoints(ts::TSFrame, on::Symbol, k::Int=1)
endpoints(ts::TSFrame, on::String, k::Int=1)
Expand Down Expand Up @@ -317,20 +304,7 @@ function endpoints(ts::TSFrame, on::Function, k::Int=1)
endpoints(index(ts), on, k)
end

function endpoints(timestamps::AbstractVector{T}, on::V)::Vector{Int} where {T<:Union{Date, DateTime, Time},
V<:Union{
Year,
Quarter,
Month,
Week,
Day,
Hour,
Minute,
Second,
Millisecond,
Microsecond,
Nanosecond
}}
function endpoints(timestamps::AbstractVector{T}, on::V)::Vector{Int} where {T<:Union{Date, DateTime, Time}, V<:Dates.Period}
if (on.value <= 0)
throw(DomainError("`on.value` needs to be greater than 0"))
end
Expand Down

0 comments on commit 56440c4

Please sign in to comment.