What is Pandas? || Intoduction about Pandas. Part 1

Cyclops
Star Gazers
Published in
4 min readAug 20, 2022

What is Pandas?

Pandas is a Python library used for working with data sets. It allows us to analyze data and make conclusion. Pandas can clean messy data sets, and make them readable and relevant.

How to download Pandas?

If you use Anaconda, you must open Anaconda terminal and write the code given below:

conda install pandas

Pandas can be installed via pip from PyPi:

pip install pandas

Pandas support the integration with many file formats or data sources out of the box(csv, excel, sql, json, …). Importing data from each of these data sources is provided by functions with the prefix read_. Similarly, the to_ methods are used to store data

Import pandas to your project:

import pandas as pdimport numpy as npfrom numpy.random import randn

Object Creation: Creating a series by passing a list of values, letting pandas create a default integer index:

s = pd.Series([1, 2, 3, 4, 5, np.nan, 7, 8])s
date = pd.date_range(‘20220820’, periods = 6)
date
dataframe = pd.DataFrame(randn(6, 4), index = date, columns = [‘A’,’B’,’C’,’D’])
dataframe
Instuction of DataFrame

Note: DataFrame datatype is the object, not looking at the fact that each element is in separate datatype

Viewing Data

View the top and the buttom rows of the frame:

head()

This function returns the first `n` rows for the object based on position. It is useful for quickly testing if your object has the right type of data in it. For negative values of `n`, this function returns all rows except the last `n` rows

dataframe.head()
dataframe.head(3)
dataframe.head(-2)

tail()

This function returns last `n` rows from the object based on position. It is useful for quickly verifying data, for example, after sorting or appending rows. For negative values of `n`, this function returns all rows except the first `n` rows

dataframe.tail(3)
dataframe.tail(-2)

to_numpy()

Dataframe.to_numpy() gives a Numpy representation of the underlying data. This can be expensive operation when your Datafrane has columns with the different data types.

Note: Dataframe.to_numpy() does not include the index or column labels in the output.

dataframe.to_numpy()

Parameters
— — — — —
dtype : str or numpy.dtype, optional. || The dtype to pass to :meth:`numpy.asarray`.
copy : bool, default False. || Whether to ensure that the returned value is not a view on another array. Note that ``copy=False`` does not *ensure* that ``to_numpy()`` is no-copy. Rather, ``copy=True`` ensure that a copy is made, even if not strictly necessary.
na_value : Any, optional. The value to use for missing values. The default value depends on `dtype` and the dtypes of the DataFrame columns.

describe()

If you want to see your data with some statistic summary you must use this method

dataframe.describe()

For transposing your data

dataframe.T

--

--

Cyclops
Star Gazers

Data-Scientist/Analyst || Founder of The-Black. || Editor of Star Gazers publication.