Hi Mohammad,
data = WeatherData["KDRA", "Temperature", {{1911, 1, 1}, {2020, 12, 25}, "Day"}];
data["Dates"] // MinMax
(* {DateObject[{1978, 5, 15, 0, 0, 0.}, "Instant", "Gregorian", -6.],
DateObject[{2020, 12, 25, 0, 0, 0.}, "Instant", "Gregorian", -6.]} *)
WeatherData
only has temperature data for that date range. You may be able to find a source with a larger date range and Import
it. Even for the range that is available, there are several gaps ranging in length from 2 days to 42 days.
data["Dates"] // Differences // Counts // KeySort
To identify the missing date intervals write a predicate function to identify non-consecutive dates
consecutiveDatesQ[dates_] := DateDifference[First@dates, Last@dates, "Day"] != Quantity[1, "Day"]
The date ranges for which there is no data
missingDateIntervals = data["Dates"] //
BlockMap[If[consecutiveDatesQ@#,
DateInterval[{DatePlus[First@#, 1], DatePlus[Last@#, -1]}],
Nothing] &, #, 2, 1] &;
missingDateIntervals // TimelinePlot[#, PlotLayout -> "Overlapped"] &
Gaps of over a week
missingDateIntervals // Select[#["Duration"] > Quantity[7, "Day"] &] //
TimelinePlot[#, PlotLayout -> "Overlapped"] &