Package: outkast
Using data on more than 140M Indians across 19 states from theSocio-Economic Caste Census(parsed datahere), we estimate the proportionscheduled caste, scheduled tribe, and otherfor a particular last name, year, and state.Why?We provide this package so that people can assess, highlight, and fight unfairness.How is the underlying data produced?Thescriptdownloads theclean versionof the SECC postedhere.Infer the last nameremove names with non-alphabetical charactersremove records with missing last namesremove < 2 char last namesremove rows with birth_date < 1900last name shared by at least 1000Group by last name, state, and yearand produce theunderlying dataBase ClassifierWe start by providing a base model for last_name that gives the Bayes
optimal solution providing the proportion ofSC, ST, and Otherwith that last name.
We also provide a series of base models where the state of
residence is known.InstallationWe strongly recommend installingoutkastinside a Python virtual environment (seevenv documentation)pip install outkastUsageusage: secc_caste [-h] -l LAST_NAME
                [-s {arunachal pradesh,assam,bihar,chhattisgarh,gujarat,haryana,kerala,madhya pradesh,maharashtra,mizoram,odisha,nagaland,punjab,rajasthan,sikkim,tamilnadu,uttar pradesh,uttarakhand,west bengal}]
                [-y YEAR] [-o OUTPUT]
                input

Appends SECC 2011 data columns for sc, st, and other by last name

positional arguments:
input                 Input file

optional arguments:
-h, --help            show this help message and exit
-l LAST_NAME, --last-name LAST_NAME
                        Name or index location of column contains the last
                        name
-s {arunachal pradesh,assam,bihar,chhattisgarh,gujarat,haryana,kerala,madhya pradesh,maharashtra,mizoram,odisha,nagaland,punjab,rajasthan,sikkim,tamilnadu,uttar pradesh,uttarakhand,west bengal}, --state {arunachal pradesh,assam,bihar,chhattisgarh,gujarat,haryana,kerala,madhya pradesh,maharashtra,mizoram,odisha,nagaland,punjab,rajasthan,sikkim,tamilnadu,uttar pradesh,uttarakhand,west bengal}
                        State name of SECC data (default=all)
-y YEAR, --year YEAR  Birth year in SECC data (default=all)
-o OUTPUT, --output OUTPUT
                        Output file with SECC data columnsUsing outkast>>> import pandas as pd
>>> from outkast import secc_caste
>>>
>>> names = [{'name': 'patel'},
...             {'name': 'zala'},
...             {'name': 'lal'},
...             {'name': 'agarwal'}]
>>>
>>> df = pd.DataFrame(names)
>>>
>>> secc_caste(df, 'name')
    name    n_sc    n_st  n_other   prop_sc   prop_st  prop_other
0    patel    5681  112302   631393  0.007581  0.149861    0.842558
1     zala     667      14    34550  0.018932  0.000397    0.980670
2      lal  703595  241846  1314224  0.311371  0.107027    0.581601
3  agarwal      39      12     4375  0.008812  0.002711    0.988477


>>>
>>> help(secc_caste)
Help on method secc_caste in module outkast.secc_caste_ln:

secc_caste(df, namecol, state=None, year=None) method of builtins.type instance
    Appends additional columns from SECC data to the input DataFrame
    based on the last name.

    Removes extra space. Checks if the name is the SECC data.
    If it is, outputs data from that row.

    Args:
        df (:obj:`DataFrame`): Pandas DataFrame containing the last name
            column.
        namecol (str or int): Column's name or location of the name in
            DataFrame.
        state (str): The state name of SECC data to be used.
            (default is None for all states)
        year (int): The year of SECC data to be used.
            (default is None for all years)

    Returns:
        DataFrame: Pandas DataFrame with additional columns:-
            'n_sc', 'n_st', 'n_other',
            'prop_sc', 'prop_st', 'prop_other' by last nameAuthorsSuriyan Laohaprapanon and Gaurav SoodLicenseThe package is released under theMIT
License.