import pandas as pd
from pandas_datareader import data
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
Electronic Production in India β Data Analysis and VisualizationΒΆ
This project analyzes Indiaβs electronic production data (mobile handsets, consumer electronics, etc.) across multiple years. It demonstrates loading CSV data with a custom index, transposing wide-format DataFrames for time-series analysis, exporting to Excel with pd.ExcelWriter, and creating interactive bar charts with Plotly alongside static Matplotlib line plots.
Why this matters: Government and industry production data is often published in wide format (one column per year), which requires transposition before time-series visualization. This project teaches a common real-world data reshaping pattern and shows how to combine Pandas with both static (Matplotlib) and interactive (Plotly) visualization libraries for different audiences.
production = pd.read_csv("mobile_2.csv")
production_idx = pd.read_csv("mobile_2.csv", index_col="Item", parse_dates=True)
production_idx
production_t = production_idx.transpose()
production_t
path = r"mobile_t.xlsx"
writer = pd.ExcelWriter(path, engine = 'xlsxwriter')
production_t.to_excel(writer)
writer.save()
writer.close()
type(production_t)
import plotly
from plotly.graph_objs import Scatter, Layout
import plotly.graph_objs as go
literate = [go.Bar(x=production_t.index, y=production_t["Mobile Handsets"])]
plotly.offline.plot({ 'data': literate,
'layout': {
'title': 'POPULATION LITERACY RATE IN TN',
'xaxis': {
'title': 'YEAR'},
'yaxis': {
'title': 'POPULATION (in lakhs) '}
}})
plt.style.use("ggplot")
production.plot(x="Item")
production_idx.plot()