NumPy Arrays

Pandas or Python Pandas is Python's library for data analysis. Pandas has derived its name from “ panel data system”, which is a term for multidimensional, structured data sets.

Today, Panda has become a popular choice for data analysis. Data analysis refers to process of evaluating big data sets using analytical and statistical tools so as to discover useful information and conclusion to support decision- making.
Pandas makes available various tools for data analysis and make it a simple and easy process as compared to other available tools.
The main author of Pandas is Wes McKinney .
Pandas is an open source library built for Python programming language. Pandas offers high-performance, easy- to-use data structure and data analysis tools.
In order to work with pandas you need to import pandas library in your python environment.

Why Pandas -

Pandas is the most popular library in the Python ecosystem for data analysis.
Pandas is capable of many tasks including:
It can read or write in many different formats (integer, float, double, etc)
It can calculate in all ways data is organized.
It can easily select subsets of data from bulky data sets and even combine multiple datasets together.
It has functionality to find and fill missing data.
It has functionality to find and fill missing data.
It allows us to apply operations to independent groups within data.
It supports advanced time-series functionality (Time series forecasting is the use of a model to predict future values based on previously observed values.)

In other words, Pandas is best at handling huge tabular data sets comprising different data formats.

NumPy Arrays-

Before we start with Pandas we should know about NumPy arrays because Pandas some functions return result in form of NumPy arrays , so if we know what a NumPy array is, we will be able to easily identify.

NumPy (‘Numerical Python' or ‘Numeric Python') is an open source module of Python that offers functions for fast mathematical computation on arrays and matrices.

In order to use NumPy, we need to import it:
  import numpy as np
The above statement has given np as an alias name for numpy module. Once imported with as , we can use both names i.e., numpy or np for eg., numpy.array( ) is same as np.array( )

Array refers to a named group of homogeneous (of same type) elements.

For example , students array contains no. of students in each house. Students array here has 4 entries as [89, 97, 87, 99]
Students is an array that represents number of students in each house. Like lists, we can access individual elements by giving index with array name.
Students[1] will give details about 2 nd House. i.e., 97

What NumPy array are like and how we can use them-

A NumPy array is simply a grid that contains values of the same/ homogeneous type. NumPy Arrays come in two forms:
 I-D (one dimensional arrays) Known as Vectors (have single row/ column only).
 Arrays known as Matrices (can have multiple rows and columns)

Creating NumPy arrays using Python lists


The [ ] after the object is known as the indexing operator. We can access elements of multi-dimensional arrays as

<array. [row][ col ]>
    Or as
<array>[row, col ]

We can check data type of a NumPy array's elements using < arrayname >. dtype
>>> a7.dtype
The default datatype is float in an NumPy array.
All elements must be of same datatype .
The shape attribute of an array indicate the number of elements along each axes.
In a NumPy array, dimensions are called axes. The number of axes is called rank.

NumPy Arrays vs Python Lists-

-   Unlike Python lists, once a NumPy array is created, you cannot change its size.
-    Every NumPy array can contain elements of homogenous type i.e., all its elements have one and only one(same) data type.
-    An equivalent NumPy array occupies much less space than a Python list.
-    NumPy arrays support vectorized operations, i.e., if you apply a function, it is performed on every item (element by element) in the array unlike list.


Ways to create NumPy Arrays-

1. Creating NumPy arrays using Python lists. (All ready mentioned above)

2. Creating empty arrays using empty( ) function-

After creating empty array, if you display the contents of the array, it will display any random contents, which are uninitalized garbage values.

3. Creating arrays filled with zeros using zeros( ) function-

4. Creating arrays filled with 1's using ones( ) function-

5. Creating arrays with a numerical range using arange () function-

The arange () function is similar to Python's range() function but it returns an ndarray in place of Python list returned by range() of Python. End value is not counted in arange ().
The arange () creates a NumPy array with evenly spaced values within a specified numerical range.
            < arrayname >= numpy.arange([start], stop,[step],[dtype])

6. Creating arrays with a numerical range using linspace( ) function- It is used to provide evenly spaced elements between two given limits. We have to provide , the start value, the end value and number of elements to be generated for the ndarray . The end value is also calculetd in linspace.
           < arrayname >= numpy.linspace ( <start>, <stop>, <number of values to be generated>)

Tea Or Coffee

Python Downloads

Reindexing and Label Alteration
Function Application –Python pandas
Bar Charts and Histograms and Quantile
Plottint with PyPlot-2


Ways to Keep Your Brain Healthy