Giter Site home page Giter Site logo

periodicaldates.jl's People

Contributors

fuzhiyu avatar kristofferc avatar matthieugomez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

periodicaldates.jl's Issues

AnnualDate

Would it be possible to provide a similar type for annual data (AnnualDate)?

Writing to CSV

I am trying to save a dataset with monthly dates. It seems that I am not able to at this stage.

It seems that everything is ok for Dates:

using DataFrames, MonthlyDates, Dates
using CSV
df = DataFrame(x = DateTime(1983, 12, 1), y = "a", z=1)
CSV.write("test.csv", df)

Monthly dates would probably have to be translated into dates?

df = DataFrame(x = MonthlyDate(1983, 12), y = "a", z=1)
CSV.write("test.csv", df)

Probably would make sense to crosspost on CSV.jl

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

Safeguard against invalid month/quarter values

When we try to construct a Date with invalid months/days, an ArgumentError will be thrown

julia> Date(1991, 12, 45)
ERROR: ArgumentError: Day: 45 out of range (1:31)

They have a validargs function checking whether the arguments are out of range. This mechanism is missing in this package, so if we pass year-month to QuarterlyDate, it won't complain but roll it over to the next year:

julia> QuarterlyDate(1995, 5)
1996-Q1

It seems pretty error-prone to me. I once passed year-month pairs to QuarterlyDate and screwed up the whole dataset. Do you think we should also implement a validargs function here to avoid invalid arguments?

I could work on it if you also like this idea.

Strange behavior when year is Float versus Int

MonthlyDates gives inconsistent results when the first argument is a Float rather than an Int.

> x = 192607
> MonthlyDate(floor(x / 100), x % 100)
1927q3
> MonthlyDate(Int(floor(x / 100)), x % 100)
1926m7

Maybe I am missing something and this is a feature that is useful somewhere else?

string literal macros

I got lazy again and found the construction of a single quarterly date is a bit tedious (QuarterlyDate(2020, 1)). Do you consider adding string literal macros to the package? Here is my idea:

macro yq_str(ymstr)
    return :(QuarterlyDate($ymstr))
end

macro ym_str(ymstr)
    return :(MonthlyDate($ymstr))
end

so a QuarterlyDate(2020, 3) can be simply constructed as yq"2020-Q3".

MonthlyDates.jl: strange behavior in x-axis with long time series

I have a long time series comprising 238 quarterly observations (1960.Q1-2019.Q2)). For teaching, I want to plot them using interactivity with Plots, plotlyjs(), Dates.jl and MontlyDates.jl. However, I have a problem with the x-axis displaying the correct information, and I would be very grateful if someone could help.

Without interactivity, I would just create a 238-element LinRange{Float64} with the dates using, e.g., Period1=LinRange(1960,2019.25,238), and with a simple piece of code:

plot(
    	Period1, [RealGDP  RealINV  RealCONS],
    	labels = ["GDP" "INV" "CONS"],
	color = [:red :orange :blue],
    	legend = :topleft,
	fg_legend = :transparent,
    	title = "Real GDP, Investment and Consumption: US (1960.Q1--2019.Q2)",
    	titlefontsize = 11,
)

I would get the following figure:

aa1

I have a problem with this simple approach because the thousands-separating comma distorts the dates (I would not mind 2000.5, but 2,005.5 looks awkward). So I searched and found the MonthlyDates.jl, which looks nice and easy to use. I define the format according to:

Period2 = QuarterlyDate("1960-Q1"):Quarter(1):QuarterlyDate("2019-Q2")

and the output, by collect(Period2) gives the correct output:

1960-Q1
1960-Q2
1960-Q3
1960-Q4
1961-Q1
1961-Q2
1961-Q3
1961-Q4
1962-Q1
...

A time series can be easily produced by replacing Period1 with Period2 in the code above. The plot looks like this:

aa2

There are three problems with this plot that I don't know how to remove:

(i) the chosen dates by default look helpless (why should the first x-axis entry be 1963-Q2?);

(ii) the x-axis only displays the correct dates if we put the cursor right on top of displayed entries (for example, 2000-Q4 looks OK): see figure above.

(iii) If we put the cursor slightly to the left/right of the displayed entries on the x-axis, a string appears that makes no sense (e.g., "8023"); see figure below.

This problem looks like an easy one to solve. I tried many ways but failed. Help will be appreciated.

aa3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.