Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.9K Views
|
5 Replies
|
1 Total Like
View groups...
Share
Share this post:

How to perform analysis on a FlightData call, that is in a time object format?

Posted 1 year ago

Hello there! I am trying to get data from FlightData to perform analysis on for a project for college! I am getting as far as getting the info, but I am not sure the best way to get everything into a format or a dataframe that would make this easily analyzable. I am familiar with R, but newer to Wolfram...

arrivalDelaysRaw = 
  FlightData[
   Entity["Airport", "MEM"] -> 
    Entity["Airport", 
     "LGA"], {"ArrivalDelay"}, {DateObject[{2023, 1, 1}], 
    DateObject[{2023, 1, 10}]}];

I call the data with the above, and try to convert with the below, which was working, but isn't working now for some reason.

safeConvertToMinutes[item_] := 
  Module[{minutes}, 
   minutes = 
    Quiet@Check[QuantityMagnitude[QuantityConvert[item, "Minutes"]], 
      None];
   If[minutes === None, Nothing, minutes] (*If conversion fails,
   return Nothing to filter out later*)];

processArrivalDelay[item_] := 
  If[item === Missing["NotAvailable"], Nothing,(*Exclude missing data*)
   safeConvertToMinutes[item] (*Attempt to convert to minutes*)];

processedArrivalDelays = Map[processArrivalDelay, arrivalDelaysRaw];

cleanedArrivalDelays = DeleteCases[processedArrivalDelays, Nothing];

cleanedArrivalDelays // Short

I am trying to perform general descriptive statistics on various flight routes delays, as well as making advanced graphics like stacked line plots or 3D Histograms. Is there anything glaringly obvious I am missing? Thank you in advance!

POSTED BY: R Balled
5 Replies

Hi Ryder,

maybe this helps a bit:

arrivalDelaysRaw = FlightData[Entity["Airport", "MEM"] -> Entity["Airport", "LGA"], {"ArrivalDelay"}, {DateObject[{2023, 1, 1}], DateObject[{2023, 1, 10}]}];
arrivalDelays0 = DeleteCases[arrivalDelaysRaw, <|"ArrivalDelay" -> Missing["NotAvailable"]|>];
arrivalDelays = KeyValueMap[{#1, UnitConvert[#2["ArrivalDelay"], "Minutes"]} &, arrivalDelays0]
POSTED BY: Henrik Schachner
Posted 1 year ago

Thank you, I am still having issues. The end goal is to get these datasets for various routes to be able to compare them statistically, but I am having trouble getting the list of numbers into something that is usable. Do you have any general advice for this? I appreciate the help very much!

POSTED BY: Updating Name

Can you provide an example of the data format that you are trying to construct?

POSTED BY: Rohit Namjoshi
Posted 1 year ago
Attachment

Attachments:
POSTED BY: R Balled

Hi Ryder,

QuantityConvert is not a built-in function. It should be UnitConvert. The error checking can be simplified by eliminating Missing from the raw data

arrivalDelaysRaw // Map[DeleteMissing] // processArrivalDelay

There is a handy Resource Function KeyGroupBy that you can use to group the data by airline or any other property of the Flight entity.

ResourceFunction["KeyGroupBy"][processedArrivalDelays, #["Airline"] &]
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard