iPhone Sales Analysis using Python : Understanding the Indian Market

Abhishek Pawar
5 min readJul 31, 2023

--

The Indian smartphone market has witnessed exponential growth over the past decade, with a significant surge in iPhone sales. As one of the world’s largest and most diverse markets, understanding the dynamics of iPhone sales in India is crucial for both Apple and investors. In this article, we will explore how Python, a powerful programming language, can be utilized to conduct a comprehensive analysis of iPhone sales data, helping us gain valuable insights into consumer preferences, market trends, and potential growth opportunities.

Let’s start

To conduct a comprehensive analysis of iPhone sales in the Indian market, lets use this well-curated dataset from Kaggle. This dataset contains valuable information about the sales of iPhones in India & with this rich dataset at our disposal, we can delve into the data and extract meaningful insights into consumer behavior, market trends, and potential growth opportunities.

Once the dataset is downloaded, we will install the necessary libraries for analysis -

# iPhone Sales Analysis

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import plotly.express as px
import plotly.graph_objects as go

data = pd.read_csv("apple_products.csv")
print(data.head())
#Below code if the file is stored in different path -

data = pd.read_csv("D:/DataAnalytics/apple_products.csv")
print(data.head())
Product Name  \
0 APPLE iPhone 8 Plus (Gold, 64 GB)
1 APPLE iPhone 8 Plus (Space Grey, 256 GB)
2 APPLE iPhone 8 Plus (Silver, 256 GB)
3 APPLE iPhone 8 (Silver, 256 GB)
4 APPLE iPhone 8 (Gold, 256 GB)

Product URL Brand Sale Price \
0 https://www.flipkart.com/apple-iphone-8-plus-g... Apple 49900
1 https://www.flipkart.com/apple-iphone-8-plus-s... Apple 84900
2 https://www.flipkart.com/apple-iphone-8-plus-s... Apple 84900
3 https://www.flipkart.com/apple-iphone-8-silver... Apple 77000
4 https://www.flipkart.com/apple-iphone-8-gold-2... Apple 77000

Mrp Discount Percentage Number Of Ratings Number Of Reviews \
0 49900 0 3431 356
1 84900 0 3431 356
2 84900 0 3431 356
3 77000 0 11202 794
4 77000 0 11202 794

Upc Star Rating Ram
0 MOBEXRGV7EHHTGUH 4.6 2 GB
1 MOBEXRGVAC6TJT4F 4.6 2 GB
2 MOBEXRGVGETABXWZ 4.6 2 GB
3 MOBEXRGVMZWUHCBA 4.5 2 GB
4 MOBEXRGVPK7PFEJZ 4.5 2 GB

Before moving ahead, lets check whether the dataset contains any null values -

#examining whether the data contains any null values
print(data.isnull().sum())
Product Name           0
Product URL 0
Brand 0
Sale Price 0
Mrp 0
Discount Percentage 0
Number Of Ratings 0
Number Of Reviews 0
Upc 0
Star Rating 0
Ram 0
dtype: int64

Null values are not present in the dataset. Let’s now examine the descriptive statistics for the data -

print(data.describe())
Sale Price            Mrp  Discount Percentage  Number Of Ratings  \
count 62.000000 62.000000 62.000000 62.000000
mean 80073.887097 88058.064516 9.951613 22420.403226
std 34310.446132 34728.825597 7.608079 33768.589550
min 29999.000000 39900.000000 0.000000 542.000000
25% 49900.000000 54900.000000 6.000000 740.000000
50% 75900.000000 79900.000000 10.000000 2101.000000
75% 117100.000000 120950.000000 14.000000 43470.000000
max 140900.000000 149900.000000 29.000000 95909.000000

Number Of Reviews Star Rating
count 62.000000 62.000000
mean 1861.677419 4.575806
std 2855.883830 0.059190
min 42.000000 4.500000
25% 64.000000 4.500000
50% 180.000000 4.600000
75% 3331.000000 4.600000
max 8161.000000 4.700000

