-
Notifications
You must be signed in to change notification settings - Fork 0
Home
It is a python library that is used for working with datasets. Pandas has functions for analyzing, cleaning, exploring and manipulating data.
It allows us to analyze big data and make conclusions based on statistical theories.
The source code for Pandas is located at this github repository https://github.com/pandas-dev/pandas
First we import pandas in code through: (import pandas as pd) then we create dictionary of our needed dataset, after this we convert the dictionary into pandas "DataFrame".
A DataFrame is essentially a table with rows and columns, where:
--> Each key in the dictionary becomes a column header.
--> Each list becomes the values under the respective columns.
Finally we print our dataframe for output using "print" function.
What is a Series?
A Pandas Series is like a column in a table. It is a one-dimensional array holding data of any type. _Syntax : "pd.series()" _
Labels are used to identify and access data in Series and DataFrames. They provide a way to refer to rows and columns using meaningful names or indices, instead of just numerical positions. "With the 'index' argument, you can name your own labels."
Data sets are usually multi-dimensional tables called DataFrames. "Series is a column, a DataFrame is whole table" Pandas use the "loc" attribute to return one or more specified row(s)
If data sets are stored in a file, Pandas can load them into a DataFrame. Syntax : "pd.read.csv('file_name.csv' )" Full Form Of CSV is "COMMA SEPERATED FILES" NOTE: File should be present in the current directory for the above code to work. If it is in a different directory, you will need to provide the full path to the file.
"Tip: use to_string() to print the entire DataFrame."
The number of rows returned is defined in Pandas option settings.
We can check our system's maximum rows with the pd.options.display.max_rows statement.
Big data sets are stored as JSON. It is a plain text, but has format of object.
SYNTAX: pd.read_json()
-JSON objects have same format as Python dictionaries. -If your JSON code is not in a file, but in a Python Dictionary, you can load it into a DataFrame directly.
The head() method returns the headers and a specified number of rows, starting from the top. SYNTAX: print(pd.head())
tail() method for viewing the last rows of the DataFrame.
The tail() method returns the headers and a specified number of rows, starting from the bottom.
The DataFrames object has a method called info(), that gives us more information about the data set.
It means fixing bad data in your data set.
One way to deal with empty cells is to remove rows that contain empty cells.
Syntax: new_data = data.dropna()
NOTE By default, the dropna() method returns a new DataFrame, and will not change the original.
If we want to change the original DataFrame, we use ( inplace = True ) argument
Syntax: df.dropna = inplace = True