INTRODUCTION TO PANDAS Pandas is a Python library used for working with data sets . It has functions for analyzing, cleaning, exploring, and manipulating data. The name "Pandas" has a reference to both "Panel Data", and "Python Data Analysis" and was created by Wes McKinney in 2008 . Pandas allows us to analyze big data and make conclusions based on statistical theories . Pandas can clean messy data sets, and make them readable and relevant .
Pandas is used for Data Analysis. Pandas work with large data sets and missing data. Data is represented in tabular way(Rows and columns). Pandas can merge or join two different data sets easily.
What Can Pandas Do? Pandas gives you answers about the data. Like: Is there a correlation between two or more columns? What is average value? Max value? Min value? Pandas are also able to delete rows that are not relevant, or contains wrong values, like empty or NULL values. This is called cleaning the data.
PANDAS DATA STRUCTURES There are three data structures of pandas, Series (1-dimensional) and DataFrame (2-dimensional ), Panel (Multidimensional) handle the vast majority of typical use cases in finance, statistics, social science, and many areas of engineering. For R users, DataFrame provides everything that R's data. frame provides and much more.
SERIES A Pandas Series is like a column in a table . It is a one-dimensional array holding data of any type . List is used as argument. Syntax: import pandas as pd pd.Series ( data,index )
Example:
Labels If nothing else is specified, the values are labeled with their index number. First value has index 0, second value has index 1 etc . Example: Return the first value of the series: print( myvar [0])
Output: x 1 y 7 z 2
DATA FRAMES Data sets in Pandas are usually multi-dimensional tables, called DataFrames . Series is like a column, a DataFrame is the whole table . A Pandas DataFrame is a 2 dimensional data structure, like a 2 dimensional array, or a table with rows and columns .
Example: Create a simple Pandas DataFrame : import pandas as pd data = { "calories": [420, 380, 390], "duration": [50, 40, 45] } #load data into a DataFrame object: df = pd.DataFrame (data) print( df )
Output:
DROPPING ENTRIES INDEXING Pandas provide data analysts a way to delete and filter dataframe using the .drop() method. Rows can be removed using index labels or column names using this method . Pandas drop row by index.
Creating a Pandas Dataframe . Output
Delete a Single Row in DataFrame by Row Index Label