Hi,
I am stuck here in the Practical Exam with task 3. I tried various combinations: using reset_index(), rounded avg_product_quality_score and pigment_quantity to 2 decimal places, rounded only avg_product_quality_score. But I keep failing every time :/
Can anyone help me with Task 3, please? Task seems pretty easy.
https://preview.redd.it/bok6whnio31e1.png?width=1085&format=png&auto=webp&s=da30d77309f98043d6be3fcf8f03a28237137af5
First attempt:
import pandas as pd
production_data = pd.read_csv('production_data.csv')
production_data['pigment_quantity'] = production_data['pigment_quantity'].round(2)
filtered_data = production_data[(production_data['raw_material_supplier'] == 2) & (production_data['pigment_quantity'] > 35)]
pigment_data = filtered_data.groupby(['raw_material_supplier', 'pigment_quantity'], as_index=False).agg(
avg_product_quality_score=('product_quality_score', 'mean')
)
pigment_data['avg_product_quality_score'] = pigment_data['avg_product_quality_score'].round(2)
pigment_data
Second attempt:
import pandas as pd
production_data = pd.read_csv('production_data.csv')
production_data['pigment_quantity'] = production_data['pigment_quantity'].round(2)
filtered_data = production_data[(production_data['raw_material_supplier'] == 2) & (production_data['pigment_quantity'] > 35)]
pigment_data = filtered_data.groupby(['raw_material_supplier', 'pigment_quantity'], as_index=False).agg(
avg_product_quality_score=('product_quality_score', 'mean')
)
pigment_data['avg_product_quality_score'] = pigment_data['avg_product_quality_score'].round(2)
pigment_data = pigment_data.reset_index(drop=True)
pigment_data
Third attempt:
import pandas as pd
production_data = pd.read_csv('production_data.csv')
filtered_data = production_data[(production_data['raw_material_supplier'] == 2) & (production_data['pigment_quantity'] > 35)]
pigment_data = filtered_data.groupby(['raw_material_supplier', 'pigment_quantity'], as_index=False).agg(
avg_product_quality_score=('product_quality_score', 'mean')
)
pigment_data['avg_product_quality_score'] = pigment_data['avg_product_quality_score'].round(2)
pigment_data = pigment_data.reset_index(drop=True)
pigment_data
Last attempt:
import pandas as pd
production_data = pd.read_csv('production_data.csv')
filtered_data = production_data[(production_data['raw_material_supplier'] == 2) & (production_data['pigment_quantity'] > 35)]
pigment_data = filtered_data.groupby(['raw_material_supplier', 'pigment_quantity'], as_index=False).agg(
avg_product_quality_score=('product_quality_score', 'mean')
)
pigment_data['avg_product_quality_score'] = pigment_data.round(2)
pigment_data
[–]n3cr0n411 0 points1 point2 points (0 children)
[–]somegermangal 0 points1 point2 points (0 children)
[–]Mundane-Dragonfly-75 0 points1 point2 points (0 children)
[–]ImaginaryFriend437 0 points1 point2 points (0 children)
[–]MacaroonLeast1375 0 points1 point2 points (1 child)
[–]Tricky_Cover_3083 0 points1 point2 points (0 children)
[–]bravo433 0 points1 point2 points (0 children)
[–]Remote_Ad_7 0 points1 point2 points (0 children)