Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Science Challenge: Analyzing Customer Purchase Patterns

Status
Not open for further replies.

soni21

Programmer
Apr 25, 2023
9
0
0
IN
I'm working on a data science project where I have a dataset of customer transactions and I need to analyze customer purchase patterns using Python. The dataset includes the following columns: customer_id, transaction_date, product_id, quantity, and price.

Here's a simplified version of the data:

Code:
import pandas as pd

data = {
    'customer_id': [101, 102, 101, 103, 102, 104],
    'transaction_date': ['2023-01-15', '2023-02-10', '2023-02-25', '2023-03-05', '2023-03-12', '2023-03-20'],
    'product_id': [1, 2, 1, 3, 2, 1],
    'quantity': [2, 1, 3, 2, 1, 4],
    'price': [20.0, 30.0, 25.0, 40.0, 30.0, 15.0]
}

df = pd.DataFrame(data)

I want to perform the following analyses using Python:

[ol ]
[li]Total Sales: Calculate the total sales revenue for each customer.[/li]
[li][/li]
[li]Purchase Frequency: Determine how often each customer makes a purchase.[/li]
[li][/li]
[li]Most Popular Products: Identify the top 3 most purchased products.[/li]
[li][/li]
[li]Customer Retention: Analyze customer retention by calculating the percentage of customers who make repeat purchases within 30 days.[/li]
[/ol]

Could you provide Python code examples and explanations for each of these analyses using the provided dataset? Thank you for your assistance in analyzing these customer purchase patterns!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top