Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted
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 ( [[ ]] )

share|improve this answer
add comment

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.

share|improve this answer
add comment

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]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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