<jupyter_start><jupyter_text>Mode<jupyter_code>import pandas as pd
import numpy as np
df = pd.read_csv('C:/Users/Swapnil/Desktop/Python Programs/InternShala - Data Science Python/Module - 3 - Statistics/Module 3 - Datasheets/mode.csv')
df
df.head()
mode_sub = df['Subject'].mode()
mode_sub
tot_favSub = df[df['Subject']=='Chemistry']
tot_favSub
tot_favSub.head()
tot_favSub.sum()<jupyter_output><empty_output><jupyter_text>Created a table<jupyter_code>cities = pd.DataFrame({'City':['Aurangabad', 'Jalna', 'Beed', 'Pune', 'Mumbai'],
                      'Rainfall':[98, 67, 98, 98, 55],
                      'Pop' : [10, 15, 20, 20, 20]})
cities
md_rain = cities['Rainfall'].mode()
md_rain
cities['Rainfall']
md_pop = cities['Pop'].mode()
md_pop
cities.loc[len(cities.index)] = ["Aurangabad", 20, 16]
cities
mod_city = cities['City'].mode()
mod_city<jupyter_output><empty_output><jupyter_text>Mistake here while adding multiple rows at once<jupyter_code>cities = cities.append({'City':['Georgeo', 'Marina', 'Wassepur'],
                        'Rainfall': [98, 55, 55],
                        'Pop': [16, 15, 16]},
                        ignore_index = True)
cities<jupyter_output><empty_output><jupyter_text>Delete rows by index number<jupyter_code>city = cities.drop([cities.index[7], cities.index[8]])
city
city = city.append({'City':'Georgeo',
                        'Rainfall':98,
                        'Pop': 16},
                        ignore_index = True)
city

city['City'].mode()<jupyter_output><empty_output><jupyter_text>Accessing cities with same frequency of rainfall  First we have to check what is mode / frequent number of Rainfall category or  column i.e 98<jupyter_code>city['Rainfall'].mode()
city[city['Rainfall']== 98]<jupyter_output><empty_output><jupyter_text>So in above cities are having same mode / frequency of rainfall.<jupyter_code>city.drop([city.index[7]])<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup