Basic Introduction to Pandas: Pandas Series(Part 1)

Abhishek Jaiswal
Analytics Vidhya
Published in
3 min readAug 23, 2020

--

Photo by Markus Spiske on Unsplash

Pandas is a software library written for the Python programming language for data manipulation and analysis. In particular, it offers data structures and operations for manipulating numerical tables and time series. Let’s get dive into the Basics of Pandas.

Case 1: Basic of Pandas Series

Fig. 1

First of all, we should write some data into the Pandas Series as Above. The difference between a Python List and Pandas Series is that Pandas Series Index can be Modified and can be called by its name as in fig.5 and stored he data in the g7_pop variable.

Fig 2
  1. g7_pop.name -In the Series above, we can add some details to the row for which we added the data.
Fig. 3

2. g7_pop.dtype -It finds the Datatype of the row in general for which we wish to know.

3. g7_pop.values -It finds the values for any row we wish to know.

4. type(g7_pop.values) -It finds the type of any row.

Fig. 4

5. g7_pop[index_num] -It finds the value stored at that index_num.

6. g7_pop.index -It finds the total index details of that row.

Fig. 5

We can assign the Index number to some values by which we can refer it that by index.

Fig. 6

We can also create the Series by. Series method as shown in Fig. 6.

Case 2: Indexing and Slicing

Fig. 7

In Fig. 6, we changed the index number to index value and we can refer to any column by directly accessing it by index_value

  1. g7_pop[index_value] -To print the value of that column by its index_value.
  2. g7_pop.iloc[index_number] -Prints the value of that column by its Index_number.Here,iloc stands for Integer Location
  3. g7_pop.loc[index_value] -Prints the value of that column by its Index_value.Here,loc stands for Location.
  4. g7_pop[initial:final: jump] -Prints the sliced value inclusive starting_value to inclusive final_value and the jump. By default, the jump is set to 1( if not mentioned).

Case 3: Boolean Functions and Mathematical Operations.

Fig. 8
  1. g7_pop >70 -It returns either True or False for the value stored in g7_pop.
  2. g7_pop[g7_pop > 70] -It Returns the value for the satisfying condition within braces.
  3. g7_pop.mean() & g7_pop.std() -It returns the mean/average and the standard deviation value
Fig. 9

We can also change the value for any column by g7_pop.iloc[..] = value number.

In the Next Part, we will have some Introduction to Pandas Dataframe and reading the CSV files.

You can refer to the data used in this Project here ,

https://drive.google.com/file/d/1D2Ea417uXk9ryK6_TV4Wb5uakaEn0SSH/view?usp=sharing

--

--