Petal Power Inventory: Question 9

I am confused with the Question 9 on Petal Power Inventory in Introduction to Pandas within Analyze Financial Data with Python.

My code is as follow:

import codecademylib
import pandas as pd

inventory = pd.read_csv('inventory.csv')
print(inventory)

staten_island = inventory.head(10)
print(staten_island)

product_request = staten_island['product_description']
print(product_request)

seed_request = inventory[(inventory.location == 'Brooklyn') & (inventory.product_type == 'seeds')]
print(seed_request)

inventory['in_stock'] = inventory.apply(lambda x: 'True' if x['quantity'] > 0 else 'False', axis = 1)
print(inventory)

inventory['total_value'] = inventory['price']*inventory['quantity']
print(inventory)

combine_lambda = lambda row: \
    '{} - {}'.format(row.product_type, row.product_description)

inventory['full_description'] = combine_lambda
print(inventory)

Question 9: Using combine_lambda , create a new column in inventory called full_description that has the complete description of each product.

The inventory’s full_description column produces strange results like at 0x7f5942984a50> and not the product description.

What has happened and how do I solve this?

Hello, @abdulhakim1997, and welcome to the Codecademy Forums!

Link to project: Petal Power Inventory

You need to get the combine_lambda function to execute. Instead, you only assigned a reference to that function to inventory['full_description'].

This should work:

inventory['full_description'] = inventory.apply(combine_lambda, axis=1)
2 Likes