In [1]:
import pandas as pd
print(pd.__version__)
In [2]:
pd.read_json?
In [3]:
df = pd.read_json("https://data.smcgov.org/resource/mb6a-xn89.json")
df.head(5)
Out[3]:
In [4]:
dir()
Out[4]:
In [5]:
df.shape
Out[5]:
In [6]:
df.describe()
Out[6]:
In [7]:
df.drop("location_1", axis=1).describe(include="all")
Out[7]:
In [8]:
df.dtypes
Out[8]:
In [9]:
df.bachelor_s_degree_or_higher.mean()
Out[9]:
In [10]:
df.geography.count()
Out[10]:
In [11]:
df.geography_type.unique()
Out[11]:
In [12]:
df.less_than_high_school_graduate.value_counts()
Out[12]:
In [13]:
def mapGeography(x):
if x == "City":
return 1
else:
return 0
In [14]:
df['geography_mapped_value'] = df.geography_type.apply(mapGeography)
In [15]:
df.geography_mapped_value.value_counts()
Out[15]:
In [16]:
df['geography_mapped_value_lambda'] = df.geography_type.apply(lambda y: 1 if y == "City" else 0)
In [17]:
df.geography_mapped_value_lambda.value_counts()
Out[17]:
In [ ]: