Posts

Introduction to Series Data Structure in Pandas Library

Image
Series is one of the fundamental data structures of the Pandas Library which is built on top of  NumPy Library. Series is actually is one dimensional labelled array object similar to list, dict or column of a table. Series object which can hold any data forms (i.e. Python dict, ndarray and scalar values e.g. 5) will assign labelled index to each item in its Series. And by default each item of a  Series will be assigned index labels from 0 to (N-1) , where N is total number of Series items.  How to create a Series data structure? Using Pandas library, we can create Series using the following constructor highlighted below; s = pandas.Series(data, index, dtype) From the above line of code, we used parameters as arguments to Series functions defined below; data may be of any form (i.e. Python dict, ndarray and scalars) that we store it as contents or items of Series index is the list of unique axis labels equal to the length of data. If the index labels is not defi

How to generate Bar Graph using Matplotlib Library

Image
Bar chart is a special type of graph in which numerical values of some data are represented by rectangular bars of equal widths among some discrete set of items to which it varies its length.  This type of charts has a discrete range of data which helps in providing visual representation of categorical data. In this tutorial post, we will discuss here about how to generate Bar plots and customize it using Matplotlib python library. And for that purpose, we will demonstrate example of plotting data of visitor’s population entering a museum during different years. For using Matplotlib library for plotting, you must first have to import Matplotlib library and use functions provided by this awesome library. Also, you will use inline magic function %matplotlib inline so that you may display resultant figure after every line of code In[1]: import matplotlib.pyplot as plt %matplotlib inline Now you will define data of populations and years with variable name po

How to create Scatter Plot using Matplotlib Library

Image
Scatter plot is one of the commonly used plots which is also thought as cousin of line plot in data visualization or data science. In this tutorial post we will discuss about scatter plot about how to create it using Matplotlib library and customize different properties of this plot based on our needs in data visualization. In scatter plots, we represent points individually with circle, dot or any other shape instead of joining points by line segment as we mostly do in line plotting. Let’s demonstrate some examples about how to create scatter plots. For generating scatter plots, we must start with following code to use Matplotlib library by importing it in our Jupiter notebook. In[1]: import matplotlib.pyplot as plt import numpy as np % matplotlib inline After importing matplotlib.pyplot module and numpy library in notebook, you can now easily use functions provided from these libraries as shown below; In[2]: x=np.linspace( 0 , 10 , 40 ) # Defin

Introduction to Matplotlib Library for Data Visualization

Image
Data Visualization is one of the most important tasks in data analysis to explore and communicate our data. It is so broad field that many books have been written so far by great publishers which you can find on book stores. In this article, we will try to introduce  Matplotlib  library which is widely used for data visualization in python as data science toolkit to create quality plots ready for publications. Matplotlib  is generally a two-dimensional (2D) MATLAB style plotting library of python, created by John D. Hunter in 2002. Since then, John D. Hunter also cooperated with Fernando Perez (Creator of IPython) and others to make IPython work with this Matplotlib library for scientific computing. This cross-platform supported library is built on NumPy library designed to work with SciPy stack library for scientific computations.  This library first commercially released on 2003 can be used in Python and IPython shells, Python scripts, Jupiter notebooks, web-applic

How to apply Operations on Arrays using NumPy Library

Image
NumPy Library provides lot of useful function that you can apply on n-dimensional arrays(ndarray) for scientific or mathematical computations.  In the subsequent sections we will discuss following functions provided by NumPy Library after importing it in our program. shape( )                        If you have an ndarray and you want to determine its dimensions then you may use  shape( )  for this purpose as shown in example below; From the above output result, i.e.  ‘Out[3]: (3,3)’   after using shape( ) function, you find that you have created an array of dimension   3x3 . Arithmetic Operations  (+,  -, *, /) You can use arithmetic operations i.e. addition, subtraction, multiplication and division to ndarray object. Using arithmetic operations when you use scalar value as second operand with first operand as ndarray, you will notice that you are adding/subtracting/multiplying/diving each entry of ndarray with scalar you defined as shown in following

How to declare an Array Object (ndarray) using NumPy Library

Image
NumPy which stands for “ Num erical  Py thon”  is a fundamental package of python used for data analysis and scientific computing projects.  NumPy  Library provides a feature of n-dimensional array object by which we can contain our large data in flexible way, which is very fast to make scientific or mathematical operations on whole data set that it holds. There are many ways by which you can create or declare n-dimensional arrays.  In this article, we will discuss about some useful functions for this purpose and learn about how to declare an n-dimensional array using following basic functions discussed below:           array( )           reshape( )           zeros( )           ones( )           arange( )           eyes( )           identity( )           empty( )           linspace( )           repeat( )           vstack( )           hstack( ) array( ) Suppose, we want to declare an array with name  'my_array'  of 3x3 dimensions having integer el

How to get started with Python on Windows

Image
Python programming language, created by  Guido van Rossum  is really a wonderful and powerful language and it is nowadays widely used high-language programming language for general purpose programming. Python does not come up pre-installed with any version of Windows OS as compared to other Operating Systems i.e. Linux and Unix in which python is already installed in it. Using this post of tutorial, you can easily install python on your Windows 10 Operating systems by performing following steps mentioned below: Step 1: Download a recent version of Python Installer First of all you have to download a installer file of python by browsing to webpage  www.python.org  as shown in following snapshot. After browsing to said link, when you hover over  Download  on navigation menu on page as highlighted below, you will be provided two options of two versions of python installers i.e.  3.x.x  and 2.x.x.  In this tutorial you will opt to download Python 3 by clicking on  Python 3.6