Table of Contents
What is Pandas?
Below is the excerpt from https://pandas.pydata.org/ :
pandas is an open source, BSD-licensed library providing high-performance, easy-to-use data structures and data analysis tools for the Python programming language.
pandas is a NumFOCUS sponsored project. This will help ensure the success of development of pandas as a world-class open-source project, and makes it possible to donate to the project.
I described Pandas as powerful tool to manipulate data within Python. It is like you have a steroids version of spreadsheet within Python.
How to install Pandas?
Check first if you have the pandas Python package installed in your system. You can use pip3 list to check.
pip3 list
If you see something like:
pandas 0.23.4
You have pandas Python package installed in your system and you are good to go. If you do not see it, you can install pandas Python package by using pip3 install
pip3 install pandas
Basics of Pandas
Making a basic dataframe
Pandas is all about dataframe. Dataframe is a set of data where Pandas can manipulate. Below is the basic example of converting the dataset into Pandasa dataframe.
import pandas as pd
data = {'Toyota':["Corolla", "Camry", "Tacoma", "RAV4"]}
df = pd.DataFrame(data)
print(df)
You will see an output something like below:
Toyota
0 Corolla
1 Camry
2 Tacoma
3 RAV4
If you want to sort this in ascending order, you do this by using df.sort_values
Example:
print(df.sort_values(['Toyota'], ascending=True))
The output will be something like below:
Toyota
1 Camry
3 Corolla
0 Rav4
2 Tacoma
Recent Posts
- How to convert MD (markdown) file to PDF using Pandoc on macOS Ventura 13
- How to make MD (markdown) document
- How to Install Docker Desktop on mac M1 chip (Apple chip) macOS 12 Monterey
- How to install MySQL Workbench on macOS 12 Monterey mac M1 (2021)
- How to install MySQL Community Server on macOS 12 Monterey (2021)