How to Use Pandas with Series

Posted on

Introduction

This is an article showing on how to use Pandas with Series. As it is already exist in the explanation from the previous article, generally there are two types of data structure where the Pandas library handled. That article explaining the data type exist with the title of ‘How to Use Pandas’ in this link. Before going further on the usage of Pandas library with Series, it is important to understand about Series first. In this case, according to the definition exist in this link which is part of Pandas documentation, Series is is a one-dimensional labeled array capable of holding any data type (integers, strings, floating point numbers, Python objects, etc.).

How to Use Pandas with Series

So, before beginning on further description about how to use pandas with DataFrame, there are lots of important aspects. In other word, a variable or an object with DataFrame as its data structure will have various functionality. One of the most basic functionality which is very important for further process is just to define or to print that variable or object. An important thing before that, just make sure Pandas library is already exist. In other words, before going on further, there are several requirements which is specifically mandatory so that the functionalities of the DataFrame data structure is available. As a reference, just take a look in the previous article in this link. It is an article with the title of ‘How to Use Pandas’ for specifying about how to install Pandas library.

How to Define DataFrame Using Pandas

After installing Pandas library, it will be possible for defining variable with DataFrame as the data structure. Below are steps for doing it  :

  1. First of all, after fulfilling the requirements, just execute the command line interface. It is very useful for executing a command as it will use the command line interface. Furthermore, since it is using using Microsoft Windows operating system, just run the Command Prompt. In the Command Prompt, just execute command further for demonstrating how to define DataFrame using Pandas. Below, just start with the Command Prompt first  :

    Microsoft Windows [Version 10.0.22000.856]
    (c) Microsoft Corporation. All rights reserved.
    
    C:\Users\Personal>
    
  2. Next, execute ‘python’ to enter the python command console as follows:

    Microsoft Windows [Version 10.0.22000.856]
    (c) Microsoft Corporation. All rights reserved.
    
    C:\Users\Personal>python
    Python 3.10.5 (tags/v3.10.5:f377153, Jun  6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
  3. Another step onward, just type ‘import pandas as pd’ to import the Pandas library below :

    Microsoft Windows [Version 10.0.22000.856]
    (c) Microsoft Corporation. All rights reserved.
    
    C:\Users\Personal>python
    Python 3.10.5 (tags/v3.10.5:f377153, Jun  6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import pandas as pd
    >>>
  4. Following after, define the Series by typing the following command :

    Microsoft Windows [Version 10.0.22000.856]
    (c) Microsoft Corporation. All rights reserved.
    
    C:\Users\Personal>python
    Python 3.10.5 (tags/v3.10.5:f377153, Jun  6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import pandas as pd
    >>> list = [1,2,3,4]
    >>> list_data_set_series = pd.Series(list)
    
  5. In order to prove back the content of the Series data set, just print it as follows continuing the previous step :

    >>> print(list_data_set_series)
    0 1
    1 2
    2 3
    3 4
    dtype: int64
    >>>

One thought on “How to Use Pandas with Series

Leave a Reply