Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
suyashi29
GitHub Repository: suyashi29/python-su
Path: blob/master/Data Visualization using Python/Python Datatypes and Basic Charts .ipynb
3074 views
Kernel: Python 3 (ipykernel)

Advantages of Data Visualization

Data visualization is essential for understanding complex data and making informed decisions.

Here are its key advantages:

    1. Makes Data Easier to Understand 📊 Converts raw data into visual formats like charts, graphs, and maps, making it easier to comprehend patterns and trends.

✔ Example: A line chart showing sales trends over time is easier to interpret than raw numbers in a table.

    1. Identifies Trends and Patterns Quickly 🔍 Helps in detecting patterns, trends, and outliers that might not be obvious in spreadsheets or raw data.

✔ Example: A heatmap of customer activity can reveal peak engagement times.

    1. Improves Decision-Making 📈 Enables businesses and analysts to make data-driven decisions faster and more accurately.

✔ Example: A dashboard showing real-time sales and inventory levels helps in making quick supply chain decisions.

    1. Enhances Communication and Storytelling 🗣 Helps present complex data to stakeholders in a compelling and clear manner.

✔ Example: A bar chart comparing monthly revenue makes financial reports more engaging.

    1. Saves Time in Data Analysis ⏳ Analyzing thousands of rows in a dataset takes time, but a well-designed chart can provide insights in seconds.

✔ Example: A scatter plot showing the correlation between marketing spend and revenue can provide immediate insights.

    1. Helps in Detecting Errors and Anomalies ⚠ Quickly highlights inconsistencies, missing data, or unusual trends in datasets.

✔ Example: A box plot can show unexpected outliers in employee performance ratings.

    1. Engages and Persuades Audience Effectively 📢 Makes reports, presentations, and pitches more engaging, leading to better audience retention.

✔ Example: A pie chart showing market share can be more persuasive than just listing numbers.

    1. Supports Predictive Analysis 🔮 Helps in forecasting future trends based on historical data using techniques like regression analysis and time series forecasting.

✔ Example: A forecasting graph for stock prices using past data trends.

    1. Enhances Accessibility for Non-Technical Users 👩‍💼 Enables business managers, executives, and non-data professionals to understand complex data without needing advanced analytical skills.

✔ Example: An interactive Tableau dashboard allows users to filter data dynamically.

    1. Facilitates Competitive Analysis 🏆 Helps organizations compare their performance with competitors by visualizing industry trends.

Python Variables

# Defining variables name = "Ashi" # String age = 25 # Integer height = 5.5 # Float is_student = True # Boolean x='1234' y= 1234 x[0],x[1],x[2],x[3] len(x) max(x) print("her name is,",name) print("%s is her name and her age is %d and height is %f" %(name,age,height)) print() ## del x[0]
her name is, Ashi Ashi is her name and her age is 25 and height is 5.500000
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[24], line 17 14 print("%s is her name and her age is %d and height is %f" %(name,age,height)) 15 print() ---> 17 del x[0] TypeError: 'str' object doesn't support item deletion
##List l=[] fruits = ["apple", "banana", 9,10.2 ] fruits[0] # Access first element fruits[-1] fruits[0]="banana" fruits[1]="apple" fruits #fruits.append("lilly") ##fruits.remove("apple") fruits #del fruits[1] fruits
['banana', 'apple', 9, 10.2]
##Tuples d=() d=("a",4,4.5) d[0] del d[0]
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[28], line 6 4 d=("a",4,4.5) 5 d[0] ----> 6 del d[0] TypeError: 'tuple' object doesn't support item deletion
## Sets s={} b = {1, 2, 3, 4, 2, 3,4,5} #unique_numbers.add(5) # Add element #unique_numbers.remove(2) # Remove element b b.add(8) b b.remove(4) b
{1, 2, 3, 5, 8}
#dictionary s={} s={"a":1,"b":2,"c":3} s s.keys() s.values() s["d"]=4 s["a"]=12 s["c"]=12 s
{'a': 12, 'b': 2, 'c': 12, 'd': 4}

Type Conversion

type(4),type(4.5),type("ashi"),type((1,3)),type({1,2}),type([1,4]),type({2:3})
(int, float, str, tuple, set, list, dict)
int(4.3) float(8) str(34) int("45") list("ashi") tuple([1,23])
(1, 23)

Input Functions

# Create an interface name"Learning platform" ##ask user for input their name, age, exp ##also if age is less than 18 then they are not eligible to create a user and password. ## If age is greater than 18 ask user to create User Name and Password, ## "Account created" ## " Welcome to login page" ## "Enter user name and password" ##"use can use interface Now" print("WELCOME TO ABSA LEARNING Platform.\n To register enter following details:") name=input("Name please:") Age=int(input("Age:")) WorkExp=float(input("TOTAL Exp:")) if Age < 18: print("Not eligible to create a account") else: print("Welcome you can create an account")
WELCOME TO ABSA LEARNING Platform. To register enter following details: Name please:Abha Age:32 TOTAL Exp:13.5 Welcome you can create an account

Basic Charts

import matplotlib.pyplot as plt import seaborn as sns import numpy as np import pandas as pd # Generate Sample Data data = { 'Category': ['A', 'B', 'C', 'D', 'E'], 'Values': [10, 20, 15, 25, 30] } df = pd.DataFrame(data) # Basic Bar Chart using Matplotlib plt.figure(figsize=(8,5)) plt.bar(df['Category'], df['Values'], color='skyblue') plt.xlabel('Category') plt.ylabel('Values') plt.title('Basic Bar Chart') plt.show() # Line Chart using Matplotlib x = np.linspace(0, 10, 100) y = np.sin(x) plt.figure(figsize=(8,5)) plt.plot(x, y, label='Sine Wave', color='r') plt.xlabel('X-axis') plt.ylabel('Y-axis') plt.title('Line Chart') plt.legend() plt.show() # Scatter Plot using Seaborn np.random.seed(42) data = pd.DataFrame({ 'X': np.random.rand(50), 'Y': np.random.rand(50) }) sns.scatterplot(x='X', y='Y', data=data) plt.title('Scatter Plot') plt.show() # Histogram using Seaborn sns.histplot(data['X'], bins=10, kde=True) plt.title('Histogram') plt.show()