CommencerCommencer gratuitement

From a dictionary of lists

A common way to create pandas DataFrames is by defining each column. This is especially useful if the data for each column is already in a list or NumPy array. In this exercise, you will take data from multiple lists and create a Python dictionary and a pandas' DataFrame.

The following lists are loaded into your workspace:

  • date: dates for each strike, as strings
  • height: the height (feet) at which the strike occurred
  • speed: the speed (knots) at which the strike occurred
  • engine: the engine type for each strike
  • airport: the airport associated with each strike
  • damage: the severity of damage to the aircraft

Cet exercice fait partie du cours

Python for MATLAB Users

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Create a dictionary from lists
strikes_dict = {'Date' : date,
                'Speed' : ____,
                '____' : height,
                '____' : ____, 
                '____' : ____,
                 ____ : airport}

# Print dictionary
print(strikes_dict)
Modifier et exécuter le code