1
$\begingroup$

I have daily time series data on a CSV that I'm trying to plot, but I can't seem to make it work nor can I find a clear answer as to what I'm doing wrong.

This is what I have:

This is what my data looks like:

enter image description here

For code I have:

Data = Import["filepath/data.csv", "CSV", "HeaderLines" -> 1 ] // Dataset 

which seems to work, but then I get an error when I try to use DateListPlot.

DateListPlot[{Data[All, {1, 2}]}, Data[All, {1, 3}]]

I know the issue is something simple that I'm overlooking, but I just can't spot it.

$\endgroup$
  • 1
    $\begingroup$ Could you please post the *.csv file on some place like Pastebin? $\endgroup$ – J. M. will be back soon Oct 1 '17 at 15:36
  • $\begingroup$ perhaps try adding the option "DateStringFormat" -> {"Month", "Day", "Year"} or "DateStringFormat" -> {"Month", "Day", "YearShort"} in Import? $\endgroup$ – kglr Oct 1 '17 at 15:50
2
$\begingroup$

For version 9, you can do the following

imp = DeleteCases[Import["C:\\Users\\W10\\Documents\\Book1.csv", "HeaderLines" -> 1, 
    "DateStringFormat" -> {"Month", "Day", "Year"}], "", 2] /. {} ->  Sequence[]

{{{2016, 6, 13}, 1, 2}, {{2016, 6, 14}, 2, 2}, {{2016, 6, 15}, 2, 1},
{{2016, 6, 16}, 3, 2}, {{2016, 6, 17}, 2, 2}, {{2016, 6, 18}, 2, 2},
{{2016, 6, 19}, 3, 1}, {{2016, 6, 20}, 4, 4}, {{2016, 6, 21}, 4, 4},
{{2016, 6, 22}, 6, 6}, {{2016, 6, 23}, 33, 17}, {{2016, 6, 24}, 100, 100},
{{2016, 6, 25}, 21, 29}}

And

DateListPlot[{imp[[All, {1, 2}]], imp[[All, {1, 3}]]}, Joined -> True ]

gives enter image description here

In version 11.2, with the free browser version, I can't check if the Import command above works, so I copy/pasted the imp to the browser.

ds = Dataset[imp]

enter image description here

DateListPlot[{ds[All, {1,2}],ds[All, {1,3}]}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.