<jupyter_start><jupyter_text>NumPy Universal FunctionsIf the data within a DataFrame are numeric, NumPy's universal functions can be used on/with the DataFrame.<jupyter_code>import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(10, 4), columns=['A', 'B', 'C', 'D'])
df2 = pd.DataFrame(np.random.randn(7, 3), columns=['A', 'B', 'C'])
sum_df = df + df2
sum_df<jupyter_output><empty_output><jupyter_text>NaN are handled correctly by universal function<jupyter_code>np.exp(sum_df)<jupyter_output><empty_output><jupyter_text>Transpose availabe T attribute<jupyter_code>sum_df.T
np.transpose(sum_df.values)<jupyter_output><empty_output><jupyter_text>dot method on DataFrame implements matrix multiplicationNote: row and column headers<jupyter_code>A_df = pd.DataFrame(np.arange(15).reshape((3,5)))
B_df = pd.DataFrame(np.arange(10).reshape((5,2)))
A_df.dot(B_df)<jupyter_output><empty_output><jupyter_text>dot method on Series implements dot product<jupyter_code>C_Series = pd.Series(np.arange(5,10))
C_Series.dot(C_Series)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13320825515947468, 'fraction_numerical': 0.016885553470919325, 'mean_word_length': 9.259615384615385, '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': '239612', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 415, 'n_tokens_neox': 398, 'n_words': 75, 'path': 'python-scripts/data_analytics_learn/link_pandas/Ex_Files_Pandas_Data/Exercise Files/04_04/Final/Universal.ipynb', 'repo_name': 'adityaka/misc_scripts', 'size': '1066'}