student notes / est. for the classroom

HTML, CSS, JavaScript, Python, data science, computer networks — written the way you'd explain it to a classmate, not a compiler.

Top Job & Internship Portals

Handpicked portals for fresher jobs, tech roles, and listings in Hyderabad

GFG

GeeksforGeeks

Tech & Software Roles

Visit →
INT

Internshala

Fresher Jobs & Internships

Visit →
GOOG

Google Careers

Global Google Openings

Visit →
APN

Apna Jobs

Local Jobs in Hyderabad

Visit →
INS

Instahyre

Tech Roles in Hyderabad

Visit →
NAUK

Naukri.com

Fresher Jobs in Hyderabad

Visit →
📢 Updated daily

Internship & Job Alerts

01

Latest notes

March 17, 2023

Python code for Graphs

To import dataset from google drive (for single dataset)

import numpy as np
import pandas as pd
from google.colab import drive
drive.mount('/content/drive')
%cd /content/drive/My Drive/
df = pd.read_csv('dataset.csv')
df


To import dataset from google drive (for multiple datasets)

import numpy as np
import pandas as pd
from google.colab import drive
drive.mount('/content/drive')
%cd /content/drive/My Drive/
directory = "foldername"

Ad




Code 1 Scatter dots

# import modules
from bokeh.plotting import figure, output_notebook, show
  
# output to notebook
output_notebook()
  
# create figure
p = figure(plot_width = 400, plot_height = 400)
  
# add a circle renderer with
# size, color and alpha
p.circle([1, 2, 3, 4, 5], [4, 7, 1, 6, 3], 
         size = 10, color = "navy", alpha = 0.5)
  
# show the results
show(p) 


Code 2 line graph

# import modules
from bokeh.plotting import figure, output_notebook, show
  
# output to notebook
output_notebook()
  
# create figure
p = figure(plot_width = 400, plot_height = 400)
   
# add a line renderer
p.line([1, 2, 3, 4, 5], [3, 1, 2, 6, 5], 
        line_width = 2, color = "green")
  
# show the results
show(p)


Code 3 bar graph

# import necessary modules
import pandas as pd
from bokeh.charts import Bar, output_notebook, show
  
# output to notebook
output_notebook()
  
# read data in dataframe
df = pd.read_csv(r"D:/kaggle/mcdonald/menu.csv")
  
# create bar
p = Bar(df, "Category", values = "Calories",
        title = "Total Calories by Category", 
                        legend = "top_right")
  
# show the results
show(p)

Code 4 box plot graph

# import necessary modules
from bokeh.charts import BoxPlot, output_notebook, show
import pandas as pd
  
# output to notebook
output_notebook()
  
# read data in dataframe
df = pd.read_csv(r"D:/kaggle / mcdonald / menu.csv")
  
# create bar
p = BoxPlot(df, values = "Protein", label = "Category", 
            color = "yellow", title = "Protein Summary (grouped by category)",
             legend = "top_right")
  
# show the results
show(p)



Code 5 Histogram graph

# import necessary modules
from bokeh.charts import Histogram, output_notebook, show
import pandas as pd
  
# output to notebook
output_notebook()
  
# read data in dataframe
df = pd.read_csv(r"D:/kaggle / mcdonald / menu.csv")
  
# create histogram
p = Histogram(df, values = "Total Fat",
               title = "Total Fat Distribution", 
               color = "navy")
  
# show the results
show(p) 


Code 6 scatter plot
# import necessary modules
from bokeh.charts import Scatter, output_notebook, show
import pandas as pd
  
# output to notebook
output_notebook()
  
# read data in dataframe
df = pd.read_csv(r"D:/kaggle / mcdonald / menu.csv")
  
# create scatter plot
p = Scatter(df, x = "Carbohydrates", y = "Saturated Fat",
            title = "Saturated Fat vs Carbohydrates",
            xlabel = "Carbohydrates", ylabel = "Saturated Fat",
            color = "orange")
   
# show the results
show(p)






Dataset 1

 id product unit

1 apple 11

2 peas 22

3 grapes 33

4 bananas 44

import numpy as np
import pandas as pd
from google.colab import drive
drive.mount('/content/drive')
%cd /content/drive/My Drive/
df = pd.read_csv('dataset.csv')
df

Dataset 2

Company nameMarket capitalPE ratioEarnings per shareDividend yieldSector P/EPrice to BookDebt to equityReturn on equityPrice to sales
0Adani wilmar67232297.795.290.0055.428.580.408.791.15
1Happiest Minds1243255.1515.350.4326.6016.650.5329.069.20
2Route mobile752527.7643.510.4226.604.530.0114.042.36
3Avenue supermart23083498.4436.200.0089.3715.380.0515.385.63
4Paras defence tech209062.208.590.004.255.940.098.5210.24
5Laxmi organic723645.875.950.2627.115.340.1915.692.46
6KPIT1913160.2111.590.4426.6013.700.1322.837.07

