0% found this document useful (0 votes)
5 views28 pages

Quality Control and Data Analysis in Python

The document outlines a series of lab sessions focused on quality checks, data processing, and data visualization using Python libraries such as Pandas, Seaborn, and Matplotlib. It includes various tasks such as checking rod strength, shaft diameters, component hardness, and performing data cleaning and encoding techniques. Additionally, it demonstrates plotting techniques and scaling methods for data analysis.

Uploaded by

Ayaan Ayan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views28 pages

Quality Control and Data Analysis in Python

The document outlines a series of lab sessions focused on quality checks, data processing, and data visualization using Python libraries such as Pandas, Seaborn, and Matplotlib. It includes various tasks such as checking rod strength, shaft diameters, component hardness, and performing data cleaning and encoding techniques. Additionally, it demonstrates plotting techniques and scaling methods for data analysis.

Uploaded by

Ayaan Ayan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import seaborn as sns

import numpy as np
import pandas as pd
from [Link] import LabelEncoder, OneHotEncoder,
OrdinalEncoder
import [Link] as px

Lab session 1

minimum_strength = 250
passed = 0
failed = 0

# Sample data for 10 rods


rod_strengths = [245, 255, 260, 230, 250, 290, 210, 300, 275, 240]

print("Starting Quality Check...")

for strength in rod_strengths:


if strength >= minimum_strength:
print(f"Strength {strength} MPa: Pass")
passed = passed + 1
else:
print(f"Strength {strength} MPa: Fail")
failed = failed + 1

print("Summary:")
print("Total Passed:", passed)
print("Total Failed:", failed)

Starting Quality Check...


Strength 245 MPa: Fail
Strength 255 MPa: Pass
Strength 260 MPa: Pass
Strength 230 MPa: Fail
Strength 250 MPa: Pass
Strength 290 MPa: Pass
Strength 210 MPa: Fail
Strength 300 MPa: Pass
Strength 275 MPa: Pass
Strength 240 MPa: Fail
Summary:
Total Passed: 6
Total Failed: 4

Lab session 2

pass_count = 0
fail_count = 0
for i in range(1, 6):
diameter = float(input(f"Enter diameter of shaft {i} (mm): "))

if 49 <= diameter <= 51:


print("Within Tolerance")
pass_count += 1
else:
print("Out of Tolerance")
fail_count += 1

print("Total shafts within tolerance:", pass_count)


print("Total shafts out of tolerance:", fail_count)

Out of Tolerance
Out of Tolerance
Within Tolerance
Within Tolerance
Out of Tolerance
Total shafts within tolerance: 2
Total shafts out of tolerance: 3

Lab Session 3

def check_hardness(value):
# Returns Pass if valid, else Fail
if 150 <= value <= 200:
print("Pass")
return True
else:
print("Fail")
return False

# Main program
num_components = int(input("How many components to test? "))

pass_total = 0
fail_total = 0

for k in range(num_components):
hb_val = float(input("Enter hardness value: "))

# Calling the function


if check_hardness(hb_val):
pass_total += 1
else:
fail_total += 1

print("Final Results:")
print("Total tested:", num_components)
print("Passed:", pass_total)
print("Failed:", fail_total)

Pass
Fail
Fail
Fail
Fail
Fail
Fail
Fail
Fail
Fail
Fail

----------------------------------------------------------------------
-----
ValueError Traceback (most recent call
last)
Cell In[9], line 17
14 fail_total = 0
16 for k in range(num_components):
---> 17 hb_val = float(input("Enter hardness value: "))
19 # Calling the function
20 if check_hardness(hb_val):

ValueError: could not convert string to float: ''

Lab session 4

# Take single-line input and convert to NumPy array


