text_html_output_1.png text_plain_output_1.png
import pandas as pd

df = pd.read_csv('../input/cities_r2.csv')
df.head().T

df.columns = ['city', 'scode', 'state', 'dcode', 'poptotal', 'popmale', 'popfemale', '0-6poptotal', '0-6popmale', '0-6popfemale', 'litertotal', 'litermale', 'literfemale', 'sexratio', '0-6sexratio', 'elrtotal', 'elrmale', 'elrfemale', 'location', 'totalgrad', 'malegrad', 'femalegrad']

df.isnull().sum()

df.describe().T

df = df.drop('location', axis=1)

df.head().T

df.state.nunique()

df.city.count()

city_count = df.groupby('state')['city'].count().sort_values(ascending=True)

df[['city', 'poptotal']].sort_values(by='poptotal', ascending=False).head(10)