First, you have to import Pandas!
Creating a Series
You create a series by passing a list of values.
The output shows both the index on the left (0-3) and the values on the right.
To replace the default numerical index with desired values when creating a new series, pass the index parameter with a list of values the same length as the series.
Series – Selection & Slicing
Series can be indexed and sliced just liked strings, lists, and tuples.,/p>
If you have a custom index, you need to use the .loc[your_index_value] method to select a specific observation, or for slicing. When using the .loc[your_index_value] method for slicing, it returns the end value. Unlike traditional slicing where it returns one value before the end value. If confused, compare the example code and results above to the example code and results below.
Series to Series Operations
For the full list of attributes and methods available to be used with series, see the official Pandas documentation which can be found here.
If using any of the math operators built into Python, the operation will be conducted element-wise within the same row. Meaning, the value at index 0 for series 1 will be added, subtracted, multiplied, or divided by the value at index 0 for series 2.