diameters = [Link](
list(map(float, input("Enter 12 shaft diameters (space-separated):
").split()))
)

# Boolean mask for tolerance check


tolerance_mask = (diameters >= 49) & (diameters <= 51)

# Labels using [Link] (no loops)


labels = [Link](tolerance_mask, "Within Tolerance", "Out of
Tolerance")

# Display results using NumPy functions only


print("\nResults for each shaft:")
print(labels)

print("\nSummary:")
print("Total shafts tested:", [Link])
print("Number within tolerance:", [Link](tolerance_mask))
print("Number out of tolerance:", [Link](~tolerance_mask))
print("Indices of out-of-tolerance shafts:", [Link](~tolerance_mask)
[0])

# Basic statistics using NumPy


print("\nStatistics:")
print("Mean diameter:", [Link](diameters))
print("Standard deviation (sample):", [Link](diameters, ddof=1))
print("Minimum diameter:", [Link](diameters))
print("Maximum diameter:", [Link](diameters))

Lab session 5

# Load 'tips' dataset


df = sns.load_dataset('tips')

print("Original Data Info:")


print([Link]())
print([Link]())

initial_rows = len(df)

# Drop missing values if any


df = [Link]()

# Feature Engineering: Add a 'per_person' cost column


df['cost_per_person'] = df['total_bill'] / df['size']

# Filter: Keep only where total bill is greater than $15


df_filtered = df[df['total_bill'] > 15]

# Save to Excel
df_filtered.to_excel("cleaned_tips.xlsx", index=False)
print("\nFile saved as cleaned_tips.xlsx")

# Read it back to verify


df_check = pd.read_excel("cleaned_tips.xlsx")

print("Processing Report")
print(f"Rows before: {initial_rows}")
print(f"Rows after filtering: {len(df_filtered)}")

Original Data Info:


<class '[Link]'>
RangeIndex: 244 entries, 0 to 243
Data columns (total 7 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 total_bill 244 non-null float64
1 tip 244 non-null float64
2 sex 244 non-null category
3 smoker 244 non-null category
4 day 244 non-null category
5 time 244 non-null category
6 size 244 non-null int64
dtypes: category(4), float64(2), int64(1)
memory usage: 7.4 KB
None
total_bill tip sex smoker day time size
0 16.99 1.01 Female No Sun Dinner 2
1 10.34 1.66 Male No Sun Dinner 3
2 21.01 3.50 Male No Sun Dinner 3
3 23.68 3.31 Male No Sun Dinner 2
4 24.59 3.61 Female No Sun Dinner 4

----------------------------------------------------------------------
-----
ModuleNotFoundError Traceback (most recent call
last)
Cell In[13], line 24
21 df_filtered = df[df['total_bill'] > 15]
23 # Save to Excel
---> 24 df_filtered.to_excel("cleaned_tips.xlsx", index=False)
25 print("\nFile saved as cleaned_tips.xlsx")
27 # Read it back to verify

File c:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-
packages\pandas\util\_decorators.py:333, in
deprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper(*arg
s, **kwargs)
327 if len(args) > num_allow_args:
328 [Link](
329
[Link](arguments=_format_argument_list(allow_args)),
330 FutureWarning,
331 stacklevel=find_stack_level(),
332 )
--> 333 return func(*args, **kwargs)

File c:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-
packages\pandas\core\[Link], in NDFrame.to_excel(self,
excel_writer, sheet_name, na_rep, float_format, columns, header,
index, index_label, startrow, startcol, engine, merge_cells, inf_rep,
freeze_panes, storage_options, engine_kwargs)
2423 from [Link] import ExcelFormatter
2425 formatter = ExcelFormatter(
2426 df,
2427 na_rep=na_rep,
(...) 2434 inf_rep=inf_rep,
2435 )
-> 2436 [Link](
2437 excel_writer,
2438 sheet_name=sheet_name,
2439 startrow=startrow,
2440 startcol=startcol,
2441 freeze_panes=freeze_panes,
2442 engine=engine,
2443 storage_options=storage_options,
2444 engine_kwargs=engine_kwargs,
2445 )

File c:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-
packages\pandas\io\formats\[Link], in [Link](self,
writer, sheet_name, startrow, startcol, freeze_panes, engine,
storage_options, engine_kwargs)
941 need_save = False
942 else:
--> 943 writer = ExcelWriter(
944 writer,
945 engine=engine,
946 storage_options=storage_options,
947 engine_kwargs=engine_kwargs,
948 )
949 need_save = True
951 try:

File c:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-
packages\pandas\io\excel\_openpyxl.py:57, in
OpenpyxlWriter.__init__(self, path, engine, date_format,
datetime_format, mode, storage_options, if_sheet_exists,
engine_kwargs, **kwargs)
44 def __init__(
45 self,
46 path: FilePath | WriteExcelBuffer | ExcelWriter,
(...) 55 ) -> None:
56 # Use the openpyxl module as the Excel writer.
---> 57 from [Link] import Workbook
59 engine_kwargs = combine_kwargs(engine_kwargs, kwargs)
61 super().__init__(
62 path,
63 mode=mode,
(...) 66 engine_kwargs=engine_kwargs,
67 )

ModuleNotFoundError: No module named 'openpyxl'

Lab session 6
# Lab 6: Plotting with Seaborn and Matplotlib
import seaborn as sns
import [Link] as plt

# Load standard datasets


iris = sns.load_dataset('iris')
tips = sns.load_dataset('tips')

# 1. Line Chart
[Link](data=tips, x="size", y="total_bill")
[Link]("Bill vs Party Size")
[Link]("[Link]")
[Link]()

# 2. Scatter Plot
[Link](data=iris, x="sepal_length", y="petal_width",
hue="species")
[Link]("Sepal Length vs Petal Width")
[Link]("[Link]")
[Link]()

# 3. Boxplot
[Link](x="day", y="total_bill", data=tips)
[Link]("Bill Distribution by Day")
[Link]("[Link]")
[Link]()

# 4. Histogram
[Link](tips['tip'], bins=10)
[Link]("Tip Frequency")
[Link]("[Link]")
[Link]()

# 5. Pie Chart
counts = tips['sex'].value_counts()
[Link](counts, labels=[Link], autopct='%1.1f%%')
[Link]("Gender Ratio")
[Link]("[Link]")
[Link]()

# 6. Bar Chart
[Link](x="day", y="total_bill", data=tips)
[Link]("Avg Bill by Day")
[Link]("[Link]")
[Link]()
Lab Session 7

data = {
'Gender': ['Male', 'Female', 'Female', 'Male', 'Male'],
'City': ['Lahore', 'Karachi', 'Islamabad', 'Lahore', 'Karachi'],
'Education': ['Matric', 'Bachelor', 'Master', 'Intermediate',
'Bachelor']
}
df = [Link](data)

print("Original DataFrame:")
print(df)

# 1. Label Encoding for 'Gender'


le = LabelEncoder()
df['Gender_Encoded'] = le.fit_transform(df['Gender'])

# 2. Ordinal Encoding for 'Education'


# Order: Matric < Intermediate < Bachelor < Master
education_order = [['Matric', 'Intermediate', 'Bachelor', 'Master']]
oe = OrdinalEncoder(categories=education_order)
df['Education_Encoded'] = oe.fit_transform(df[['Education']])
# 3. One-Hot Encoding for 'City'
# We use pandas get_dummies for easier visualization,
# but sklearn OneHotEncoder is also valid.
df_one_hot = pd.get_dummies(df['City'], prefix='City').astype(int)
df_final = [Link]([df, df_one_hot], axis=1)

print("\nEncoded DataFrame:")
print(df_final[['Gender', 'Gender_Encoded', 'Education',
'Education_Encoded']])
print("\nOne-Hot Encoded Cities:")
print(df_final.filter(like='City_'))

Original DataFrame:
Gender City Education
0 Male Lahore Matric
1 Female Karachi Bachelor
2 Female Islamabad Master
3 Male Lahore Intermediate
4 Male Karachi Bachelor

Encoded DataFrame:
Gender Gender_Encoded Education Education_Encoded
0 Male 1 Matric 0.0
1 Female 0 Bachelor 2.0
2 Female 0 Master 3.0
3 Male 1 Intermediate 1.0
4 Male 1 Bachelor 2.0

One-Hot Encoded Cities:


City_Islamabad City_Karachi City_Lahore
0 0 0 1
1 0 1 0
2 1 0 0
3 0 0 1
4 0 1 0

Lab session 8

import pandas as pd
from [Link] import MinMaxScaler, StandardScaler,
RobustScaler

# Sample data
data = {
'Age': [20, 30, 45, 55, 22],
'Income': [40000, 85000, 120000, 160000, 42000],
'Spending': [200, 500, 1200, 800, 2500] # 2500 is an outlier
}
df = [Link](data)
# Min-Max Scaling
scaler1 = MinMaxScaler()
df_mm = [Link](scaler1.fit_transform(df), columns=[Link])
print("MinMax Result:\n", df_mm.head())

# Standard Scaling (Z-Score)


scaler2 = StandardScaler()
df_std = [Link](scaler2.fit_transform(df), columns=[Link])
print("\nStandardized Result:\n", df_std.head())

# Robust Scaling
scaler3 = RobustScaler()
df_rob = [Link](scaler3.fit_transform(df), columns=[Link])
print("\nRobust Result:\n", df_rob.head())

MinMax Result:
Age Income Spending
0 0.000000 0.000000 0.000000
1 0.285714 0.375000 0.130435
2 0.714286 0.666667 0.434783
3 1.000000 1.000000 0.260870
4 0.057143 0.016667 1.000000

Standardized Result:
Age Income Spending
0 -1.063201 -1.071526 -1.048037
1 -0.324867 -0.095440 -0.673738
2 0.782634 0.663738 0.199626
3 1.520968 1.531370 -0.299439
4 -0.915534 -1.028144 1.821588

Robust Result:
Age Income Spending
0 -0.434783 -0.576923 -0.857143
1 0.000000 0.000000 -0.428571
2 0.652174 0.448718 0.571429
3 1.086957 0.961538 0.000000
4 -0.347826 -0.551282 2.428571

Lab Session 9

# Sample Dataset
data = {
'Country': ['Pak', 'Ind', 'chn', 'USA', 'UK'],
'Population': [220, 1380, 1400, 330, 67], # in millions
'GDP': [300, 2600, 14000, 23000, 3100], # in billion USD
'Life_Expectancy': [67, 69, 77, 79, 81],
'Continent': ['Asia', 'Asia', 'Asia', 'America', 'Europe']
}
df = [Link](data)
# 1. Bar Chart (GDP by Country)
fig1 = [Link](df, x='Country', y='GDP', title="GDP by Country",
color='Continent')
[Link]()

# 2. Scatter Plot (GDP vs Life Expectancy, size based on Population)


fig2 = [Link](df, x='GDP', y='Life_Expectancy', size='Population',

color='Country', title="GDP vs Life Expectancy",


hover_name='Country')
[Link]()

# 3. Pie Chart (Population Distribution)


fig3 = [Link](df, values='Population', names='Country',
title="Population Share")
[Link]()

# 4. Line Chart (Simulated trend)


# Just sorting by GDP to show a line
df_sorted = df.sort_values('GDP')
fig4 = [Link](df_sorted, x='Country', y='GDP', title="GDP Trend
(Sorted)")
[Link]()

{"config":{"plotlyServerURL":"[Link]
[{"hovertemplate":"Continent=Asia<br>Country=%{x}<br>GDP=%
{y}<extra></extra>","legendgroup":"Asia","marker":
{"color":"#636efa","pattern":
{"shape":""}},"name":"Asia","orientation":"v","showlegend":true,"textp
osition":"auto","type":"bar","x":["Pak","Ind","chn"],"xaxis":"x","y":
{"bdata":"LAEoCrA2","dtype":"i2"},"yaxis":"y"},
{"hovertemplate":"Continent=America<br>Country=%{x}<br>GDP=%
{y}<extra></extra>","legendgroup":"America","marker":
{"color":"#EF553B","pattern":
{"shape":""}},"name":"America","orientation":"v","showlegend":true,"te
xtposition":"auto","type":"bar","x":["USA"],"xaxis":"x","y":
{"bdata":"2Fk=","dtype":"i2"},"yaxis":"y"},
{"hovertemplate":"Continent=Europe<br>Country=%{x}<br>GDP=%
{y}<extra></extra>","legendgroup":"Europe","marker":
{"color":"#00cc96","pattern":
{"shape":""}},"name":"Europe","orientation":"v","showlegend":true,"tex
tposition":"auto","type":"bar","x":["UK"],"xaxis":"x","y":
{"bdata":"HAw=","dtype":"i2"},"yaxis":"y"}],"layout":
{"barmode":"relative","legend":{"title":
{"text":"Continent"},"tracegroupgap":0},"template":{"data":{"bar":
[{"error_x":{"color":"#2a3f5f"},"error_y":
{"color":"#2a3f5f"},"marker":{"line":
{"color":"#E5ECF6","width":0.5},"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpo
lar":[{"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"
carpet":[{"aaxis":
{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","min
orgridcolor":"white","startlinecolor":"#2a3f5f"},"baxis":
{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","min
orgridcolor":"white","startlinecolor":"#2a3f5f"},"type":"carpet"}],"ch
oropleth":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"heatmap"}],"histogram":[{"marker":{"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],
"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":
{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":
[{"automargin":true,"type":"pie"}],"scatter":[{"fillpattern":
{"fillmode":"overlay","size":10,"solidity":0.2},"type":"scatter"}],"sc
atter3d":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":
{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattergl"}],"scattermap":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattermap"}],"scattermapbox":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar"
:[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl
":[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterterna
ry":[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":
{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":
{"color":"#C8D4E3"},"line":
{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":
{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"autotypenumbers
":"strict","coloraxis":{"colorbar":
{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":
[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],
[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],
[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"sequentialminus":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],[1,"#f0f921"]]},"colorway":
["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692"
,"#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"geo":
{"bgcolor":"white","lakecolor":"white","landcolor":"#E5ECF6","showlake
s":true,"showland":true,"subunitcolor":"white"},"hoverlabel":
{"align":"left"},"hovermode":"closest","mapbox":
{"style":"light"},"paper_bgcolor":"white","plot_bgcolor":"#E5ECF6","po
lar":{"angularaxis":
{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF
6","radialaxis":
{"gridcolor":"white","linecolor":"white","ticks":""}},"scene":
{"xaxis":
{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"lineco
lor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}
,"yaxis":
{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"lineco
lor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}
,"zaxis":
{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"lineco
lor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}
},"shapedefaults":{"line":{"color":"#2a3f5f"}},"ternary":{"aaxis":
{"gridcolor":"white","linecolor":"white","ticks":""},"baxis":
{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF
6","caxis":
{"gridcolor":"white","linecolor":"white","ticks":""}},"title":
{"x":5.0e-2},"xaxis":
{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"",
"title":
{"standoff":15},"zerolinecolor":"white","zerolinewidth":2},"yaxis":
{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"",
"title":
{"standoff":15},"zerolinecolor":"white","zerolinewidth":2}}},"title":
{"text":"GDP by Country"},"xaxis":{"anchor":"y","domain":
[0,1],"title":{"text":"Country"}},"yaxis":{"anchor":"x","domain":
[0,1],"title":{"text":"GDP"}}}}

{"config":{"plotlyServerURL":"[Link]
[{"hovertemplate":"<b>%{hovertext}</b><br><br>Country=Pak<br>GDP=%
{x}<br>Life_Expectancy=%{y}<br>Population=%{[Link]}<extra></
extra>","hovertext":["Pak"],"legendgroup":"Pak","marker":
{"color":"#636efa","size":
{"bdata":"3AA=","dtype":"i2"},"sizemode":"area","sizeref":3.5,"symbol"
:"circle"},"mode":"markers","name":"Pak","orientation":"v","showlegend
":true,"type":"scatter","x":
{"bdata":"LAE=","dtype":"i2"},"xaxis":"x","y":
{"bdata":"Qw==","dtype":"i1"},"yaxis":"y"},{"hovertemplate":"<b>%
{hovertext}</b><br><br>Country=Ind<br>GDP=%{x}<br>Life_Expectancy=%
{y}<br>Population=%{[Link]}<extra></extra>","hovertext":
["Ind"],"legendgroup":"Ind","marker":{"color":"#EF553B","size":
{"bdata":"ZAU=","dtype":"i2"},"sizemode":"area","sizeref":3.5,"symbol"
:"circle"},"mode":"markers","name":"Ind","orientation":"v","showlegend
":true,"type":"scatter","x":
{"bdata":"KAo=","dtype":"i2"},"xaxis":"x","y":
{"bdata":"RQ==","dtype":"i1"},"yaxis":"y"},{"hovertemplate":"<b>%
{hovertext}</b><br><br>Country=chn<br>GDP=%{x}<br>Life_Expectancy=%
{y}<br>Population=%{[Link]}<extra></extra>","hovertext":
["chn"],"legendgroup":"chn","marker":{"color":"#00cc96","size":
{"bdata":"eAU=","dtype":"i2"},"sizemode":"area","sizeref":3.5,"symbol"
:"circle"},"mode":"markers","name":"chn","orientation":"v","showlegend
":true,"type":"scatter","x":
{"bdata":"sDY=","dtype":"i2"},"xaxis":"x","y":
{"bdata":"TQ==","dtype":"i1"},"yaxis":"y"},{"hovertemplate":"<b>%
{hovertext}</b><br><br>Country=USA<br>GDP=%{x}<br>Life_Expectancy=%
{y}<br>Population=%{[Link]}<extra></extra>","hovertext":
["USA"],"legendgroup":"USA","marker":{"color":"#ab63fa","size":
{"bdata":"SgE=","dtype":"i2"},"sizemode":"area","sizeref":3.5,"symbol"
:"circle"},"mode":"markers","name":"USA","orientation":"v","showlegend
":true,"type":"scatter","x":
{"bdata":"2Fk=","dtype":"i2"},"xaxis":"x","y":
{"bdata":"Tw==","dtype":"i1"},"yaxis":"y"},{"hovertemplate":"<b>%
{hovertext}</b><br><br>Country=UK<br>GDP=%{x}<br>Life_Expectancy=%
{y}<br>Population=%{[Link]}<extra></extra>","hovertext":
["UK"],"legendgroup":"UK","marker":{"color":"#FFA15A","size":
{"bdata":"Qw==","dtype":"i1"},"sizemode":"area","sizeref":3.5,"symbol"
:"circle"},"mode":"markers","name":"UK","orientation":"v","showlegend"
:true,"type":"scatter","x":
{"bdata":"HAw=","dtype":"i2"},"xaxis":"x","y":
{"bdata":"UQ==","dtype":"i1"},"yaxis":"y"}],"layout":{"legend":
{"itemsizing":"constant","title":
{"text":"Country"},"tracegroupgap":0},"template":{"data":{"bar":
[{"error_x":{"color":"#2a3f5f"},"error_y":
{"color":"#2a3f5f"},"marker":{"line":
{"color":"#E5ECF6","width":0.5},"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpo
lar":[{"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"
carpet":[{"aaxis":
{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","min
orgridcolor":"white","startlinecolor":"#2a3f5f"},"baxis":
{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","min
orgridcolor":"white","startlinecolor":"#2a3f5f"},"type":"carpet"}],"ch
oropleth":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"heatmap"}],"histogram":[{"marker":{"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],
"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":
{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":
[{"automargin":true,"type":"pie"}],"scatter":[{"fillpattern":
{"fillmode":"overlay","size":10,"solidity":0.2},"type":"scatter"}],"sc
atter3d":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":
{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattergl"}],"scattermap":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattermap"}],"scattermapbox":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar"
:[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl
":[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterterna
ry":[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":
{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":
{"color":"#C8D4E3"},"line":
{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":
{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"autotypenumbers
":"strict","coloraxis":{"colorbar":
{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":
[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],
[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],
[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"sequentialminus":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],[1,"#f0f921"]]},"colorway":
["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692"
,"#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"geo":
{"bgcolor":"white","lakecolor":"white","landcolor":"#E5ECF6","showlake
s":true,"showland":true,"subunitcolor":"white"},"hoverlabel":
{"align":"left"},"hovermode":"closest","mapbox":
{"style":"light"},"paper_bgcolor":"white","plot_bgcolor":"#E5ECF6","po
lar":{"angularaxis":
{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF
6","radialaxis":
{"gridcolor":"white","linecolor":"white","ticks":""}},"scene":
{"xaxis":
{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"lineco
lor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}
,"yaxis":
{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"lineco
lor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}
,"zaxis":
{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"lineco
lor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}
},"shapedefaults":{"line":{"color":"#2a3f5f"}},"ternary":{"aaxis":
{"gridcolor":"white","linecolor":"white","ticks":""},"baxis":
{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF
6","caxis":
{"gridcolor":"white","linecolor":"white","ticks":""}},"title":
{"x":5.0e-2},"xaxis":
{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"",
"title":
{"standoff":15},"zerolinecolor":"white","zerolinewidth":2},"yaxis":
{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"",
"title":
{"standoff":15},"zerolinecolor":"white","zerolinewidth":2}}},"title":
{"text":"GDP vs Life Expectancy"},"xaxis":{"anchor":"y","domain":
[0,1],"title":{"text":"GDP"}},"yaxis":{"anchor":"x","domain":
[0,1],"title":{"text":"Life_Expectancy"}}}}

{"config":{"plotlyServerURL":"[Link]
{"x":[0,1],"y":[0,1]},"hovertemplate":"Country=%{label}<br>Population=
%{value}<extra></extra>","labels":
["Pak","Ind","chn","USA","UK"],"legendgroup":"","name":"","showlegend"
:true,"type":"pie","values":
{"bdata":"3ABkBXgFSgFDAA==","dtype":"i2"}}],"layout":{"legend":
{"tracegroupgap":0},"template":{"data":{"bar":[{"error_x":
{"color":"#2a3f5f"},"error_y":{"color":"#2a3f5f"},"marker":{"line":
{"color":"#E5ECF6","width":0.5},"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpo
lar":[{"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"
carpet":[{"aaxis":
{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","min
orgridcolor":"white","startlinecolor":"#2a3f5f"},"baxis":
{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","min
orgridcolor":"white","startlinecolor":"#2a3f5f"},"type":"carpet"}],"ch
oropleth":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"heatmap"}],"histogram":[{"marker":{"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],
"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":
{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":
[{"automargin":true,"type":"pie"}],"scatter":[{"fillpattern":
{"fillmode":"overlay","size":10,"solidity":0.2},"type":"scatter"}],"sc
atter3d":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":
{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattergl"}],"scattermap":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattermap"}],"scattermapbox":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar"
:[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl
":[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterterna
ry":[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":
{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":
{"color":"#C8D4E3"},"line":
{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":
{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"autotypenumbers
":"strict","coloraxis":{"colorbar":
{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":
[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],
[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],
[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"sequentialminus":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],[1,"#f0f921"]]},"colorway":
["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692"
,"#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"geo":
{"bgcolor":"white","lakecolor":"white","landcolor":"#E5ECF6","showlake
s":true,"showland":true,"subunitcolor":"white"},"hoverlabel":
{"align":"left"},"hovermode":"closest","mapbox":
{"style":"light"},"paper_bgcolor":"white","plot_bgcolor":"#E5ECF6","po
lar":{"angularaxis":
{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF
6","radialaxis":
{"gridcolor":"white","linecolor":"white","ticks":""}},"scene":
{"xaxis":
{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"lineco
lor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}
,"yaxis":
{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"lineco
lor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}
,"zaxis":
{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"lineco
lor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}
},"shapedefaults":{"line":{"color":"#2a3f5f"}},"ternary":{"aaxis":
{"gridcolor":"white","linecolor":"white","ticks":""},"baxis":
{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF
6","caxis":
{"gridcolor":"white","linecolor":"white","ticks":""}},"title":
{"x":5.0e-2},"xaxis":
{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"",
"title":
{"standoff":15},"zerolinecolor":"white","zerolinewidth":2},"yaxis":
{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"",
"title":
{"standoff":15},"zerolinecolor":"white","zerolinewidth":2}}},"title":
{"text":"Population Share"}}}

{"config":{"plotlyServerURL":"[Link]
[{"hovertemplate":"Country=%{x}<br>GDP=%{y}<extra></
extra>","legendgroup":"","line":
{"color":"#636efa","dash":"solid"},"marker":
{"symbol":"circle"},"mode":"lines","name":"","orientation":"v","showle
gend":false,"type":"scatter","x":
["Pak","Ind","UK","chn","USA"],"xaxis":"x","y":
{"bdata":"LAEoChwMsDbYWQ==","dtype":"i2"},"yaxis":"y"}],"layout":
{"legend":{"tracegroupgap":0},"template":{"data":{"bar":[{"error_x":
{"color":"#2a3f5f"},"error_y":{"color":"#2a3f5f"},"marker":{"line":
{"color":"#E5ECF6","width":0.5},"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpo
lar":[{"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"
carpet":[{"aaxis":
{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","min
orgridcolor":"white","startlinecolor":"#2a3f5f"},"baxis":
{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","min
orgridcolor":"white","startlinecolor":"#2a3f5f"},"type":"carpet"}],"ch
oropleth":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"heatmap"}],"histogram":[{"marker":{"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],
"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":
{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":
[{"automargin":true,"type":"pie"}],"scatter":[{"fillpattern":
{"fillmode":"overlay","size":10,"solidity":0.2},"type":"scatter"}],"sc
atter3d":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":
{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattergl"}],"scattermap":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattermap"}],"scattermapbox":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar"
:[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl
":[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterterna
ry":[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":
{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":
{"color":"#C8D4E3"},"line":
{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":
{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"autotypenumbers
":"strict","coloraxis":{"colorbar":
{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":
[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],
[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],
[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"sequentialminus":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],[1,"#f0f921"]]},"colorway":
["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692"
,"#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"geo":
{"bgcolor":"white","lakecolor":"white","landcolor":"#E5ECF6","showlake
s":true,"showland":true,"subunitcolor":"white"},"hoverlabel":
{"align":"left"},"hovermode":"closest","mapbox":
{"style":"light"},"paper_bgcolor":"white","plot_bgcolor":"#E5ECF6","po
lar":{"angularaxis":
{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF
6","radialaxis":
{"gridcolor":"white","linecolor":"white","ticks":""}},"scene":
{"xaxis":
{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"lineco
lor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}
,"yaxis":
{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"lineco
lor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}
,"zaxis":
{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"lineco
lor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}
},"shapedefaults":{"line":{"color":"#2a3f5f"}},"ternary":{"aaxis":
{"gridcolor":"white","linecolor":"white","ticks":""},"baxis":
{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF
6","caxis":
{"gridcolor":"white","linecolor":"white","ticks":""}},"title":
{"x":5.0e-2},"xaxis":
{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"",
"title":
{"standoff":15},"zerolinecolor":"white","zerolinewidth":2},"yaxis":
{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"",
"title":
{"standoff":15},"zerolinecolor":"white","zerolinewidth":2}}},"title":
{"text":"GDP Trend (Sorted)"},"xaxis":{"anchor":"y","domain":
[0,1],"title":{"text":"Country"}},"yaxis":{"anchor":"x","domain":
[0,1],"title":{"text":"GDP"}}}}

Lab session 10

import wbdata
import pandas as pd
indicator = {
'[Link]': 'Population total',
'[Link]': 'GDP(Currency $)',
'[Link]': 'Life Expectancy'
}
COUNTRIES =
['PK','IND','BGD','AFG','IRN','CHN','NPL','LKA','BTN','MMR']
Data = wbdata.get_dataframe(indicator, country=COUNTRIES)
Data=Data.reset_index()
Data['date'] = pd.to_numeric(Data['date'])
Data['GDP(Currency $)']=Data['GDP(Currency
$)'].fillna(Data['GDP(Currency $)'].mean())
Data['Life Expectancy']=Data['Life Expectancy'].fillna(Data['Life
Expectancy'].mean())
Data.drop_duplicates()
[Link]().sum()
[Link]()

date Population total GDP(Currency $) Life Expectancy


count 650.000000 6.500000e+02 6.500000e+02 650.000000
mean 1992.000000 2.434565e+08 5.294469e+11 59.227891
std 18.776112 4.122273e+08 2.090305e+12 10.774422
min 1960.000000 2.240840e+05 6.181211e+07 26.522000
25% 1976.000000 1.761387e+07 4.827249e+09 51.737500
50% 1992.000000 4.574022e+07 4.211385e+10 60.423000
75% 2008.000000 1.593551e+08 2.792301e+11 67.508000
max 2024.000000 1.450936e+09 1.874380e+13 78.202000
fig1 = [Link](Data, x='date', y='Population total', color='country')
fig2 = [Link](Data, x='date', y='GDP(Currency $)', color='country')
fig3 = [Link](Data, x='date', y='Life Expectancy', color='country')
fig1
fig2
fig3

----------------------------------------------------------------------
-----
NameError Traceback (most recent call
last)
Cell In[5], line 1
----> 1 fig1 = [Link](Data, x='date', y='Population total',
color='country')
2 fig2 = [Link](Data, x='date', y='GDP(Currency $)',
color='country')
3 fig3 = [Link](Data, x='date', y='Life Expectancy',
color='country')

NameError: name 'px' is not defined

You might also like