0% found this document useful (0 votes)
10 views

Python Pandas For Data Analytics

Uploaded by

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

Python Pandas For Data Analytics

Uploaded by

22metadata
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Pandas

NOTEBOOK LINK : click here

What and why Pandas :


Pandas is a powerful library used for data manipulation and
analysis. It provides data structures like DataFrames and Series,
which are very useful for handling and analysing structured data.

How to install Pandas


In jupyter notebook :

If the program is installed already ,it simply shows “Requirement


already satisfied” or if it isn't installed it instals the program to the
file.
If you are installing in the terminal simply run pip install pandas
How to use Pandas :
If pandas is been installed in your python environment then simply
import it :

Series :
Series is a one-dimensional labelled array capable of holding any
data type (integers, strings, floating point numbers, Python objects,
etc.). It is similar to a column in a DataFrame or a single column in
an Excel spreadsheet. Each element in a Series has a label, known
as its index
● List to series :

When a list is converted to the series the index follows from


default 0 to n.
● dictionary to series :

When this type of multi key value dictionary is converted to series


then :

When the dictionary is converted to a series the key of the


dictionary are used as index
Dataframes :

1. DataFrames are similar to tables in a database or Excel


spreadsheets. They have rows and columns, where each
column can have a different data type (e.g., integers, floats,
strings).
2. DataFrames have labelled rows (index) and columns. Helps
us for easier data accessing.
3. You can add or remove rows and columns from a DataFrame,
making it highly flexible for various data manipulation.
4. Different columns in a DataFrame can store different types of
data (e.g., integers, floats, strings, dates).

Dictionaries to Dataframes :

The output will be a dataframe (we can check the datatype)


This is the data frame for the above dictionary

On a important note as the Dataframe looks alike its very complex


task to work on our analysis , because there should be a tabular
display on which we can easily work with our data
So to fix our display we will use :
After converting or importing into df use this code for better
display

But this code needs to be run every time after creating df to display
the better format , though we can use it as a function and reuse it ,
but definitely will not suggest it .

Don't worry there is a setting in pandas enabling which will give a


decent display to focus on our tasks :
Simply write this code and run before starting your work in
notebook

**In next section the outputs u will see are based on the same enabled option**
Importing a csv file :
We can import files like csv, JSON , excel , SQL in Python Pandas
this is our employee.csv file that we will import in pandas

➢ To import csv in Pandas simply :

The output looks like :

The df.head() displays the top rows (5 rows by default)

The df.tail() displays the bottom rows (5 rows by default)

You might also like