Skip to content

Commit 8b78131

Browse files
committed
Update 1068. Product Sales Analysis I.py
1 parent e4f2ac9 commit 8b78131

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import pandas as pd
2+
3+
# Sample Data
4+
sales_data = {'sale_id': [1, 2, 7],
5+
'product_id': [100, 100, 200],
6+
'year': [2008, 2009, 2011],
7+
'quantity': [10, 12, 15],
8+
'price': [5000, 5000, 9000]}
9+
10+
product_data = {'product_id': [100, 200, 300],
11+
'product_name': ['Nokia', 'Apple', 'Samsung']}
12+
13+
# Create DataFrames
14+
sales_df = pd.DataFrame(sales_data)
15+
product_df = pd.DataFrame(product_data)
16+
17+
# Perform Join
18+
result = sales_df.merge(product_df, on='product_id')[['product_name', 'year', 'price']]
19+
20+
print(result)

0 commit comments

Comments
 (0)