Python Code for Charts

a simple graph

  1. from matplotlib import pyplot as plt    
  2. #ploting our canvas    
  3. plt.plot([1,2,3],[4,5,1])    
  4. #display the graph    
  5. plt.show()  

Line Graph

  1. from matplotlib import pyplot as plt    
  2.     
  3. x = [1,2,3]    
  4. y = [10,11,12]    
  5.     
  6. plt.plot(x,y)    
  7.     
  8. plt.title("Line graph")    
  9. plt.ylabel('Y axis')    
  10. plt.xlabel('X axis')    
  11. plt.show()    

Bar graph

  1. from matplotlib import pyplot as plt    
  2. Names = ['Arun','James','Ricky','Patrick']    
  3. Marks = [51,87,45,67]    
  4. plt.bar(Names,Marks,color = 'blue')    
  5. plt.title('Result')    
  6. plt.xlabel('Names')    
  7. plt.ylabel('Marks')    
  8. plt.show()   

Pie chart

  1. from matplotlib import pyplot as plt    
  2.     
  3. # Pie chart, where the slices will be ordered and plotted counter-clockwise:    
  4. Aus_Players = 'Smith', 'Finch', 'Warner', 'Lumberchane'    
  5. Runs = [42, 32, 18, 24]    
  6. explode = (0.1, 0, 0, 0)  # it "explode" the 1st slice     
  7.     
  8. fig1, ax1 = plt.subplots()    
  9. ax1.pie(Runs, explode=explode, labels=Aus_Players, autopct='%1.1f%%',    
  10.         shadow=True, startangle=90)    
  11. ax1.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle.    
  12.     
  13. plt.show()    

Histogram

  1. from matplotlib import pyplot as plt    
  2. from matplotlib import pyplot as plt    
  3. percentage = [97,54,45,10, 20, 10, 30,97,50,71,40,49,40,74,95,80,65,82,70,65,55,70,75,60,52,44,43,42,45]    
  4. number_of_student = [0,10,20,30,40,50,60,70,80,90,100]    
  5. plt.hist(percentage, number_of_student, histtype='bar', rwidth=0.8)    
  6. plt.xlabel('percentage')    
  7. plt.ylabel('Number of people')    
  8. plt.title('Histogram')    
  9. plt.show()  

Scatter Plot

  1. from matplotlib import pyplot as plt    
  2. from matplotlib import style    
  3. style.use('ggplot')    
  4.     
  5. x = [4,8,12]    
  6. y = [19,11,7]    
  7.     
  8. x2 = [7,10,12]    
  9. y2 = [8,18,24]    
  10.     
  11. plt.scatter(x, y)    
  12.     
  13. plt.scatter(x2, y2, color='g')    
  14.     
  15. plt.title('Epic Info')    
  16. plt.ylabel('Y axis')    
  17. plt.xlabel('X axis')    
  18.     
  19. plt.show()    




1 comment:

  1. The way you explain a complex topic in an easy-to-understand way is really impressive.
    Hire React Developer from Chennai

    ReplyDelete

02

Capstone resource hub

Codingacharya

Capstone Learning Resources, Notes & Project Hub

TCS NQT Questions
Read Notes
Machine Learning – ACE Theory
Read Notes
Machine Learning PPT
Read Notes
MachienLearning LAB
Read Notes
CSPT LAB programs
Read Notes
Time table and CSPT syllabus
Read Notes
Appreciations
Read Notes
ISTE life memberships
Read Notes
Artificial Intelligence & Analytics
Read Notes
Fullstack Web Dev
Read Notes
MERN Web Dev
Read Notes
Course Structure
Read Notes
Cloud Computing
Read Notes
90 Days ML Challenge
Read Notes
Advanced Analytics & Viz
Read Notes
Advanced Machine Learning
Read Notes
React JS
Read Notes
ML Chaitanya
Read Notes
Important Links
Read Notes
CSS Effects
Read Notes
RESUME
Read Notes
Bootstrap CSS
Read Notes
MongoDB
Read Notes
OWN Python Package
Read Notes
HTML Course
Read Notes
HTML Projects
Read Notes
GitHub Projects
Read Notes
Angular JS
Read Notes
Journals
Read Notes
NLP Notes
Read Notes
Videos
Read Notes
Data Analytics & Viz
Read Notes
Cloud Computing (Archive)
Read Notes
Open CV
Read Notes
jQuery
Read Notes
React JS (Archive)
Read Notes
Node JS
Read Notes
DAV Theory
Read Notes
DAV Lab
Read Notes
Big Data Notes
Read Notes
R-Programming
Read Notes
HADOOP Lab
Read Notes
GATE DA
Read Notes
JAVA Lab
Read Notes
Computer Networks
Read Notes
03

Live projects & profiles