1
$\begingroup$

I imported some data from Excel and got the following for my date and values:

{{{1986, 1, 2, 0, 0, 0.}, 25.56, ""}, {{1986, 1, 3, 0, 0, 0.}, 26., ""}

It seems that there is an extra space there. How can I remove that and make appropriate format for DateListPlot? Also important: what materials do I need to learn to overcome such difficulties?

$\endgroup$
5
$\begingroup$
l = {{{1986, 1, 2, 0, 0, 0.}, 25.56, ""}, {{1986, 1, 3, 0, 0, 0.},  26., ""}};
DateListPlot[l[[All, 1 ;; 2]], Joined -> True]

Take a look at Span (;;) and Part ( [[ ]] )

$\endgroup$
3
$\begingroup$

Another option with Most[]:

l = {{{1986, 1, 2, 0, 0, 0.}, 25.56, ""}, {{1986, 1, 3, 0, 0, 0.},  26., ""}};
DateListPlot[Most/@l, Joined -> True]

Most[expr] gives expr with the last element removed.

$\endgroup$
1
$\begingroup$

You could also use Transpose[] with Thread[]:

l = {{{1986, 1, 2, 0, 0, 0.}, 25.56, ""}, {{1986, 1, 3, 0, 0, 0.},26., ""}};
DateListPlot[Thread[Transpose[l][[1 ;; 2]]], Joined -> True]
$\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.