<jupyter_start><jupyter_text>Chapter I: Series Cheat Sheet 1: What is a Pandas Series?A Pandas series object is a 1-D labelled array. In very simple terms it's a single column; having it's own **name** (header), **index** (row labels), etc. You can think it like as a python list on steroids! Pandas series or Series object in general stores data in a sequential order just like a list in a single column. Things to rememberA series should ideally be consistent, meaning it should have elements of single datatype. This is **not** mandatory but it surely helps with optimization of the code. If the series object has multiple datatypes, pandas will consider the type of entire series as 'object' (string). If the series object has a consistent (single) datatype, pandas consider the type of entire series to be the type of individual element (check the below examples). Series with multiple datatypesIn the below example we have created a list called as **test_list** which holds 4 elements each with different datatypes. But if you see the type of pandas series object you'll notice that pandas considers the datatype as **object** (internal pandas lingo for **string**)<jupyter_code>test_list = ['one', 2, 3.0, ['this', 'is', 'a', 'test']]

type(test_list)
import pandas as pd

pd.Series(test_list)
type(pd.Series(test_list))<jupyter_output><empty_output><jupyter_text>Series with single datatypeIn the below example we have created the same **test_list** but now it holds 4 elements with single datatype, **integer**. Pandas series will now consider the datatype of the entire series object as **int64** (internal pandas lingo for **integer**).<jupyter_code>test_list = [1, 2, 3, 4]

type(test_list)
import pandas as pd

pd.Series(test_list)
type(pd.Series(test_list))<jupyter_output><empty_output><jupyter_text>Series objectA pandas series method looks something like this:pd.Series(**data**=None, **index**=None, **dtype**=None, **name**=None, **copy**=False, **fastpath**=False)***Important parameters:*****data:** list, array-like object or dictionary.**index:** list of indices.**dtype:** datatype of the output series and **name:** header (name) of the series.  2. How to create a Pandas series object?Series object can be created using either a list/array-like object or a dictionary. Creating a Pandas series with list/array-like objectIts simple. Just pass the list to the **Series** constructor method.<jupyter_code>import pandas as pd

android_version_names = ['astroboy', 'bender', 'cupcake', 'doughnut', 'éclair', 'froyo',
                         'gingerbread', 'honeycomb', 'icecream sandwich', 'jellybean',
                         'kitkat', 'lollipop', 'marshmallow', 'nougat', 'oreo', 'pie']

pd.Series(android_version_names)
type(pd.Series(android_version_names))<jupyter_output><empty_output><jupyter_text>You will notice the numbers starting from 0 at left, these are called index (indices). Pandas automatically adds them if you don't intend to use your own indices. Creating a Pandas series with a list/array-like object and with our own indicesThis will create a Pandas series object using index that we pass seperately. This is done by passing another list (own list of indices) to the **index** parameter.pd.Series(data=None, **index=None**, ...) Note:Number of indices should be equal to the number of elements in the series (list).<jupyter_code>android_version_names = ['astroboy', 'bender', 'cupcake', 'doughnut', 'éclair', 'froyo',
                         'gingerbread', 'honeycomb', 'icecream sandwich', 'jellybean',
                         'kitkat', 'lollipop', 'marshmallow', 'nougat', 'oreo', 'pie']

android_versions = [1.0, 1.1, 1.5, 1.6, 2.0, 2.2, 2.3, 3.0, 4.0, 4.1, 4.4, 5.0, 6.0, 7.0, 8.0, 9.0]

pd.Series(data=android_version_names, index=android_versions)
type(pd.Series(data=android_version_names, index=android_versions))<jupyter_output><empty_output><jupyter_text>Creating a Pandas series with a dictionaryA python dictionary consists an unordered collection of key-value pairs. So, here the keys become the index and the values remain the values in the series object. You don't need to pass seperate list for index. Note:For python 3.6 and above the order of dictionary is maintained.If indices are passed, it'll overwrite the values and replace them with **NaN** which means Not a Number (None/Null/Missing) values.<jupyter_code>android_version_dict = {
    'a': 'astroboy',
    'b': 'bender',
    'c': 'cupcake',
    'd': 'donut',
    'e': 'eclair',
    'f': 'froyo',
    'g': 'gingerbread',
    'h': 'honeycomb',
    'i': 'icecream sandwich',
    'j': 'jellybean',
    'k': 'kitkat',
    'l': 'lollipop',
    'm': 'marshmallow',
    'n': 'Nougat',
    'o': 'oreo',
    'p': 'pie',
}

pd.Series(data=android_version_dict) # without index
pd.Series(data=android_version_dict, index=android_versions) # with index<jupyter_output><empty_output><jupyter_text>3. How to name the Series object OR How to add header to the Series object?This name is similar to the **Header** or **Column name** in Excel. This is done by passing string (name) to the **name** parameter.pd.Series(data=None, index=None, **name=None** ...)<jupyter_code>pd.Series(data=android_version_names, index=android_versions, name='Android Versions')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11876888217522659, 'fraction_numerical': 0.00944108761329305, 'mean_word_length': 4.96509009009009, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '449675', 'license': 'Apache-2.0', 'n_tokens_mistral': 1644, 'n_tokens_neox': 1572, 'n_words': 624, 'path': 'pandas/series_1 (basics).ipynb', 'repo_name': 'xames3-old/cheat_sheet', 'size': '5296'}