<jupyter_start><jupyter_text>Day 2<jupyter_code>people = {
    "first" : "Corey",
    "last": "Schafer",
    "email" : "<EMAIL>"
    
}
people = {
    "first" : ["Corey","Anik","Ankush"],
    "last": ["Schafer","Tanzim","Dey"],
    "email" : ["<EMAIL>","<EMAIL>","<EMAIL>"]
        }

people['email']
import pandas as pd
df1 = pd.DataFrame(people) #creating DataFrame
df1
df1['email']
type(df1['email']) #series object
df1.email

df1
df1[['last','email']]
type(df1[['last','email']])
df1.columns
df1.iloc[0]    #integer Location
df1.iloc[[0,1]]
df1.iloc[[0,1],2]
df1.loc[0]
df1.loc[[0,1]]
df1.loc[[0,1],'email']
df1.loc[[0,1],['email','last']]
df
df.shape
df.columns
df['Hobbyist']
df['Hobbyist'].value_counts()
df.loc[0,'Hobbyist']
df.loc[0:2,'Hobbyist']
df.loc[0:2,'Hobbyist':'Employment']
df = pd.read_csv("survey_results_public.csv", index_col= "Respondent")
df

schema_df
schema_df = pd.read_csv("data/survey_results_schema.csv", index_col = 'Column')
schema_df
schema_df.loc['Hobbyist']
schema_df.loc['MgrIdiot','QuestionText']
schema_df.sort_index() # ascending
schema_df.sort_index(ascending = False)
high_salary = (df['ConvertedComp'] >70000)
nhjmm


df.loc[high_salary]
df.loc[high_salary,['Country','LanguageWorkedWith','ConvertedComp']]
countries = ['United States', 'India', 'United Kingdom', 'Germany', 'Canada']
filt = df['Country'].isin(countries)
df.loc[filt,'Country']
df['LanguageWorkedWith']
filt = df['LanguageWorkedWith'].str.contains('Python', na = False)
df.loc[filt, 'LanguageWorkedWith']
filt
df.loc[filt]
df.rename(columns = {'ConvertedComp':'SalaryUSD'}, inplace = True)
df
df['Hobbyist']
df['Hobbyist'] = df['Hobbyist'].map({'Yes':True, 'No':False})
df
df.sort_values(by=["Country","ConvertedComp"], ascending = [True, False],inplace = True)
df[['Country', 'ConvertedComp']].head(50)
df['ConvertedComp'].nlargest(20)
df.nlargest(10,'ConvertedComp')
df.nsmallest(10,'ConvertedComp')
df['ConvertedComp'].head(15)
df['ConvertedComp'].median()
df.median() #find median of numerical componesnts
df.describe()
df['ConvertedComp'].count()
df['Hobbyist'].value_counts()
df['SocialMedia']
schema_df.loc['SocialMedia']
df['SocialMedia'].value_counts()
df['SocialMedia'].value_counts(normalize = True)
df['Country'].value_counts()
country_grp = df.groupby(['Country'])
country_grp.get_group('India')
filt = df['Country']== 'India'
df.loc[filt]['SocialMedia'].value_counts()
country_grp['SocialMedia'].value_counts().loc['India']
country_grp['ConvertedComp'].median().loc['Germany']
country_grp['ConvertedComp'].agg(['median','mean'])
country_grp['ConvertedComp'].agg(['median','mean']).loc['Canada']
filt = df['Country']== 'India'
df.loc[filt]['LanguageWorkedWith'].str.contains('Python').sum()
country_grp['LanguageWorkedWith'].apply(lambda x : x.str.contains('Python').sum() )
country_res = df["Country"].value_counts()
country_res
country_using_py = country_grp['LanguageWorkedWith'].apply(lambda x : x.str.contains('Python').sum() )
country_using_py
python_df= pd.concat([country_res, country_using_py], axis = 'columns', sort = False)
python_df
python_df.rename(columns = {'Country':'Number of Resp', 'LanguageWorkedWith':'NumKnowsPython'},inplace = True)
python_df
python_df
python_df['PctKnowdPy'] = (python_df['NumKnowsPytgon']/python_df['Number of Resp']) * 100
python_df
python_df.sort_values(by = "PctKnowdPy", ascending = False, inplace = True)
python_df.loc['Japan']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2068864896410855, 'fraction_numerical': 0.015465421651590313, 'mean_word_length': 8.656338028169014, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '461757', 'license': 'MIT', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1288, 'n_words': 186, 'path': 'Pandas Tutorial.ipynb', 'repo_name': 'arkaprava26/Data-Science-assignment', 'size': '3469'}