<jupyter_start><jupyter_text>**Importing Libraries**<jupyter_code>import numpy as np
import pandas as pd<jupyter_output><empty_output><jupyter_text>Preparing Dataframe<jupyter_code>names = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
marks = [87, 89, 86, 32, 43, 45, 80, 10, 90, 31]
cities = ['Bengaluru', 'Delhi', 'Mumbai', 'Bengaluru', 'Delhi', 'Mumbai', 'Bengaluru', 'Delhi', 'Mumbai', 'Delhi']

data = {
    'name' : names,
    'marks': marks,
    'city': cities
}
df = pd.DataFrame(data)
df<jupyter_output><empty_output><jupyter_text>Operations on a dataframe<jupyter_code>df.shape
df.size
df.head()
df.head(2)
df.tail()
df.tail(2)
df['name']
print("Name : ", df['name'][0])
print("Marks : ", df['marks'][0])
print("City : ", df['city'][0])
df.index
df.columns
df.columns = ['name_x', 'marks_x', 'city_x']
df.head()
df['name_x'][0] = 'Q'
df.head()
df.name_x[0] = 'W'
df.head()
df.loc[0, 'name_x'] = 'Z'
df.head()
df.drop('city_x', axis = 1) # axis = 1 is for column, returns a new dataset and the original dataset remains unchanged. That is, it is not inplace!
df1 = df.drop(1, axis = 0, inplace = False) 
# axis = 0 is for row, returns a new dataset and the original dataset remains unchanged.
# inpace = False by default, inpace = True will make changes in the original dataset
df1
df.head()
df.loc[[1,2], ['name_x', 'marks_x']]
df1.loc[1,2] # Throws error because key '1' is not present in the df1 dataframe.
df1.iloc[1,2]
df.loc[:, ['name_x']]
df.loc[[2,5], :]
df.iloc[1,2] # 1 is index for row and 2 is index for column
df['name_x'].isnull()
sum(df['name_x'].isnull())<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20074349442379183, 'fraction_numerical': 0.031598513011152414, 'mean_word_length': 5.358267716535433, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '389774', 'license': 'MIT', 'n_tokens_mistral': 690, 'n_tokens_neox': 663, 'n_words': 178, 'path': 'Session 3/Pandas_AIML_1.ipynb', 'repo_name': 'SandeshRangreji/AIML-Workshop', 'size': '1614'}