# What is the syntax to properly plot a list of dates and values that go over one month?

I'm trying to experiment with the covid-19 data from John Hopkins as a way of learning some basic Mathematica functionality. I pulled down the CSV files and figured out how to convert them to datasets and then extra particular rows, etc. I ended up with a small chunk of data covering part of January and February. If I use DateListPlot on the first portion of that data, just covering January, it works fine. However, if I increase the length of the data by just 1 such that the first date of February is included, I get the following error:

DateListPlot::ldata: <|1/22/20->2,1/23/20->1,1/24/20->2,1/25/20->2,1/26/20->4,1/27/20->4,1/28/20->7,1/29/20->7,1/30/20->11,1/31/20->15,2/1/20->20|> is not a valid dataset or list of datasets.

I have no idea why adding the first date of the next month produces this error and would appreciate any insights.

Here is what I did

1) Pulled down the data from Github (https://github.com/CSSEGISandData/COVID-19.git)

Then in a Notebook:

confirmed =


(* See first image -- the plot works when the range goes from 5 to 14 but as soon as I change the end index from 14 to 15, the plot fails even though the list data displays correctly *)

• This is based on John Hopkins and might bee easier for you. Also see wolfr.am/coronavirus . Mar 20 '20 at 6:23
• Yes, thanks - I saw that --- however, I wanted to use the raw data from github as an excuse to teach myself some basic Mathematica. I'm mostly having problems with syntax. But this bizarre error about the dataset not being valid only when I add an extra date to it is throwing me. Mar 20 '20 at 12:38
• you should provide more detail: both inputs working and non working and screenshots of outputs for both of them for people to be able to explain to you what is going on. Mar 20 '20 at 14:30
• I have updated the initial post with some images that should clarify what I did. Really appreciate the help. Mar 20 '20 at 17:57
• I have updated my answer. Mar 20 '20 at 18:16

It is clear now that the extra point that you add is the only one that has the date that is ambiguous to interpretation:

data=Normal[confirmed[1][[5;;15]]]


<|"1/22/20" -> 2, "1/23/20" -> 3, "1/24/20" -> 5, "1/25/20" -> 7, "1/26/20" -> 8, "1/27/20" -> 8, "1/28/20" -> 14, "1/29/20" -> 14, "1/30/20" -> 14, "1/31/20" -> 19, "2/1/20" -> 19|>

So the last point -- is it FEB 1 or JAN 2 ? DateListPlot cannot interpret that date and gives error. This is why you need exact interpretation of dates:

convert=KeyMap[DateObject[{#,{"Month","Day","YearShort"}}]&,data]


Now it obviously works, no errors:

DateListPlot[convert, PlotMarkers -> Automatic]


• I'll try quotes but I don't understand then why it works for the January dates and only fails when I start to include Feb dates. Mar 20 '20 at 12:35
• If the "/" was computing division, then why does it work fine if I just use the january dates, e.g, that exact dataset you saw above with the very last item missing? Mar 20 '20 at 13:07
• @David you should provide more detail: both inputs working and non working and screenshots of outputs for both of them for people to be able to explain to you what is going on. Mar 20 '20 at 13:35
• @David ...and are you sure "it work fine" ? Do you see the same horizontal axis time stamps as on my plot? Mar 20 '20 at 15:01
• Yes, look at my first graph- it has the correct values for both dates (X-axis) and quantities (Y-axis) Mar 20 '20 at 19:39