Advanced Python
Python OOPs Concepts:-
- Everything Is An Object.
- Object-Oriented Programming means and how it ties together with Python classes.
- OOP is one of the most powerful tools of Python.
- Python is a great programming language that supports OOP.
Major principles of object-oriented programming :-
- Object
- Class
- Method
- Inheritance
- Polymorphism
- Data Abstraction
- Encapsulation
Object(Instances):- Object is a unique instance of a data structure that's defined by its
class. An object can be anything like - a student while designing a school's
record registry, or a pen in stationary's item management program, or a car in
manufacture's car database program.
it is a real entity.
it is a real entity.
Three
important characteristics by which it is identified:-
Identity:- Identity refers to some piece of information that can be used to
identify the object of a class. It can be the name of the student, the company
name of the car, etc.
Properties:- The attributes of that object are called properties. Like age,
gender, DOB for a student; or type of engine, number of gears for a car.
Behavior:- Behavior of any object is equivalent to the functions that it
can perform. In OOP it is possible to assign some functions to objects of a
class. Taking the example forward, like a student can read/write, the car can
accelerate and so on.
Class:- A class is a blueprint for any functional entity which defines its properties and its functions.
it is a collection of objects.
define a class in
Python, you can use the "class" keyword, followed by the class name and a
colon. Inside the class, an " init()" method has to be defined with "def". This is the
initializer that you can later use to instantiate objects
Note:-The self in Python is equivalent to the this pointer in
C++ and the this reference in Java and C#.
Example:-
class pyarun:
pass # An empty block
p = pyarun()
print(p)
Method:- A special kind of function that is defined in a class
definition.
it is an object behavior.
Inheritance:- Inheritance is the process by which one class takes on the attributes
and methods of another.
it is a process of deriving a new class from already existing class.
reuse code of existing object
inheritance is process of object re-usability.
it is a process of deriving a new class from already existing class.
reuse code of existing object
inheritance is process of object re-usability.
Example:-
Polymorphism (Many forms):-When a message can processed in different ways is call polymorphism .
Polymorphism means one name many forms, one function behavior different forms.
Polymorphism means one name many forms, one function behavior different forms.
Data
Abstraction:- Hides the implementation details and only provides the functionality to the user.
you can achieve abstraction using abstract class and interface.
abstraction means, showcasing only the required
things to the outside world while hiding the details.
abstraction is the process of hiding the working style of an object and showing the information of an object in understandable manner.
abstraction is the process of hiding the working style of an object and showing the information of an object in understandable manner.
Encapsulation:- Binding the data and code together as a single unit.
securing data by hiding the implementation details to user.
it is process of binding the data members and member functions into a single unit.
it is process of binding the data members and member functions into a single unit.
This binding of the properties to functions is called Encapsulation.
Data and functionality to bound together with in a class.
controlling the access of the data.
both abstraction and encapsulation word hand in hand because abstraction
say what details to be mode visible and encapsulation provides the level of access right to that visible details.
encapsulation is like your bag in which you can keep your pen, book etc. it means this is the property of encapsulation members and functions.
encapsulation is like your bag in which you can keep your pen, book etc. it means this is the property of encapsulation members and functions.
Python libraries for Data
Science:-
1. NumPy (Numeric Computation):- NumPy
stands for Numerical Python, library consisting of multidimensional array
objects and a collection of routines for processing those arrays.
2. SciPy (Scientific Computation):- SciPy is
another Python library for researchers, developers and data scientists. It
provides statistics, optimizations, integration and linear algebra packages for
computation. It is based on NumPy concept to deal with complex
mathematical problems.
3. PANDAS (Data Analysis Library):- PANDAS
referred as Python Data Analysis Library. It contains DataFrame as its main
data structure and DataFrame you can store and manage data from tables by
performing manipulation over rows and columns. They are in multiple formats
such as CSV, SQL, and HDFS or excel etc. Pandas contain many built-in methods for grouping,
filtering, and combining data, as well as the time-series functionality.
Series: - one-dimensional
Data Frames:
- two-dimensional
4. Scikit-Learn
(Machine Learning):-Scikit-learn is a Python
module integrating a wide range of state-of-the-art machine learning algorithms
for medium-scale supervised and unsupervised problems. It is one of the
best-known machine-learning libraries for python.
5.
Matplotlib: - 2D plotting library of Python is very famous among data
scientists for designing varieties of figures in multiple formats which is
compatible across their respected platforms. One can easily use it in
their Python code, IPython shells or Jupiter notebook, application servers.
With Matplotlib, you can make histograms, plots, bar charts, scatter
plots etc
6.
Tensorflow (Deep Learning):- open source library was designed by Google to compute
data low graphs with the empowered machine learning algorithms. It was designed
to fulfill high demand for the training neural networks work.
7.
Seaborn: - Seaborn was designed to visualize the complex statistical
models. It has the potential to deliver accurate graphs such as heat maps.
Seaborn was created on the concept of Matplotlib and somehow it is highly
dependent on that. Seaborn is essentially a higher-level API based on the Matplotlib
library. It contains more suitable default settings for processing charts.
Also, there is a rich gallery of visualizations including some complex types
like time series, joint plots, and violin diagrams.
8. NLTK:
- NLTK libraries stand for Natural Language
Toolkit. As per its name, this library is very helpful for accomplishing
Natural language processing tasks. Initially, it was developed to promote the
teaching models and other NLP enabled research such as the cognitive theory of
artificial intelligence and linguistic models etc.
Pandas tips and tricks:-
For selecting data use loc and
iloc
loc() is
label-based, which means that you have to specify rows and columns based on
their row and column labels.
iloc () is integer
position-based, so you have to specify rows and columns by their integer
position values (0-based integer position).
Top 10 Python APIs for your projects
Hi
ReplyDeleteThank you all for your valuable comments .
ReplyDeleteThanks for visiting our blog website.
ReplyDelete