Commit 6295bd85 authored by MichelJuillard's avatar MichelJuillard
Browse files

switch to ExtendedDates, bump version 0.1.3

parent 5ee267e1
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
[[ArgTools]] [[ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
version = "1.1.1"
[[Artifacts]] [[Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
...@@ -9,6 +10,12 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" ...@@ -9,6 +10,12 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
[[Base64]] [[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[CSTParser]]
deps = ["Tokenize"]
git-tree-sha1 = "b2667530e42347b10c10ba6623cfebc09ac5c7b6"
uuid = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
version = "3.2.4"
[[CSV]] [[CSV]]
deps = ["Dates", "Mmap", "Parsers", "PooledArrays", "SentinelArrays", "Tables", "Unicode"] deps = ["Dates", "Mmap", "Parsers", "PooledArrays", "SentinelArrays", "Tables", "Unicode"]
git-tree-sha1 = "6d4242ef4cb1539e7ede8e01a47a32365e0a34cd" git-tree-sha1 = "6d4242ef4cb1539e7ede8e01a47a32365e0a34cd"
...@@ -21,6 +28,18 @@ git-tree-sha1 = "f713d583d10fc036252fd826feebc6c173c522a8" ...@@ -21,6 +28,18 @@ git-tree-sha1 = "f713d583d10fc036252fd826feebc6c173c522a8"
uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597" uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597"
version = "0.9.5" version = "0.9.5"
[[CodeTracking]]
deps = ["InteractiveUtils", "UUIDs"]
git-tree-sha1 = "9aa8a5ebb6b5bf469a7e0e2b5202cf6f8c291104"
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
version = "1.0.6"
[[CommonMark]]
deps = ["Crayons", "JSON", "URIs"]
git-tree-sha1 = "393ac9df4eb085c2ab12005fc496dae2e1da344e"
uuid = "a80b9123-70ca-4bc0-993e-6e3bcb318db6"
version = "0.8.3"
[[Compat]] [[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "ac4132ad78082518ec2037ae5770b6e796f7f956" git-tree-sha1 = "ac4132ad78082518ec2037ae5770b6e796f7f956"
...@@ -69,6 +88,16 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" ...@@ -69,6 +88,16 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[Downloads]] [[Downloads]]
deps = ["ArgTools", "LibCURL", "NetworkOptions"] deps = ["ArgTools", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
version = "1.4.0"
[[ExtendedDates]]
deps = ["CodeTracking", "Dates", "JuliaFormatter", "Printf", "Revise"]
path = "../ExtendedDates"
uuid = "78f5a1cc-aa73-4dda-b6b2-4d6b1976988f"
version = "0.1.0"
[[FileWatching]]
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
[[Formatting]] [[Formatting]]
deps = ["Printf"] deps = ["Printf"]
...@@ -95,45 +124,73 @@ git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856" ...@@ -95,45 +124,73 @@ git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
uuid = "82899510-4779-5014-852e-03e436cf321d" uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0" version = "1.0.0"
[[JLLWrappers]]
deps = ["Preferences"]
git-tree-sha1 = "642a199af8b68253517b80bd3bfd17eb4e84df6e"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.3.0"
[[JSON]] [[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"] deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4" git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.1" version = "0.21.1"
[[JuliaFormatter]]
deps = ["CSTParser", "CommonMark", "DataStructures", "Pkg", "Tokenize"]
git-tree-sha1 = "cf0dbee6a5a30e2aef87f3b54bc3733ca2df2939"
uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
version = "0.16.1"
[[JuliaInterpreter]]
deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"]
git-tree-sha1 = "e273807f38074f033d94207a201e6e827d8417db"
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
version = "0.8.21"
[[LibCURL]] [[LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"] deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
version = "0.6.2"
[[LibCURL_jll]] [[LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] deps = ["LibSSH2_jll", "Libdl", "MbedTLS_jll", "Pkg", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
version = "7.73.0+4"
[[LibGit2]] [[LibGit2]]
deps = ["Base64", "NetworkOptions", "Printf", "SHA"] deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
[[LibSSH2_jll]] [[LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"] deps = ["Artifacts", "JLLWrappers", "Libdl", "MbedTLS_jll", "Pkg"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
version = "1.9.1+2"
[[Libdl]] [[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
[[LinearAlgebra]] [[LinearAlgebra]]
deps = ["Libdl"] deps = ["Libdl", "libblastrampoline_jll"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
[[Logging]] [[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
[[LoweredCodeUtils]]
deps = ["JuliaInterpreter"]
git-tree-sha1 = "491a883c4fef1103077a7f648961adbf9c8dd933"
uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
version = "2.1.2"
[[Markdown]] [[Markdown]]
deps = ["Base64"] deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[MbedTLS_jll]] [[MbedTLS_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.24.0+2"
[[Missings]] [[Missings]]
deps = ["DataAPI"] deps = ["DataAPI"]
...@@ -145,10 +202,13 @@ version = "0.4.5" ...@@ -145,10 +202,13 @@ version = "0.4.5"
uuid = "a63ad114-7e13-5084-954f-fe012c677804" uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[MozillaCACerts_jll]] [[MozillaCACerts_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159" uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
version = "2020.7.22"
[[NetworkOptions]] [[NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
version = "1.2.0"
[[OrderedCollections]] [[OrderedCollections]]
git-tree-sha1 = "4fa2ba51070ec13fcc7517db714445b4ab986bdf" git-tree-sha1 = "4fa2ba51070ec13fcc7517db714445b4ab986bdf"
...@@ -161,15 +221,10 @@ git-tree-sha1 = "c8abc88faa3f7a3950832ac5d6e690881590d6dc" ...@@ -161,15 +221,10 @@ git-tree-sha1 = "c8abc88faa3f7a3950832ac5d6e690881590d6dc"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "1.1.0" version = "1.1.0"
[[Periods]]
deps = ["Dates", "Test"]
git-tree-sha1 = "846d5f9989d915415e208c1e4e558cb5f5c489db"
uuid = "0c1d1a06-9168-427d-90e3-b4d73349562f"
version = "0.1.0"
[[Pkg]] [[Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
version = "1.6.0"
[[PooledArrays]] [[PooledArrays]]
deps = ["DataAPI", "Future"] deps = ["DataAPI", "Future"]
...@@ -177,6 +232,12 @@ git-tree-sha1 = "cde4ce9d6f33219465b55162811d8de8139c0414" ...@@ -177,6 +232,12 @@ git-tree-sha1 = "cde4ce9d6f33219465b55162811d8de8139c0414"
uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720" uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
version = "1.2.1" version = "1.2.1"
[[Preferences]]
deps = ["TOML"]
git-tree-sha1 = "00cfd92944ca9c760982747e9a1d0d5d86ab1e5a"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.2.2"
[[PrettyTables]] [[PrettyTables]]
deps = ["Crayons", "Formatting", "Markdown", "Reexport", "Tables"] deps = ["Crayons", "Formatting", "Markdown", "Reexport", "Tables"]
git-tree-sha1 = "574a6b3ea95f04e8757c0280bb9c29f1a5e35138" git-tree-sha1 = "574a6b3ea95f04e8757c0280bb9c29f1a5e35138"
...@@ -200,6 +261,18 @@ git-tree-sha1 = "57d8440b0c7d98fc4f889e478e80f268d534c9d5" ...@@ -200,6 +261,18 @@ git-tree-sha1 = "57d8440b0c7d98fc4f889e478e80f268d534c9d5"
uuid = "189a3867-3050-52da-a836-e630ba90ab69" uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "1.0.0" version = "1.0.0"
[[Requires]]
deps = ["UUIDs"]
git-tree-sha1 = "4036a3bd08ac7e968e27c203d45f5fff15020621"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.1.3"
[[Revise]]
deps = ["CodeTracking", "Distributed", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "Pkg", "REPL", "Requires", "UUIDs", "Unicode"]
git-tree-sha1 = "1947d2d75463bd86d87eaba7265b0721598dd803"
uuid = "295af30f-e4ad-537b-8983-00126c2a3abe"
version = "3.1.19"
[[SHA]] [[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
...@@ -242,6 +315,7 @@ version = "1.6.0" ...@@ -242,6 +315,7 @@ version = "1.6.0"
[[TOML]] [[TOML]]
deps = ["Dates"] deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
version = "1.0.0"
[[TableTraits]] [[TableTraits]]
deps = ["IteratorInterfaceExtensions"] deps = ["IteratorInterfaceExtensions"]
...@@ -258,11 +332,22 @@ version = "1.4.2" ...@@ -258,11 +332,22 @@ version = "1.4.2"
[[Tar]] [[Tar]]
deps = ["ArgTools", "SHA"] deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
version = "1.9.1"
[[Test]] [[Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[Tokenize]]
git-tree-sha1 = "0952c9cee34988092d73a5708780b3917166a0dd"
uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624"
version = "0.5.21"
[[URIs]]
git-tree-sha1 = "97bbe755a53fe859669cd907f2d96aee8d2c1355"
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
version = "1.3.0"
[[UUIDs]] [[UUIDs]]
deps = ["Random", "SHA"] deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
...@@ -271,13 +356,21 @@ uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" ...@@ -271,13 +356,21 @@ uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
[[Zlib_jll]] [[Zlib_jll]]
deps = ["Libdl"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a" uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
version = "1.2.12+1"
[[libblastrampoline_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "3.0.4+0"
[[nghttp2_jll]] [[nghttp2_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
version = "1.41.0+1"
[[p7zip_jll]] [[p7zip_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
version = "16.2.1+1"
name = "TimeDataFrames" name = "TimeDataFrames"
uuid = "ff13af16-2f41-468a-a2e1-aff5c43aabf7" uuid = "ff13af16-2f41-468a-a2e1-aff5c43aabf7"
authors = ["michel "] authors = ["michel "]
version = "0.1.2" version = "0.1.3"
[deps] [deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Periods = "0c1d1a06-9168-427d-90e3-b4d73349562f" ExtendedDates = "78f5a1cc-aa73-4dda-b6b2-4d6b1976988f"
[compat]
julia = ">= 1.6.3"
...@@ -2,62 +2,63 @@ module TimeDataFrames ...@@ -2,62 +2,63 @@ module TimeDataFrames
using CSV using CSV
using DataFrames using DataFrames
using Periods using ExtendedDates
export TimeDataFrame, innerjoin, outerjoin export TimeDataFrame, innerjoin, outerjoin
mutable struct TimeDataFrame mutable struct TimeDataFrame
data::DataFrame data::DataFrame
periods::Vector{Period} periods::AbstractVector{ExtendedDates.SimpleDate}
continuous::Bool continuous::Bool
frequency::Frequency function TimeDataFrame(data::DataFrame,
periods::AbstractVector{T},
continuous::Bool) where T <: ExtendedDates.SimpleDate
new(data, periods, continuous)
end
end; end;
TimeDataFrame() = TimeDataFrame(DataFrame(), Vector{Period}(), true,
Undated)
TimeDataFrame(frequency::Frequency) = TimeDataFrame(DataFrame(), TimeDataFrame() = TimeDataFrame(DataFrame(), Vector{T}(), true) where T <: ExtendedDates.SimpleDate
Vector{Period}(), true, frequency)
function TimeDataFrame(dataframe::AbstractDataFrame, frequency::Frequency, firstperiod; function TimeDataFrame(dataframe::AbstractDataFrame, firstperiod::T;
copycols::Bool=true) copycols::Bool=true) where T <: ExtendedDates.SimpleDate
periods = [Period(firstperiod + i - 1, frequency) for i in 1:DataFrames.nrow(dataframe)] periods = range(firstperiod, length=DataFrames.nrow(dataframe), step = typeof(firstperiod - firstperiod)(1))
TimeDataFrame(DataFrame(dataframe; copycols), periods, true, frequency) TimeDataFrame(DataFrame(dataframe; copycols), periods, true)
end end
function TimeDataFrame(filename::String, frequency::Frequency, firstperiod::Integer) function TimeDataFrame(filename::String, firstperiod::T) where T <: ExtendedDates.SimpleDate
data = DataFrame(CSV.File(filename)) data = DataFrame(CSV.File(filename))
continuous = true continuous = true
periods = [Period(firstperiod + i - 1, 0, Year) for i in 1:size(data, 1)] periods = range(firstperiod, size(data, 1))
TimeDataFrame(data, periods, true, frequency) TimeDataFrame(data, periods, true)
end end
TimeDataFrame(frequency::Frequency, firstperiod, pairs::Pair{Symbol,<:Any}...; TimeDataFrame(firstperiod::T, pairs::Pair{Symbol,<:Any}...;
makeunique::Bool=false, copycols::Bool=true) = makeunique::Bool=false, copycols::Bool=true) where T <: ExtendedDates.SimpleDate =
TimeDataFrame(DataFrame(pairs; makeunique, copycols), TimeDataFrame(DataFrame(pairs; makeunique, copycols),
frequency, firstperiod) firstperiod)
TimeDataFrame(frequency::Frequency, firstperiod, pairs::Pair{<:AbstractString,<:Any}...; TimeDataFrame(firstperiod::T, pairs::Pair{<:AbstractString,<:Any}...;
makeunique::Bool=false, copycols::Bool=true) = makeunique::Bool=false, copycols::Bool=true) where T <: ExtendedDates.SimpleDate =
TimeDataFrame(DataFrame(pairs; makeunique, copycols), TimeDataFrame(DataFrame(pairs; makeunique, copycols),
frequency, firstperiod) firstperiod)
# these two are needed as a workaround Tables.jl dispatch # these two are needed as a workaround Tables.jl dispatch
TimeDataFrame(pairs::AbstractVector{<:Pair}, frequency::Frequency, firstperiod; makeunique::Bool=false, TimeDataFrame(pairs::AbstractVector{<:Pair}, firstperiod::T; makeunique::Bool=false,
copycols::Bool=true) = copycols::Bool=true) where T <: ExtendedDates.SimpleDate =
TimeDataFrame(DataFrame(pairs..., makeunique=makeunique, copycols=copycols), TimeDataFrame(DataFrame(pairs..., makeunique=makeunique, copycols=copycols),
frequency, firstperiod) firstperiod)
TimeDataFrame(pairs::NTuple{N, Pair}, frequency::Frequency, firstperiod; makeunique::Bool=false, TimeDataFrame(pairs::NTuple{N, Pair}, firstperiod::T; makeunique::Bool=false,
copycols::Bool=true) where {N} = copycols::Bool=true) where {N,T <: ExtendedDates.SimpleDate} =
TimeDataFrame(DataFrame(pairs..., makeunique=makeunique, copycols=copycols), TimeDataFrame(DataFrame(pairs..., makeunique=makeunique, copycols=copycols),
frequency, firstperiod) firstperiod)
TimeDataFrame(d::AbstractDict, frequency::Frequency, firstperiod; copycols::Bool=true) = TimeDataFrame(d::AbstractDict, firstperiod::T; copycols::Bool=true) where T <: ExtendedDates.SimpleDate =
TimeDataFrame(DataFrame(d; copycols), frequency, firstperiod) TimeDataFrame(DataFrame(d; copycols), firstperiod)
#= #=
TimeDataFrame(frequency::Frequency, firstperiod; kwargs...) TimeDataFrame(frequency::ExtendedDates.Frequency, firstperiod::ExtendedDates.SimpleDate; kwargs...)
if isempty(kwargs) if isempty(kwargs)
TimeDataFrame() TimeDataFrame()
else else
...@@ -81,59 +82,58 @@ TimeDataFrame(frequency::Frequency, firstperiod; kwargs...) ...@@ -81,59 +82,58 @@ TimeDataFrame(frequency::Frequency, firstperiod; kwargs...)
end end
=# =#
TimeDataFrame(columns::AbstractVector, cnames::AbstractVector{Symbol}, frequency::Frequency, TimeDataFrame(columns::AbstractVector, cnames::AbstractVector{Symbol},
firstperiod; makeunique::Bool=false, copycols::Bool=true) = firstperiod::T; makeunique::Bool=false, copycols::Bool=true) where T <: ExtendedDates.SimpleDate =
TimeDataFrame(DataFrame(columns, cnames; makeunique, copycols), frequency, firstperiod) TimeDataFrame(DataFrame(columns, cnames; makeunique, copycols), firstperiod)
TimeDataFrame(columns::AbstractVector, cnames::AbstractVector{<:AbstractString}, frequency::Frequency, TimeDataFrame(columns::AbstractVector, cnames::AbstractVector{<:AbstractString},
firstperiod; makeunique::Bool=false, copycols::Bool=true) = firstperiod::T; makeunique::Bool=false, copycols::Bool=true) where T <: ExtendedDates.SimpleDate =
TimeDataFrame(DataFrame(columns, Symbol.(cnames), makeunique=makeunique, copycols=copycols), TimeDataFrame(DataFrame(columns, Symbol.(cnames), makeunique=makeunique, copycols=copycols),
frequency, firstperiod) firstperiod)
TimeDataFrame(columns::AbstractVector{<:AbstractVector}, frequency::Frequency, firstperiod, TimeDataFrame(columns::AbstractVector{<:AbstractVector}, firstperiod::T,
cnames::AbstractVector{Symbol}=gennames(length(columns)); cnames::AbstractVector{Symbol}=gennames(length(columns));
makeunique::Bool=false, copycols::Bool=true) = makeunique::Bool=false, copycols::Bool=true) where T <: ExtendedDates.SimpleDate =
TimeDataFrame(DataFrame(collect(AbstractVector, columns), TimeDataFrame(DataFrame(collect(AbstractVector, columns),
Index(convert(Vector{Symbol}, cnames), makeunique=makeunique), Index(convert(Vector{Symbol}, cnames), makeunique=makeunique),
copycols=copycols), frequency, firstperiod) copycols=copycols), firstperiod)
TimeDataFrame(columns::AbstractVector{<:AbstractVector}, TimeDataFrame(columns::AbstractVector{<:AbstractVector},
cnames::AbstractVector{<:AbstractString}, frequency::Frequency, firstperiod; cnames::AbstractVector{<:AbstractString}, firstperiod::T;
makeunique::Bool=false, copycols::Bool=true) = makeunique::Bool=false, copycols::Bool=true) where T <: ExtendedDates.SimpleDate =
TimeDataFrame(DataFrame(columns, Symbol.(cnames); makeunique=makeunique, copycols=copycols), TimeDataFrame(DataFrame(columns, Symbol.(cnames); makeunique=makeunique, copycols=copycols),
frequency, firstperiod) firstperiod)
TimeDataFrame(columns::NTuple{N, AbstractVector}, cnames::NTuple{N, Symbol}, frequency::Frequency, firstperiod; TimeDataFrame(columns::NTuple{N, AbstractVector}, cnames::NTuple{N, Symbol}, firstperiod::T;
makeunique::Bool=false, copycols::Bool=true) where {N} = makeunique::Bool=false, copycols::Bool=true) where {N, T <: ExtendedDates.SimpleDate} =
TimeDataFrame(DataFrame(collect(AbstractVector, columns), collect(Symbol, cnames), TimeDataFrame(DataFrame(collect(AbstractVector, columns), collect(Symbol, cnames),
makeunique=makeunique, copycols=copycols), frequency, firstperiod) makeunique=makeunique, copycols=copycols), firstperiod)
TimeDataFrame(columns::NTuple{N, AbstractVector}, cnames::NTuple{N, AbstractString}, frequency::Frequency, firstperiod; TimeDataFrame(columns::NTuple{N, AbstractVector}, cnames::NTuple{N, AbstractString}, firstperiod::T;
makeunique::Bool=false, copycols::Bool=true) where {N} = makeunique::Bool=false, copycols::Bool=true) where {N, T <: ExtendedDates.SimpleDate} =
TimeDataFrame(DataFrame(columns, Symbol.(cnames); makeunique=makeunique, copycols=copycols), frequency, TimeDataFrame(DataFrame(columns, Symbol.(cnames); makeunique=makeunique, copycols=copycols),
firstperiod) firstperiod)
TimeDataFrame(columns::NTuple{N, AbstractVector}, frequency::Frequency, firstperiod; copycols::Bool=true) where {N} = TimeDataFrame(columns::NTuple{N, AbstractVector}, firstperiod::T; copycols::Bool=true) where {N, T <: ExtendedDates.SimpleDate} =
TimeDataFrame(DataFrame(collect(AbstractVector, columns), gennames(length(columns)), TimeDataFrame(DataFrame(collect(AbstractVector, columns), gennames(length(columns)),
copycols=copycols), frequency, firstperiod) copycols=copycols), firstperiod)
TimeDataFrame(columns::AbstractMatrix, frequency::Frequency, firstperiod, TimeDataFrame(columns::AbstractMatrix, firstperiod::T,
cnames::AbstractVector{Symbol} = gennames(size(columns, 2)); makeunique::Bool=false) = cnames::AbstractVector{Symbol} = gennames(size(columns, 2)); makeunique::Bool=false) where T <: ExtendedDates.SimpleDate =
TimeDataFrame(DataFrame(AbstractVector[columns[:, i] for i in 1:size(columns, 2)], cnames, TimeDataFrame(DataFrame(AbstractVector[columns[:, i] for i in 1:size(columns, 2)], cnames,
makeunique=makeunique, copycols=false), frequency, firstperiod) makeunique=makeunique, copycols=false), firstperiod)
TimeDataFrame(columns::AbstractMatrix, cnames::AbstractVector{<:AbstractString}, frequency::Frequency, firstperiod; TimeDataFrame(columns::AbstractMatrix, cnames::AbstractVector{<:AbstractString}, firstperiod::T;
makeunique::Bool=false) = makeunique::Bool=false) where T <: ExtendedDates.SimpleDate =
TimeDataFrame(DataFrame(columns, Symbol.(cnames); makeunique=makeunique), frequency, firstperiod) TimeDataFrame(DataFrame(columns, Symbol.(cnames); makeunique=makeunique), firstperiod)
TimeDataFrame(column_eltypes::AbstractVector{T}, cnames::AbstractVector{Symbol}, TimeDataFrame(column_eltypes::AbstractVector{T}, cnames::AbstractVector{Symbol},
frequency::Frequency, firstperiod, nrows::Integer=0; makeunique::Bool=false) where T<:Type = firstperiod::P, nrows::Integer=0; makeunique::Bool=false) where {T<:Type, P <: ExtendedDates.SimpleDate} =
TimeDataFrame(DataFrame(column_eltypes, cnames, nrows; makeunique), frequency, firstperiod) TimeDataFrame(DataFrame(column_eltypes, cnames, nrows; makeunique), firstperiod)
TimeDataFrame(column_eltypes::AbstractVector{<:Type}, TimeDataFrame(column_eltypes::AbstractVector{T}, cnames::AbstractVector{S}, firstperiod::P,
cnames::AbstractVector{<:AbstractString}, nrows::Integer=0; makeunique::Bool=false) where {T <: Type, P <: ExtendedDates.SimpleDate, S <: AbstractString} =
frequency::Frequency, firstperiod, nrows::Integer=0; makeunique::Bool=false) = TimeDataFrame(DataFrame(column_eltypes, Symbol.(cnames), nrows; makeunique=makeunique),
TimeDataFrame(DataFrame(column_eltypes, Symbol.(cnames), nrows; makeunique=makeunique), frequency,
firstperiod) firstperiod)
# Redefining getproperty breaks tdf.data ! # Redefining getproperty breaks tdf.data !
...@@ -142,10 +142,9 @@ function Base.getproperty(tdf::TimeDataFrame, symbol::Symbol) ...@@ -142,10 +142,9 @@ function Base.getproperty(tdf::TimeDataFrame, symbol::Symbol)
x = getproperty(data, symbol) x = getproperty(data, symbol)
periods = getfield(tdf, :periods) periods = getfield(tdf, :periods)
continuous = getfield(tdf, :continuous) continuous = getfield(tdf, :continuous)
frequency = getfield(tdf, :frequency)
df = DataFrame() df = DataFrame()
df[!, symbol] = x df[!, symbol] = x
TimeDataFrame(df, periods, continuous, frequency)