<jupyter_start><jupyter_text>Vectorized Operations- not necessary to write loops for element-by-element operations- pandas' Series objects can be passed to **_MOST_** NumPy functionsdocumentation: http://pandas.pydata.org/pandas-docs/stable/basics.html<jupyter_code>import pandas as pd
import numpy as np
my_dictionary = {'a' : 45., 'b' : -19.5, 'c' : 4444}
my_series = pd.Series(my_dictionary)
my_series<jupyter_output><empty_output><jupyter_text>add Series without loop<jupyter_code>my_series + my_series
my_series<jupyter_output><empty_output><jupyter_text>Series within arithmetic expression<jupyter_code>my_series + 5<jupyter_output><empty_output><jupyter_text>Series used as argument to NumPy function<jupyter_code>np.exp(my_series)<jupyter_output><empty_output><jupyter_text>A key difference between Series and ndarray is that operations between Series automatically align the data based onlabel. Thus, you can write computations without giving consideration to whether the Series involved have the same labels.<jupyter_code>my_series[1:]
my_series[:-1]
my_series[1:] + my_series[:-1]<jupyter_output><empty_output><jupyter_text>Apply Python functions on an element-by-element basis<jupyter_code>def multiply_by_ten (input_element):
    return input_element * 10.0
my_series.map(multiply_by_ten)<jupyter_output><empty_output><jupyter_text>Vectorized string methodsSeries is equipped with a set of string processing methods that make it easy to operate on each element of the array. Perhaps most importantly, these methods exclude missing/NA values automatically.<jupyter_code>series_of_strings = pd.Series(['A', 'B', 'C', 'Aaba', 'Baca', np.nan, 'CABA', 'dog', 'cat'])

series_of_strings.str.lower()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09855907780979827, 'fraction_numerical': 0.009798270893371758, 'mean_word_length': 8.041666666666666, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '156271', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 573, 'n_tokens_neox': 549, 'n_words': 144, 'path': 'python-scripts/data_analytics_learn/link_pandas/Ex_Files_Pandas_Data/Exercise Files/03_02/Final/Vector Ops.ipynb', 'repo_name': 'adityaka/misc_scripts', 'size': '1735'}