Converting a list to Series

Report a typo

Suppose that the list foods contains names of different foods, and calories is a list that contains the corresponding calorie content per 100g.

Define a function that creates and returns a Series object that stores values from the calories list while having the names from foods as index. Also, set the name of the Series to Calorie content.

Note that you do NOT need to print your result.

For example, suppose that:

foods = ['bagel', 'pasta', 'rice']
calories = [310, 110, 140]

Just write your code to the function body, no need to define foods and calories, take input or additionally call the function!

Then, your function should return the following Series:

bagel    310
pasta    110
rice     140
Name: Calorie content, dtype: int64
Write a program in Python 3
import pandas as pd

def create_series(foods, calories):
# write your code here ....
pass
___

Create a free account to access the full topic