<jupyter_start><jupyter_text>Series 1d array like object containing a sequence of values and an associated array of data labels called its indexA good way to think of a series is a fixed-length, ordered dict.<jupyter_code>import pandas as pd
obj = pd.Series([4,7,5,4])
obj
#numbers on left are the index while those on the right include the series
#You can get the array representation of the index using .values and .index:
obj.values
#obj.index
#To create a series with an index indentifying each data point with a label
obj = pd.Series([1,2,3,4], index=['a', 'b', 'c', 'd'])
obj                
#To give replace index values with new ones
obj.index = ['bob', 'niall', 'jack', 'will']
obj<jupyter_output><empty_output><jupyter_text>Comared with NumPy, you can index a series using the labels themselves rather than just the index number<jupyter_code>obj['bob']<jupyter_output><empty_output><jupyter_text>Series and Index both have a .name attribute for naming both respectively.obj.name = ''obj.index.name = ''  Can use boolean, multiplication and other math functions we saw in NumPy. The index values will always remain intact.    Passing a Dictionary<jupyter_code>#to pass a dictionary to create a Series:
dict1 = {'a': 1, 'b': 50, 'c': 89}
obj = pd.Series(dict1)
obj.name = 'Dict_Series'
obj<jupyter_output><empty_output><jupyter_text>When passing a dictionary to a Series, the index will contain the keys in the sorted order as shown above. To override this (keys is variable contianing a list):1. We can rename the index values2. We can pass a list of index values when initially creating the series<jupyter_code>#1
keys = ['c', 'a', 'f']
obj.index = keys
obj
#2
obj1 = pd.Series(dict1, index = keys)
obj1<jupyter_output><empty_output><jupyter_text>Note: A new list was created called keys. However this values must match the keys already in the dictionary otherwise we get a NaN: Not a Number - the equivalent to null values / missing values. 'f' was never a key in the original dict<jupyter_code>pd.isnull(obj1)
pd.notnull(obj)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09095307208514755, 'fraction_numerical': 0.011611030478955007, 'mean_word_length': 5.100294985250738, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '149698', 'license': 'MIT', 'n_tokens_mistral': 637, 'n_tokens_neox': 622, 'n_words': 275, 'path': 'Notes/Pandas/Getting Started with pandas/pandas Data Structures/Series.ipynb', 'repo_name': 'yorken2/DataAnalysis-Notes', 'size': '2067'}