•   over 11 years ago

Question: date in integers in file"2"

In the data file "2", "Sub-national time series data on Ebola cases", the date is represented using an integer from 41722 to 41985. Could anyone explain which dates are these integers correspond to? Thanks!

  • 2 comments

  •   •   over 11 years ago

    Those numbers tell us that the data was saved from an Excel file and not generated directly as a text-file. Excel stores dates as days elapsed since Jan 1, 1900. Except there's a bug that makes Excel think 1900 was a leap year, so you really want to measure days since Dec 31, 1899 =P

    In Python, for '41722,' the treatment would be:

    import datetime
    new_date = datetime.date(1899, 12, 30) + datetime.timedelta(days=41722)

    new_date is 'datetime.date(2014, 3, 24)' - which can be confirmed by putting '41722' into Excel and converting it to a Short Date.

  •   •   over 11 years ago

    In R, you can do this.
    as.Date("1899-12-31") + your_dataset$date

    Use case:
    http://rpubs.com/kaz_yos/hackebola1

Comments are closed.