Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Data science report

The document is an internship report by SK. Reshma submitted to Jawaharlal Nehru Technological University, detailing her internship at Skilldzire, Hyderabad, from August 20 to September 20, 2022. It covers various aspects of data science, including methodologies, Python programming, and the application of data science in renewable energy. The report also includes acknowledgments, objectives, and a weekly overview of activities undertaken during the internship.

Uploaded by

Arshiya Nousheen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Data science report

The document is an internship report by SK. Reshma submitted to Jawaharlal Nehru Technological University, detailing her internship at Skilldzire, Hyderabad, from August 20 to September 20, 2022. It covers various aspects of data science, including methodologies, Python programming, and the application of data science in renewable energy. The report also includes acknowledgments, objectives, and a weekly overview of activities undertaken during the internship.

Uploaded by

Arshiya Nousheen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Internship Report on

DATA SCIENCE
is submitted in partial fulfillment of the requirement (III B.Tech Summer
Break) for the award of the Degree of Bachelor of Technology
to

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY


ANANTAPUR, ANANTHAPURAMU
by
SK. RESHMA
(19711A04A3)

Internship carried out at


SKILLDZIRE , HYDERABAD
(Duration: 20TH AUGUST, 2022 to 20TH SEPTEMBER, 2022

Department of Electronics and Communication Engineering

2022-2023
Department of Electronics and Communication Engineering

CERTIFICATE

This is to certify that the “Internship Report” is submitted by


SK. RESHMA (19711A04A3) during academic year 2022-2023, in partial fulfillment of
the requirements for the award of degree of Bachelor of Technology in Department of
Electronics and Communication Engineering, at Skilldzire, Hyderabad.

Internship Coordinator Head of the Department


Dr. K.S. Sagar Reddy, M. Tech, Ph.D Dr. K. Murali, M. Tech, Ph.D
Professor,Dept of ECE Professor & HOD Dept of ECE

Signature of the Examiners

1.

2.
DECLARATION

I hereby declare that the internship entitled DATA SCIENCE has been done by
me and has submitted to NARAYANA ENGINEERING COLLEGE, NELLORE as a
part of partial fulfillment of the requirements for the award of degree of Bachelor of
Technology in Department of Electronics and Communication Engineering.
I also declare that this internship report has not submitted to any other institute or
university and not copied from any other sources.

SK. RESHMA
(19711A04A3)

Place: NELLORE
Date:
ACKNOWLEDGEMENT

I am extremely thankful to Dr. P. NARAYANA, the Founder Chairman of


Narayana Group for his good initiation starting technical institution in Nellore. I also
extremely thankful to Mr. R. Sambasiva Rao, B.Tech, Registrar, Narayana Engineering
College, Nellore.

I am highly indebted to director Dr. A. V. S Prasad, Ph.D, Director, Narayana


Engineering & Pharmacy Colleges, Principal Dr. G. Srinivasulu Reddy, M.Tech., Ph.D,
Narayana Engineering College, Nellore for providing to accomplish this internship.

I would like to thank my Head of the Department Dr. K. Murali M.Tech, Ph.D,
Professor & HOD, Department of Electronics and Communication Engineering,
Narayana Engineering College, Nellore for his constructive criticism throughout my
internship.

I would like to thank Dr. K. S. Sagar Reddy M.Tech, Ph.D, Professor, Internship
Coordinator, Department of ECE for their support and advices to get his guidance,
constant assistance, support, endurance and constructive for the betterment of the
internship.

I would like to thank the CEO of SKILLDZIRE for giving me the opportunity to
do an internship within the organization through virtual mode. I also would like all the
people that worked along with me in SKILLDZIRE, HYDERABAD with their patience
and openness they created an enjoyable working environment. It is indeed with a great
sense of pleasure and immense sense of gratitude that I acknowledge the help of these
individuals.

I am extremely greatfull to my department staff members and friends who helped


me in successful completion of this internship.

SHAIK RESHMA
(19711A04A3)
INDEX

CHAPTER NAMES PAGE NO


Abstract I
Organization Information II
Benefits to the Company / Institute Through Your Report III
Learning Objectives / Internship Objectives IV
Weekly Overview of Internship Activities V
CHAPTER 1: INTRODUCTION 1-4
1.1 Introduction to Data Science 1
1.2 Stages of Data Science 1-2
1.3 Features of Python 2-3
1.4 Use of Data Science in Renewable Energy 3-4
CHAPTER 2: MEHODOLOGY 5-17
2.1. Introduction of Python 5
2.2 Data Structure in Python 5-8
2.3 Operators 8-10
2.4 Conditional statements 11-12
2.4.1 IF else statement 11
2.4.2 Elif statement 11-12
2.5 Loops in Python 12-13
2.5.1 For loop 12
2.5.2 While loop 13
2.6 Module, Package and Functions 14-15
CHAPTER 3: OOPS 16-22
3.1 Oops and classes 16-18
3.2 Exception Handling 18-19
3.3 Handling an Exception 19-20
3.4 File Handling 20-21
3.5 Functions 21-22
CHAPTER 4: Libraries in Python 23-28
5.1 Mataplotlib 23-24
5.2 Pandas 24-25
5.3NumPy 25-28
CHAPTER 5: REAL TIME PROJECT 29-30
CHAPTER 6: CONCLUSION 33
CHAPTER 7: FUTURE SCOPE 34
CHAPTER 8: REFERENCES 33
List of Figures

NAME PAGE NO
Figure 1.2.1: Steps of Data Science 2
Figure 1.4.1: Role of Data Science 4
Figure 2.2.1: Array example 6
Figure 2.2.2: List example 7
Figure 2.2.3: Tuple example 7
Figure 2.2.4: Dictionary example 8
Figure 2.2.5: A data structure tree at glance 8
Figure 2.4.1: If else statement 11
Figure 2.4.2: Elif example 11
Figure 2.5.1: Range example 13
Figure 2.5.2: While loop example 13
Figure 2.6.1: Packages example 14
Figure 2.6.2: Function example 15
Figure 4.1.1: Matplotlib basic example 23
Figure 4.2.1: Pandas basic example 24
Figure 4.3.1: NumPy basic example 25

List of Tables

Name Page No
Table 2.3.1: Arithmetic operators 9
Table 2.3.2: Assignment operators 9
Table 2.3.3: Logical operators 10
Table 2.3.4: Comparison operators 10
Table 2.3.5: Membership operators 11
ABSTRACT
Data science encompasses a set of principles, problem definitions,
algorithms, and processes for extracting nonobvious and useful patterns from large data
sets. Many of the elements of data science have been developed in related fields such as
machine learning and data mining. In fact, the terms data science, machine learning, and
data mining are often used interchangeably. The commonality across these disciplines is
a focus on improving decision making through the analysis of data. However, although
data science borrows from these other fields, it is broader in scope. Machine learning
(ML) focuses on the design and evaluation of algorithms for extracting patterns from data.
Data mining generally deals with the analysis of structured data and often implies an
emphasis on commercial applications. Data science takes all of these considerations into
account but also takes up other challenges, such as the capturing, cleaning, and
transforming of unstructured social media and web data; the use of big-data technologies
to store and process big, unstructured data sets; and questions related to data ethics and
regulation.
Organization Information / Industry Profile

 Skilldzire is one of the growing IT services companies.Skilldzire Technologies


Private Limited is a private incorporated on 16 October 2020.
 It is classified as Non-govt company and is registered at Register of Companies,
Hyderabad.
 Its authorized share capital is Rs.100,000 and its paid up capital is Rs.100,000.It
is involved in Business activities.
 Directors of Skilldzire Technologies Private limited are Srikanth Muppalla and
Sreedhar Thokala.
 We provide complete end-to-end outsourcing solutions for various industries.
We have a comprehensive set of solutions for the Educational Institutes, banking
finance, insurance, manufacturing, retail & distribution and contracting sectors.
 The company has operations and a customer base spanning across 8 countries
including software.
Benefits to the company / Institute through your report
The Institute combines pioneering research with top class education. An
innovative curriculum allows the student flexibility in selecting courses and projects.
Students, even at the undergraduate level, get to participate in on-going research and
technology development - an opportunity unprecedented in India.
Improves management systems, internal processes and set goals.Identify weaknesses and
strengths.
The Institute also focuses on:
1. Gain Valuable Work Experience
2. Explore a career path
3. Give Yourself an edge in the job market
4. Develop and refine skills and more.
The candidate who joins with this company can explore and enhance their skills also at
the end of course each candidate is assigned a project then the candidate can be able to
get a certificate from the company as the course completion. The Students from this
company has been given a good feedback regarding the respective trainers and the
consistency and discipline of company’s maintenance.

Each company has its own protocols and principles where every intern should follow that
to attend the classes regularly and also should be an active participant by the assigned
task like assignments and should submit a project at the end to get a certificate as the
proof that the particular candidate has worked as a intern under our organization
successfully. The benefit for the undergraduate students is to gain the practical experience
from the industry as by working under a project. Working as an intern doesn’t .This whole
Internship Experience helps to excel in a Software company on future.
Learning Objectives / Internship Objectives
 Internships are generally thought of to be reserved for college students looking
to gain experience in a particular field. However, a wide array of people can
benefit from Training Internships in order to receive real world experience and
develop their skills.
 An objective for this position should emphasize the skills you already possess in
the area and your interest in learning more

 Internships are utilized in a number of different career fields, including


architecture, engineering, healthcare, economics, advertising and many more.
 Some internship is used to allow individuals to perform scientific research while
others are specifically designed to allow people to gain first-hand experience
working.
 Utilizing internships is a great way to build your resume and develop skills that
can be emphasized in your resume for future jobs. When you are applying for a
Training Internship, make sure to highlight any special skills or talents that can
make you stand apart from the rest of the applicants so that you have an
improved chance of landing the position.
Weekly Overview of Internship Activities

SUMMARY OF THE TOPIC/MODULE


WEEK DATE DAY
COMPLETED
20/08/2022
Monday Introduction on Data Science
21/08/2022 Tuesday Stages of Data Science
1st WEEK

22/08/2022 Wednesday Introduction of Python


23/08/2022 Thursday Data Structure in Python
24/08/2022 Friday Operators
25/08/2022 Saturday Holiday

SUMMARY OF THE TOPIC/MODULE


WEEK DATE DAY
COMPLETED
27/08/2022 Monday Holiday
28/08/2022 Tuesday Conditional Statements
2nd WEEK

29/08/2022 Wednesday Loops in Python


30/08/2022 Thursday Holiday
31/08/2022 Friday Sample Projects
01/09/2022 Saturday Sample Projects
SUMMARY OF THE TOPIC/MODULE
WEEK DATE DAY
COMPLETED
03/09/2022 Monday Holiday
04/09/2022 Tuesday OOPS &Classes
3rd WEEK

05/09/2022 Wednesday Handling an Exception


06/09/2022 Thursday Holiday
07/09/2022 Friday File Handling
08/09/2022 Saturday Libraries in Python

SUMMARY OF THE TOPIC/MODULE


WEEK DATE DAY
COMPLETED
10/09/2022 Monday Discussion on left over Topics
11/09/2022 Tuesday Assigning Project
4th WEEK

12/09/2022 Wednesday Implementation of Project


13/09/2022 Thursday Implementation of Project
14/09/2022 Friday Project Presentation
15/09/2022 Saturday Project Presentation
20/09/2022 Monday Submission of Project abstract & Presentation
CERTIFICATION
CHAPTER-1
INTRODUCTION
1.1 Data Science
Data science is the field of data analytics and data visualization in which raw data
or the unstructured data is cleaned and made ready for the analysis purpose. Data
scientists use this data to get the required information for the future purpose.”Data science
uses many processes and methods on the big data, the data may be structured or
unstructured”. Data frames available on the internet is the raw data we get. It may be
either in unstructured or semi structured format. This data is further filtered, cleaned and
then number of required task are performed for the analysis with the use of the high
programming language. This data is further analyzed and then presented for our better
understanding and evaluation. One must be clear that data science is not about making
complicated models or making awesome visualization neither it is about writing code but
about using the data to create an impact for your company, for this impact we need tools
like complicated data models and data visualization.
1.2 Stages of Data Science
There are many tools used to handle the big data available to us. ”Data scientists
use programming tools such as Python, R, SAS, Java, Perl, and C/C++ to extract
knowledge from prepared data”.
Data scientists use many algorithms and mathematical models on the data.
Following are the stages and their cycle performed on the unstructured data.
 Identifying the problem.
 Identify available data sources
 Identify available data sources
 Identify if additional data sources are needed.
 Statistical analysis
 Implementation, development
 Maintenance
 Communicate results

Dept. of ECE Narayana Engineering College, Nellore 1


Figure 1.2.1: Steps of Data Science
Data science finds its application in many fields. With the assistance of data
science it is easy to get the search query on search engines in plenty of time. A role of the
data scientist is to have a deep understanding of the data as well as a good command on
the programming language, he should also know how to work with the raw data extracted
from the data source. Many programming languages are used to analyze and evaluate the
data such as Python, Java, MATLAB, Scala, Julia, R., SQL and TensorFlow. Among
which python is the most user friendly and vastly used programming language in the field
of data science.
This life cycle is applied in each and every field, in this project we will be
considering all this seven stages of data science to analyze the data. The process will be
starting from data collection, data preparation, data modeling and finally data evaluation.
For instance, As we have huge amount of data we can create an energy model for a
particular country by collecting its previous energy data, we can also predict the future
requirement of it with the same data.
1.3 Features of python
1. Easy to code: Python is a high-level programming language. Python is very easy to
learn the language as compared to other languages like C, C#, Javascript, Java, etc. It is
very easy to code in python language and anybody can learn python basics in a few hours
or days. It is also a developer-friendly language.
2. Free and open space: Python language is freely available at the official website and
you can download it. Since it is open-source, this means that source code is also available

Dept. of ECE Narayana Engineering College, Nellore 2


to the public. So you can download it as, use it as well as share it.
3. Object oriented: One of the key features of python is Object-Oriented programming.
Python supports object-oriented language and concepts of classes, objects encapsulation,
etc.
4. GUI programming support: Graphical User interfaces can be made using a module
such as PyQt5, PyQt4, wxPython, or Tk in python.
1.4 Use of Data Science in Renewable energy
As the number of renewable energy systems are increasing the renewable energy
data is increasing through sensors and other aspects of energy systems. So again this big
data can be helpful in not even understanding the current scenario of the renewable energy
sector but can also be helpful in forecasting the renewable energy consumption as well as
production both.
Following are the applications of data science which plays a major role in the filed of
renewable energy.
 Improving the current technology This is mostly used in the field of solar energy.
Data of solar panels are collected using sensors and by analysing that data pattern
we can improve the efficiency as well as life span of the particular solar panel.
 Renewable energy consumption prediction The consumption of renewable energy
by the customers can also be predicted with the help of past data of energy
consumption by the customers.This can be so helpful in fulfilling customers
requirement in future.
 Renewable energy production forecasting Solar energy and wind energy
production can be optimized by considering the weather condition and
environmental condition data.With this data, forecasting can be easily done.
 Reducing Renewable Energy Production Costs With the help of the big energy
data available to us we are able to predict the production cost of renewable energy
easily from forecasting model. The price of the energies are declining just because
of the big data and forecasting model available to us. Renewable energy will be
cost competent with its conventional counterparts.
 Efficient backup facility for power plants With the help of computational models
we can easily get the high and low power usage and when there is abundant power
we can save the power which may be wasted vice versa when there is shortage of

Dept. of ECE Narayana Engineering College, Nellore 3


power we can provide with the help of our renewable energy systems.

Below in the figure shows the role of Data Science and Big Data Analytics in the
Renewable Energy Sector.

Figure1.4.1: Role of Data Science

Dept. of ECE Narayana Engineering College, Nellore 4


CHAPTER 2
METHODOLOGY
2.1 Python Programming language basics
”Python is an interpreted, object-oriented, high-level programming language with
dynamic semantics”. This language consist of mainly data structures which make it very
easy for the data scientists to analyse the data very effectively. It does not only help in
forecasting and analysis it also helps in connecting the two different languages.Two best
features of this programming language is that it does not have any compilation step as
compared to the other programming language in which compilation is done before the
program is being executed and other one is the reuse of the code, it consist of modules
and packages due to which we can use the previously written code any where in between
the program whenever is required. There are multiple languages for example R., Java,
SQL, Julia, Scala, MATLAB available in market which can be used to analyze and
evaluate the data, but due to some outstanding features python is the most famous
language used in the field of data science.
Python is mostly used and easy among all other programming languages is due to the
following reasons.
2.2 Data structures in Python
Data structures are the way of storing the data so that we can easily perform
different operations on the data whenever its required. When the data has been collected
from the data source the data is available in different forms. So later it is easy for the data
scientists to perform different operation on the data once it is sorted in to different data
structures.
Data structures are mainly classified in to two categories and then further their
subcategories shown below.
Primitive Data Structures
They are also called as basic data structures.This type of data structures contains simple
values of the data.
• Integers- All the whole numbers from negative infinity to positive infinity comes
under integer data types.

Dept. of ECE Narayana Engineering College, Nellore 5


• Float- The decimal figure numbers or rational numbers comes under float data types.
• Strings- Collection of alphabets or characters are called strings. We enclose the string
either in single or double quotes in python.
• Boolean- These are the built in data types which take two values that are ’True’ and
’False’. True represents the 1 and False represents 0 in python.
Non-Primitive Data Structures
These are the derived type or reference variables data structures. They are called derived
data structures because they derived from the basic data structures such as integer and
float. Python has mainly five types of data structures.
Following are the non primitive data structures
Array– Array is the collection of data types of same type.Arrays data structure are used
mostly in the NumPy library of python.In the below example we have first imported the
package array from numpy library and definrd the array as variable divided the array by
7 and we have printed our array to get output.

Figure 2.2.1: Array example

List– “A list is a value that contains multiple values in an ordered sequence”.Values in


the list referred to list itself,that is the value can be stored in a varaiable or passed to a
function.List are changeable and values in the list are enclosed inside a square bracket,we
can perform multiple operations such as indexing,slicing,adding and multiplying.

Dept. of ECE Narayana Engineering College, Nellore 6


Figure 2.2.2: List example
Tuple- A tuple is a list of non changeable objects. The differences between tuples and
lists are that the tuples cannot be changed, tuples use parentheses, whereas list uses square
brackets.

Figure 2.2.3: Tuple example


Dictionary- These are nothing but a type of data structure which consist of key value
pairs enclosed in the curly brackets. It is same as the any dictionary we use in day to day
life in which we find the meaning of the particular words. So if I compare normal
dictionary to this python dictionary data structure then the a word in a dictionary will be
our key and its meaning will be the value of the dictionary. In the figure name, occupation
and hobby are the keys and Suraj, data analyst and vlogging are the values assigned to the
keys.

Dept. of ECE Narayana Engineering College, Nellore 7


Figure 2.2.4: Dictionary example
Sets– Set are used for calculating mathematical operations such as union,intersection and
symmetric difference.
Below is the data structure tree which explains the category and sub-category of each
datatype.

Figure 2.2.5 A data structure tree at glance


2.3 Operators
Operators are the symbols in python that are used to perform Arithmetic or
logical operations. Following are the different types of operators in python.
Arithmetic operators- Arithmetic operators carry out mathematical operations and
they are mostly used with the numeric values.

Dept. of ECE Narayana Engineering College, Nellore 8


Table 2.3.1: Arithmetic operators
A and B are the numeric values.
Assignment operators– As the name decides this operations are used for assigning the
values to the variables.

Table 2.3.2: Assignment operators

Dept. of ECE Narayana Engineering College, Nellore 9


Here a is any value and number of operations are performed on this value.
Logical operations– These operations are used to join conditional statements

Table 2.3.3: Logical operators


Here a is any value provided by us and on which multiple operations can be performed.
Comparison operators– These operators are used to compare two different values.

Table 2.3.4: Comparison operators


Here a and b are two different values and these values are compared.
Membership operators- These operators are used to check membership of a particular
value.It is used to check whether a specific value is present in the object or not.

Dept. of ECE Narayana Engineering College, Nellore 10


Table 2.3.5: Membership operators

2.4 Condition statements


2.4.1 IF else statements
”The most common type of statement is the if statement. if statement consist of a
block which is called as clause”, it is the block after if statement, it executed the
statement if the condition is true. The statement is omitted if the condition is False. then
the statement in the else part is printed
If statement consist of following –
 If keyword itself
 Condition which may be True or False
 Colon
 If clause or a block of code

Figure 2.4.1: if else statement

Dept. of ECE Narayana Engineering College, Nellore 11


2.4.2 Elif statement
In this statement only one statement is executed, There are many cases in which
there is only one possibility to execute.”The elif statement is an else if statement that
always follows an if or another elif statement”. The elif statement provides another
condition that is checked only if any of the previous conditions were False. In code, an
elif statement always consists of the following:. The only difference between if else and
elif statement is that in elif statement we have the condition where as in else statement we
do not have any condition.
Elif statement consist of following –
 elif keyword itself
 Condition which may be true or false
 Colon
 elif clause or a block of code

Below is the figure shows how elif statement is used with description inside it.

Figure 2.4.2: Elif example


2.5 Loops in python
2.5.1 For loop
For loops are traditionally used when you have a block of code which you want to
repeat a fixed number of times. The Python for statement iterates over the members of a
sequence in order, executing the block each time.
Range statement- This statement ’range()’ is used with for loop statements where you
can specify one value. For example, if you specify 10, the loop statement starts from 1
and ends with 9, which is n-1. Also, you can specify the start and end values. The
Dept. of ECE Narayana Engineering College, Nellore 12
following examples demonstrate loop statements.

Figure2.5.1: Range example

2.5.2 While loop


While loops are used for repeating the section of code but not same as for loop, the
while loop does not run n times, but until a defined condition is no longer met. If the
condition is initially false, the loop body will not be executed at all.

Figure 2.5.2: While loop example

Dept. of ECE Narayana Engineering College, Nellore 13


2.6 Module, Package and Functions
Modules are Python files which has extension as .py. The name of the module will
be the name of the file. A Python module can have a set of functions, classes or variables
defined and implemented.
Module has some python codes, this codes can define the classes, functions and
variables.The reason behind using the module is that it organizes your python code by
grouping the python code so that it is easier to use.
Package
A package consist of the collection of modules in which python codes are written
with name init.py. It means that each python code inside of the python path, which
contains a file named init.py, will be treated as a package by Python. Packages are used
for organizing the module by using dotted names.

Figure 2.6.1: Package example


Functions
A function is a python code which can be reused at any anytime in the whole python
code. Function performs specific task whenever it is called during the program.With the
help of function the program is divided in to multiple codes.
 Built in functions - The functions which are already in the python programming
and have specific action to perform are called as built in functions. This function
are immutable.

Dept. of ECE Narayana Engineering College, Nellore 14


Some examples of this functions are –
chr() - used to get string
print() - used to print an object in terminal
min() - used to get minimum value in terminal
 User defined functions - This functions are user to defined functions and it starts
with the key word ’def’ as shown in the example below. We have defined the
function names temperature and its task to be performed when called. Below is
the example of it

Figure 2.6.2: Function example

Dept. of ECE Narayana Engineering College, Nellore 15


CHAPTER 3
OOPS
Object Oriented Programming is a way of computer programming using the idea
of “objects” to represents data and methods
It an approach used for creating neat and reusable code instead of a redundant one
The program is divided into self-contained objects or several mini-programs.
Every Individual object represents a different part of the application having its own logic
and data to communicate within themselves.

3.1 OOPS AND CLASSES


Python is an object oriented programming language. Almost everything in Python
is an object, with its properties and methods.
A Class is like an object constructor, or a "blueprint" for creating objects.
Create a Class
To create a class, use the keyword class:
Example
Create a class named MyClass,with a property names x:
Class MyClass:
x=5

Dept. of ECE Narayana Engineering College, Nellore 16


Create Object
Now we can use the class named MyClass to create objects:
Example
Create an object named p1,and print the value of x:
p1=MyClass()
print(p1.x)

The __init__() Function

The examples above are classes and objects in their simplest form, and are not
really useful in real life applications. To understand the meaning of classes we have to
understand the built-in __init__() function. All classes have a function called __init__(),
which is always executed when the class is being initiated. Use the __init__() function
to assign values to object properties, or other operations that are necessary to do when
the object is being created:

Example
Create a class named Person,use the __init__() function to assign values for name and
age:
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
p1 = Person("John", 36)
print(p1.name)
print(p1.age)

The__str__() Function

The __str__() function controls what should be returned when the class object is
represented as a string.If the __str__() function is not set, the string representation of the
object is returned:

Example:class Person:
def __init__(self, name, age):

Dept. of ECE Narayana Engineering College, Nellore 17


self.name = name
self.age = age
p1 = Person("John", 36)
print(p1)

The string representation of an object with the __str__() function:

class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def __str__(self):
return f"{self.name}({self.age})"
p1 = Person("John", 36)
print(p1)

3.2 EXCEPTION HANDLING

An exception is an event, which occurs during the execution of a program that


disrupts the normal flow of the program's instructions. In general, when a Python script
encounters a situation that it cannot cope with, it raises an exception. An exception is a
Python object that represents an error.When a Python script raises an exception, it must
either handle the exception immediately otherwise it terminates and quits.

Dept. of ECE Narayana Engineering College, Nellore 18


3.3 Handling an exception

Some suspicious code that may raise an exception, you can defend your program
by placing the suspicious code in a try: block. After the try: block, include
an except: statement, followed by a block of code which handles the problem as elegantly
as possible.

Syntax

Here is simple syntax of try....except...else blocks –

try:
You do your operations here;
except ExceptionI:
If there is ExceptionI, then execute this block.
except ExceptionII:
If there is ExceptionII, then execute this block.
Else:

If there is no exception then execute this block.

Here are few important points about the above-mentioned syntax −

Dept. of ECE Narayana Engineering College, Nellore 19


 A single try statement can have multiple except statements. This is useful when
the try block contains statements that may throw different types of exceptions.

 You can also provide a generic except clause, which handles any exception.

 After the except clause(s), you can include an else-clause. The code in the else-
block executes if the code in the try: block does not raise an exception.

 The else-block is a good place for code that does not need the try: block's
protection.

3.4 FILE HANDLING

File handling is an important part of any web application. Python has several
functions for creating, reading, updating, and deleting files.

The key function for working with files in Python is the open() function.
The open() function takes two parameters; filename, and mode.

There are four different methods (modes) for opening a file:

"r" - Read - Default value. Opens a file for reading, error if the file does not exist
"a" - Append - Opens a file for appending, creates the file if it does not exist
"w" - Write - Opens a file for writing, creates the file if it does not exist
"x" - Create - Creates the specified file, returns an error if the file exists
"t" - Text - Default value. Text mode
"b" - Binary - Binary mode

Syntax

To open a file for reading it is enough to specify the name of the file:

f = open("demofile.txt")

The code above is the same as:

f = open("demofile.txt", "rt")

Dept. of ECE Narayana Engineering College, Nellore 20


Because "r" for read, and "t" for text are the default values, you do not need to
specify them.

Regular Expressions

RE is defined as set of symbols that are used to extract some set of strings based on
specified pattern.

Ex:-display all the python files in our computer whose extension is *.py

Such a pattern is used to locate a chunk of text in string by matching up the pattern

Ex:-Email,Ph no etc..

3.5 Functions

Search():-It searches for first occurence if re pattern within string with optional flags
sub():-Replaces on or many matches with a string

Findall():-Returns a list containing all matches

Split():-Returns a list where the string has been split at each match

Symbolic characters
^ :-Matches the start of the string
$ :-Matches the end of the String
. :-Matches any character except new line
() :-Matches sub-pattern inside parenthesis as a grp and stores in a substring
* :-Matches zero or more occurences of preceding sub-pattern
+ :-Matches one or more occurences of preceding sub-pattern
? :-Matches zero or one occurences of preceding sub-pattern
*? :-Matches zero or more occurences of preceding sub-pattern
{m,n} :- Matches from m repetition to occurences of the preceding sub pattern
:-Matches either of the sub-pattern present on either side of this special character
[] :-Matches any one of the character in the sequence.

Dept. of ECE Narayana Engineering College, Nellore 21


CHAPTER 4
Libraries in Python
Python library is vast. There are built in functions in the library which are written
in C language. This library provide access to system functionality such as file input output
and that is not accessible to Python programmers. This modules and library provide
solution to the many problems in programming.
Following are some Python libraries.
 Matplotlib
 Pandas
 TensorFlow
 Numpy
 Keras
 PyTorch
 LightGBM
 Eli5
 SciPy
4.1 Mataplotlib
”Matplotlib is a plotting library for the Python programming language and its
numerical mathematics extension NumPy”. Matlab provides an application that is used
in graphical user interface tool kits. Another such libraby is pylab which is almost same
as MATLAB.
It is a library for 2D graphics, it finds its application in web application servers, graphical
user interface toolkit and shell.Below is the example of a basic plot in python.

Dept. of ECE Narayana Engineering College, Nellore 22


Figure 4.1.1: Matplotlib basic example
4.2 Pandas
Pandas is also a library or a data analysis tool in python which is written in python
programming language. It is mostly used for data analysis and data manipulation. It is
also used for data structures and time series. We can see the application of python in many
fields such as-Economics, Recommendation Systems - Spotify, Netflix and Amazon,
Stock Prediction, Neuro science, Statistics, Advertising, Analytics, Natural Language
Processing. Data can be analyzed in pandas in two ways –
Data frames- In this data is two dimensional and consist of multiple series. Data is
always represented in rectangular table.
Series- In this data is one dimensional and consist of single list with index

Dept. of ECE Narayana Engineering College, Nellore 23


Figure 4.2.1: Pandas basic example

4.3 NumPy
”NumPy is a library for the Python programming language, adding support for
large, multidimensional arrays and matrices, along with a large collection of high-level
mathematical functions to operate on these arrays”. The previous similar programming of
NumPy is Numeric, and this language was originally created by Jim Hugunin with
contributions from several other developers. In 2005, Travis Oliphant created NumPy by
incorporating features of the competing Numarray into Numeric, with extensive
modifications. It is an open source library and free of cost.

Dept. of ECE Narayana Engineering College, Nellore 24


Figure 4.3.1: NumPy basic example

Create a NumPy ndarray Object

NumPy is used to work with arrays. The array object in NumPy is


called ndarray.

We can create a NumPy ndarray object by using the array() function.

Example
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(arr)
print(type(arr))
To create an ndarray, we can pass a list, tuple or any array-like object into
the array() method, and it will be converted into an ndarray:
Example
Use a tuple to create a NumPy array:
import numpy as np
arr = np.array((1, 2, 3, 4, 5))

Dept. of ECE Narayana Engineering College, Nellore 25


print(array)

Access Array Elements

Array indexing is the same as accessing an array element. You can access an array
element by referring to its index number.

The indexes in NumPy arrays start with 0, meaning that the first element has
index 0, and the second has index 1 etc.

Example
Get the first element from the following array:
import numpy as np
arr = np.array([1, 2, 3, 4])
print(arr[0])

Example
Get the second element from the following array:
import numpy as np
arr = np.array([1, 2, 3, 4])
print(arr[1])

Example
Get third and fourth elements from the following array and add them.
import numpy as np
arr = np.array([1, 2, 3, 4])
print(arr[2] + arr[3])

Pandas DataFrame

A Pandas DataFrame is a 2 dimensional data structure, like a 2 dimensional array,


or a table with rows and columns.

Example
Create a simple Pandas DataFrame:
import pandas as pd
Dept. of ECE Narayana Engineering College, Nellore 26
data = { "calories": [420, 380, 390], "duration": [50, 40, 45]}
#load data into a DataFrame object:
df = pd.DataFrame(data)
print(df)

Result
calories duration
0 420 50
1 380 40
2 390 45

Dept. of ECE Narayana Engineering College, Nellore 27


CHAPTER 5
REAL TIME PROJECT

Figure 5.1: Sample Project

Figure 5.2: Result 1

Dept. of ECE Narayana Engineering College, Nellore 28


Figure 5.3: Result 2

Figure 5.4: Result 3

Dept. of ECE Narayana Engineering College, Nellore 29


CHAPTER 6
CONCLUSION
Data science is one of the growing fields. It has become an important part of almost
every sector. It provides the best solutions that help to fulfill the challenges of the ever-
increasing demand and maintainable future. As the importance of data science is
increasing day by day, the need for a data scientist is also growing. Data scientists are the
future of the world. Thus, a data scientist must be capable of providing great solutions
which meet the challenges of all fields. To perform this, they should have proper resources
and systems which help them to achieve their goal.

Today,the nation is in the formative phase of data science education,where


educational organizations are pioneering their own programs,each with different
approaches to depth,breadth and curricular emphasis. It is too early to expert consensus
to emerge on certain best practices of data science education. However,it is not too early
to envision the possible forms that such practices might take.

Dept. of ECE Narayana Engineering College, Nellore 30


CHAPTER 7
FUTURE SCOPE
As most fields are emerging continuously, the importance of data science is also
increasing rapidly. Data science has influenced various areas. Its effect can be observed
in multiple sectors such as the retail industry, healthcare, and education. In the healthcare
industry, new medicines and techniques are being discovered continuously and there is a
requirement for better care for patients. With the help of data science techniques, the
healthcare sector can find a solution that helps to take care of the patients. Education is
another field where the benefits of data science can be seen clearly. The latest
technologies such as smartphones and laptops have now become an important part of the
education system. With the help of data science, better opportunities are created for the
students which enables them to enhance their knowledge.

Dept. of ECE Narayana Engineering College, Nellore 31


CHAPTER 8
REFERENCES
 Abelson, H.Sussman, G.J&Sussman,J. Structure and interpretation of Data
Science
 A book on data science by Dr.OssamaEmbarak,Data_Analysis_and Accessed on
27-06-2020
 Python website https://www.python.org/doc/essays/blurb/ Accessed on 29-06-
2020.
 Matplotlib https://en.wikipedia.org/wiki/Matplotlib Accessed on 04- 07-2020
 Numpy online https://en.wikipedia.org/wiki/NumPy Accessed on 07-07- 2020 56

Dept. of ECE Narayana Engineering College, Nellore 32

You might also like