Computer scienceData scienceInstrumentsPandasData preprocessing with pandas

Searching within a pandas DataFrame

Chart

Report a typo

In this task, you have a part of the USDA National Nutrient Database:

food_calories_df.head()

Output:

+----+-----------------+--------------+
|    | Shrt_Desc       |   Energ_Kcal |
|----+-----------------+--------------|
|  0 | VEAL,RIB,LN,RAW |          120 |
|  1 | BANANAS,RAW     |           89 |
|  2 | SYRUPS,MAPLE    |          260 |
|  3 | SUGARS,BROWN    |          380 |
|  4 | GINGER,GROUND   |          335 |
+----+-----------------+--------------+

Find and print the sum of energy values for the following rows from the Shrt_Desc column:

  • 'CARROTS,RAW'
  • 'BREAD,WHEAT'
  • 'CRANBERRIES,RAW'
  • 'SUGARS,MAPLE'
  • 'WATER,TAP,WELL'

The dataset is loaded as food_calories_df.

Write a program in Python 3
# your code here. the dataset is already loaded as food_calories_df.
print(...)
___

Create a free account to access the full topic