<jupyter_start><jupyter_text>Pandas Part I<jupyter_code>import numpy as np
import pandas as pd
arr = np.random.standard_normal((5,10))
arr
# creating dataframe from an numpy array
df = pd.DataFrame(arr)
df.tail(3)
cols = "A B C D E F G H I J".split()
cols
df.columns = cols
df
# renaming columns
df.rename(columns={'C': 'Z'}, inplace=True)
df.columns
df.info()
df['A']
index = pd.date_range('1/1/2018', periods=5)
index
df.set_index(index, inplace=True)
df.head(3)
#df.tail(3)
# accessing data in rows
# loc vs iloc
df.loc['2018-01-02']
df.iloc[[1,3]]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16006884681583478, 'fraction_numerical': 0.039586919104991396, 'mean_word_length': 5.466666666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '285880', 'license': 'MIT', 'n_tokens_mistral': 251, 'n_tokens_neox': 241, 'n_words': 62, 'path': 'Section 2/pandas_part_I.ipynb', 'repo_name': 'PacktPublishing/Hands-on-Python-for-Finance-V-', 'size': '581'}