Pandas And Python

Apr 18, 2024

Panda VS Python

Pandas are not only incredibly adorable animals and awesome Kung Fu fighters; Pandas also happens to be an incredibly powerful data analysis library that can be used in Python. Pandas is not built into Python meaning you cannot simply import the library to begin using it, but that is an easy fix and can be corrected by simply installing the package, Pandas. This library can allow you to connect and use data stored on csv files. This is not particularly new as one could open up a file by using “with open” in Python, but it’s not nearly as user friendly.

If you take this data below:


The data inside this csv file can be opened in a file by using:

with open(“insert_file_name.csv”) as data_file:
    data = data_file.readlines()
#Result is
['day,temp,condition\n', 'Monday,12,Sunny\n', 'Tuesday,14,Rain\n', 'Wednesday,15,Rain\n', 'Thursday,14,Cloudy\n', 'Friday,21,Sunny\n', 'Saturday,22,Sunny\n', 'Sunday,24,Sunny']

That is difficult to read and not user friendly, however Pandas not only makes it as easy as just one step, but also presents it as a table to further the user experience and comprehension.

data = pandas.read_csv(“insert_file_name.csv”)
#Result is#
         day  temp condition
0     Monday    12     Sunny
1    Tuesday    14      Rain
2  Wednesday    15      Rain
3   Thursday    14    Cloudy
4     Friday    21     Sunny
5   Saturday    22     Sunny
6     Sunday    24     Sunny

The best part in my opinion is getting hold of one singular column is as easy as naming the column desired.

data = pandas.read_csv("weather_data.csv")
0    12
1    14
2    15
3    14
4    21
5    22
6    24

You could even get hold of a row by using the method iterrows() and an if statement.

data = pandas.read_csv("weather_data.csv")
for (index, row) in data.iterrows():
    if == "Monday":
day          Monday
temp             12
condition     Sunny
Name: 0, dtype: object
Justin.TadrosJustin Tadros is a Project Manager and Data Analyst at The Training Boss. Justin has a bachelor degree in Theater performance from Rollins College and currently pursuing his Masters in business at the University of Center Florida.  Justin is certified on Microsoft Power BI and Progress Sitefinity Sales accreditation with on going training on Python and CMS technologies.  Justin performs in theaters in Orlando, Boston, Alaska and stand up comic whenever the opportunity arises.  His passion for performing and bringing incredible customer service to any industry he approaches is second to his commitment, dedication and hard work.


Playlist for Sitefinity on YouTube


Playlist for Microsoft Fabric on YouTube

Copyright © 2024 The Training Boss LLC

  Developed with Sitefinity 15.1.8321 on ASP.NET 8