Tag Info

New answers tagged

0

I dont realy get what result you expect from your code. Do you want to create a ListContourPlot or a ListPlot3D? My best guess: ListPlot3D[testData[[All, 2 ;;]], AxesLabel -> {"Bins", None, "%"}, PlotRange -> Full, ColorFunction -> "Rainbow", Ticks -> {Automatic, Transpose[{Range@Length@testData, DateString[#, {"Year", " ", "Month", ...


2

Some sample data: r = # - #[[1]] &@(Range[##, 3690] & @@ (AbsoluteTime[{#, {"Day", "Month", "YearShort"}}] & /@ {"05/01/14", "05/03/14"})); hours = N[r/3600]; data = Transpose[{hours, hours^2}]; Integrate: f = Interpolation@data; Integrate[f@x, {x, 0, Last@hours}] ...


9

There's a couple ways to do this: data = {{{2014, 8, 4, 10, 36, 0.}, 257.}, {{2014, 8, 4, 16, 28, 0.}, 385.}, {{2014, 8, 4, 22, 53, 0.}, 176.}, {{2014, 8, 5, 6, 52, 0.}, 148.}, {{2014, 8, 5, 11, 19, 0.}, 192.}}; 1) Convert dates to absolute times: data[[All, 1]] = AbsoluteTime /@ data[[All, 1]]; f1 = Interpolation@data; ...


5

dat = "2014-08-29 03:59:52 27273 Brown 2014-08-29 03:59:53 27276 Green 2014-08-29 03:59:55 27276 Brown 2014-08-29 03:59:57 27303 Red 2014-08-29 03:59:58 27303 Green 2014-08-29 03:59:59 27303 Brown 2014-08-29 04:00:04 27317 Brown 2014-08-29 04:00:07 27331 Blue 2014-08-29 04:00:07 27334 ...


4

dat = "2014-08-29 03:59:52 27273 Brown 2014-08-29 03:59:53 27276 Green 2014-08-29 03:59:55 27276 Brown 2014-08-29 03:59:57 27303 Red 2014-08-29 03:59:58 27303 Green 2014-08-29 03:59:59 27303 Brown 2014-08-29 04:00:04 27317 Brown 2014-08-29 04:00:07 27331 Blue 2014-08-29 04:00:07 27334 Blue 2014-08-29 04:00:08 27331 Red ...


1

With se.dat being exactly what you provided: dat = StringSplit[#, ","] & /@ Import["~/se.dat", "List"]; dates = ToExpression /@ (StringSplit[#, ","] & /@ (StringReplace[StringTrim@#, {"-" | " " | ":" -> ","}] & /@ First /@ dat)) val = ToExpression[#[[2]]] & /@ dat col = ToExpression[#[[3]]] & /@ dat ...


1

Ugly but simple, and when you are only interested in milliseconds also correct for this use case. DateString[{2014, 5, 7, 13, 47, Round[44.760,0.001] + 0.0001}, {"Year", "-", "Month", "-", "Day", " ", "Hour", ":", "Minute", ":", "SecondExact"}]


6

I think those who find this kind problem challenging enough to ask for s solution on this site are likely to be open to a tutorial answer giving a step-by-step exposition. The overall plan is to develop a function that will take one item from the table, compute the date difference for that item, and insert it into the item. With such a function, any data ...


6

My proposal: {##, data[[1, 1]] ~DayCount~ #} & @@@ data {{{2012, 6, 1}, 16, 0}, {{2012, 6, 8}, 14.24, 7}, ..., {{2012, 10, 9}, 4.53, 130}}


2

data /. {date_: {_, _, _}, v_} :> {date, v, DateDifference[{2012, 6, 1}, date]} {{{2012, 6, 1}, 16, Quantity[0, "Days"]}, {{2012, 6, 8}, 14.24, Quantity[7, "Days"]},... If you are using V10 you need to use QuantityMagnitude to get the number of days as a number. This goes for all answers using DateDifference. data /. {date_: {_, _, _}, v_} :> ...


1

{## & @@ #, DateDifference[data[[1, 1]], First@#]} & /@ data (* {{{2012, 6, 1}, 16, 0}, {{2012, 6, 8}, 14.24, 7}, {{2012, 6, 15}, 13.7, 14}, {{2012, 6, 22}, 12.31, 21}, {{2012, 6, 29}, 11.5, 28}, {{2012, 7, 6}, 10.08, 35}, {{2012, 7, 13}, 9.18, 42}, {{2012, 7, 20}, 8.65, 49}, {{2012, 7, 27}, 7.8, 56}, {{2012, 8, 3}, 7.51, 63}, ...


3

DateDifference[First@First@data, #] & /@ (First /@ data) Append[#, #2] & @@@ Thread@{data, %} {0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 130} {{{2012, 6, 1}, 16, 0}, {{2012, 6, 8}, 14.24, 7}, {{2012, 6, 15}, 13.7, 14}, {{2012, 6, 22}, 12.31, 21}, {{2012, 6, 29}, 11.5, 28}, {{2012, 7, 6}, 10.08, 35}, {{2012, ...


4

I would use: DateRange[{2000}, {2010}, "Year"][[All, {1}]] {{2000}, {2001}, {2002}, {2003}, {2004}, {2005}, {2006}, {2007}, {2008}, {2009}, {2010}} % ~Select~ LeapYearQ {{2000}, {2004}, {2008}} Note the {1} in the Part parameters; see Head and everything except Head?


4

I'm afraid you now have to extract that information by yourself. This performs the same function as eldo's code, but instead of using Map twice I use Composition. It is also showcasing the new Mathematica 10 syntax. Map[List@*First]@*Select[LeapYearQ]@DateRange[{2000}, {2020}, "Year"] {{2000}, {2004}, {2008}, {2012}, {2016}, {2020}} In order to ...


2

As to your first question: List /@ First /@ Select[DateRange[{2000}, {2020}, "Year"], LeapYearQ] {{2000}, {2004}, {2008}, {2012}, {2016}, {2020}}


2

This is due to the fact that the first data point pulled (for {2014,8,14}) is used to calculate the first return value, which is on {2014,8,15}. To calculate the return for {2014,8,14} the previous day is needed. In order to get matching starting dates in a reliable way, it is best to determine the starting date, e.g. firstDate={2014, 01, 05} and than ...


2

Some possibilities to plot GridLines with DateListPlot: DateListPlot[{ {{2014, 1, 1}, 1}, {{2014, 1, 2}, 2}, {{2014, 1, 3}, 3}}, PlotTheme -> "Detailed"] DateListPlot[{ {{2014, 1, 1}, 1}, {{2014, 1, 2}, 2}, {{2014, 1, 3}, 3}, {{2014, 1, 4}, 1}}, GridLines -> {{{{2014, 1, 2}, Red}, {"Jan 3, 2014", Green}}, Automatic}] ...



Top 50 recent answers are included