cover

How to Use Python Pandas for Data Structures and Data Analysis.

sdjbsdkfbdskfj
2022-06-19
00:27
comments
No Rating

Available Platforms

rss

There are many different libraries that can be used to easily analyse any dataset. However, some libraries are more popular than others.

In this tutorial, we will take a look at the three most popular libraries for data analysis: Pandas, NumPy and Matplotlib.

Pandas is a library that provides easy-to-use data structures and data analysis tools. NumPy is a library that provides efficient numerical computing tools. Matplotlib is a library that provides plotting tools.
We will start by looking at how to use Pandas to load and examine data. We will then take a look at how to use NumPy to perform numerical operations on data. Finally, we will use Matplotlib to create visualisations of data.

Loading Data

The first step in any data analysis is to load the data. Pandas makes it easy to load data from a variety of sources, including CSV files, Excel files, JSON files and SQL databases.

In this example, we will load a CSV file containing data about countries. The file can be downloaded from here:
The read_csv() function returns a DataFrame object. A DataFrame is a two-dimensional data structure that contains columns and rows.

Viewing Data

Once the data has been loaded, we can start to examine it. The first thing we might want to do is to view the first few rows of data:

df.head()
which would return the following output:
We can also view the last few rows of data:
which would return the following output:
We can also view a summary of the data:
df.describe()
which would return the following output:
We can also view the data types of each column:

As we can see, the id column is of type int64, which means it contains integers. The name column is of type object, which means it contains strings.
Selecting Data

We can select data from a DataFrame using the following methods:

df[column_name]
df.loc[row_index]
df.iloc[row_index]
For example, if we wanted to select the id and name columns, we would use the following code:

df["BQ]
which would return the following output:

We can also use the loc and iloc methods to filter data. For example, if we wanted to filter the data to only include countries with an id less than 10, we would use the following code:

df.loc[df[“id”] < 10]
Sorting Data

We can sort data using the following methods:

df.sort_values(by=column_name)
 df.sort_values(by=column_name, ascending=False)
For example, if we wanted to sort the data by id in ascending order, we would use the following code:

df.sort_values(by=”id”)
Aggregation

We can aggregate data using the following methods:

df.mean()
df.median()
df.min()
df.max()
df.std()
df.sum()
In this tutorial, we have looked at one of the most popular library for data analysis: Pandas. We have seen how to use the library to load, examine and filter data.
Before you leave:

If you liked this article, don’t forget to give me a few claps, follow me and thus receive all updates about new publications.

If you enjoy reading stories like these, consider signing up to become a Medium member. It’s $5 a month, and you’ll receive unlimited access to stories on Medium.

So don’t wait — sign up now and start enjoying all that Medium has to offer.

https://www.hihonor.com/es/club/topicdetail/topicid-25014/
https://www.hihonor.com/es/club/topicdetail/topicid-25015/
https://www.cityballetsf.org/profile/w4tch-doctor-strange-2-0nline-123m0vies/profile
https://www.cityballetsf.org/profile/w4tch-lightyear-0nline-123m0vies/profile
https://www.cityballetsf.org/profile/w4tch-jurassic-world-dominion-0nline-123m0vies/profile
https://www.cityballetsf.org/profile/w4tch-spiderhead-0nline-123m0vies/profile
https://www.cityballetsf.org/profile/w4tch-minions-the-rise-of-gru-0nline-123m0vies/profile
https://www.cityballetsf.org/profile/w4tch-everything-everywhere-all-at-once-0nline-123m0vies/profile
https://www.cityballetsf.org/profile/w4tch-fantastic-beasts-3-0nline-123m0vies/profile
https://www.cityballetsf.org/profile/123m0vies-dragon-ball-super-123m0vies/profile
https://www.cityballetsf.org/profile/w4tch-jujutsu-kaisen-0-0nline-123m0vies/profile
https://www.cityballetsf.org/profile/dragon-ball-super-espan0l-latin0/profile
https://www.cityballetsf.org/profile/dragon-ball-super-v3r-cu3vana-pel1pus/profile
https://www.bctrains.com/profile/dragon-ball-super-hero-espan0l-latin0/profile
https://www.bctrains.com/profile/dragon-ball-super-v3r-pel1culas/profile
https://www.renegadepawsrescue.org/profile/dragon-ball-super-espan0l-latin0/profile
https://www.renegadepawsrescue.org/profile/dragon-ball-super-cuevana-pel1spus/profile
https://geany.org/p/ebWC6/
https://ideone.com/9JdqKE
https://yamcode.com/jjuh3miuxx
https://pasteio.com/xnVjM62t8A0T
https://p.teknik.io/yd07P
https://bitbin.it/O0QRDCDu/
https://notes.io/qtybw
https://txt.fyi/-/22169/ef2dbeb0/
https://controlc.com/ec94a6ff
http://cpp.sh/56zvk
https://paste2.org/9MGDKO74
https://ide.geeksforgeeks.org/160f8b5d-2c5c-46db-b027-38e479b0a1da
https://paiza.io/projects/oHc7lNWeO8jlMLkR9XylLg
https://paste.tbee-clan.de/dRZ8X
https://pastebin.com/rKC0fDFn
https://jsfiddle.net/bjvtgh7L/
https://rextester.com/SDDXR65667
https://www.wowace.com/paste/9535f182
https://www.twblogs.net/a/62af3c16cda75cc4150301cb
https://techplanet.today/post/how-to-use-python-pandas-for-data-structures-and-data-analysis
https://public.flourish.studio/visualisation/10392642/
https://zenodo.org/communities/how-to-use-python-pandas-for-data-structures-and-data-analysis
https://verbeke.cookpad-blog.jp/articles/729671