India iPhone Sales Analysis

Now I’m going to establish a new dataframe(df) and store all the information about the top 10 iPhones in India according to Flipkart reviews. It will be easier to comprehend which model of iPhones are most popular in India if you know this -

top_rated = data.sort_values(by=["Star Rating"], 
ascending=False)
top_rated = top_rated.head(10)
print(top_rated['Product Name'])
20     APPLE iPhone 11 Pro Max (Midnight Green, 64 GB)
17 APPLE iPhone 11 Pro Max (Space Grey, 64 GB)
16 APPLE iPhone 11 Pro Max (Midnight Green, 256 GB)
15 APPLE iPhone 11 Pro Max (Gold, 64 GB)
14 APPLE iPhone 11 Pro Max (Gold, 256 GB)
0 APPLE iPhone 8 Plus (Gold, 64 GB)
29 APPLE iPhone 12 (White, 128 GB)
32 APPLE iPhone 12 Pro Max (Graphite, 128 GB)
35 APPLE iPhone 12 (Black, 128 GB)
36 APPLE iPhone 12 (Blue, 128 GB)
Name: Product Name, dtype: object

These are India’s top 5 most popular iPhones, as determined by the data above -

APPLE iPhone 11 Pro Max (Midnight Green, 64 GB)
APPLE iPhone 11 Pro Max (Space Grey, 64 GB)
APPLE iPhone 11 Pro Max (Midnight Green, 256 GB)
APPLE iPhone 11 Pro Max (Gold, 64 GB)
APPLE iPhone 11 Pro Max (Gold, 256 GB)

Let’s now examine the amount of reviews for the top-rated iPhones on Flipkart -

iphones = top_rated["Product Name"].value_counts()
label = iphones.index
counts = top_rated["Number Of Ratings"]
figure = px.bar(top_rated, x=label, y=counts,
title="Number of Ratings of Top-Rated iPhones in India")
figure.update_layout(
xaxis_title="iPhone Model",
yaxis_title="Number of Ratings",
xaxis_tickangle=45,
)
figure.show()

APPLE iPhone 8 Plus (Gold, 64 GB) has the highest rating on Flipkart, as shown in the above bar graph. Let’s now examine the number of reviews for the iPhones with the highest ratings on Flipkart -

iphones = top_rated["Product Name"].value_counts()
label = iphones.index
counts = top_rated["Number Of Reviews"]
fig = px.bar(top_rated, x=label, y=counts,
title="Number of Reviews for Top-Rated iPhones in India")
fig.update_layout(
xaxis_title="iPhone Model",
yaxis_title="Number of Reviews",
xaxis_tickangle=45,
)
fig.show()

Among the highest-rated iPhones in India, the APPLE iPhone 8 Plus (Gold, 64 GB) has the most reviews on Flipkart. Let’s now examine the correlation between iPhone sale prices and customer reviews on Flipkart -

figure = px.scatter(data_frame=data, x="Number Of Ratings",
y="Sale Price", size="Discount Percentage",
trendline="ols",
title="Relationship between Sale Price and Number of Ratings of iPhones in India")
figure.update_layout(
xaxis_title="Number Of Ratings",
yaxis_title="Sale Price (INR)",
)
figure.show()

Here, the number of ratings and the price of iPhones have a negative linear connection. It implies that more iPhones are sold in India at lower sale prices.

Conclusion

So, using Python programming, this is how you may examine the sales of iPhones in India. Following are the key insights from this article about iPhone sales in India:

1. The most popular iPhone in India was the APPLE iPhone 8 Plus (Gold, 64 GB).
2. In India, iPhones with reduced sale prices are more popular.
3. In India, more iPhones are sold at steep discounts.

I hope you enjoyed reading this post on using Python to analyze iPhone sales. Please feel free to post insightful queries in the comments section below.

--

--

Abhishek Pawar
0 Followers

Data Analyst, SQL, Python, data visualization, Passionate about uncovering insights from complex datasets & Drive data-driven decisions