API Reference
instate package
- instate.last_state(df: DataFrame, lastnamecol: str, dataset: str = 'v1') DataFrame
Appends additional columns from state data to the input DataFrame based on the last name.
Removes the extra space. Checks if the name is the Indian electoral rolls data. If it is, outputs data from that row. Drops duplicated last names.
- Parameters:
df (
DataFrame
) – Pandas DataFrame containing the last name column.lastnamecol (str or int) – Column’s name or location of the name in DataFrame.
state (str) – The state name of Indian electoral rolls data to be used. (default is None for all states)
- Returns:
Pandas DataFrame with 31 additional columns
- Return type:
DataFrame
- instate.list_states(dataset: str = 'v1') List[str]
- instate.lookup_lang(df: DataFrame, lastnamecol: str) DataFrame
- instate.pred_last_state(df: DataFrame, lastnamecol: str, k: int = 3) DataFrame
Predict state based on name. Filters the dataframe to lastnames more than 2 chars, with only English alphabets, strips extra spaces, and converts last names to lowercase. Also drops duplicates. :param df: pandas dataframe with the last name column :param lastnamecol: column name with the last name :param k: the number of states that should be returned (in order). default is 3.
- Returns:
Pandas DataFrame with appended predictions
- Return type:
DataFrame
- instate.predict_lang(df: DataFrame, lastnamecol: str) DataFrame
- instate.state_to_lang(df: DataFrame, statecolname: str) DataFrame
InRollsLnData Class
- class instate.instate.InRollsLnData[source]
Bases:
object
- classmethod last_state(df: DataFrame, lastnamecol: str, dataset: str = 'v1') DataFrame [source]
Appends additional columns from state data to the input DataFrame based on the last name.
Removes the extra space. Checks if the name is the Indian electoral rolls data. If it is, outputs data from that row. Drops duplicated last names.
- Parameters:
df (
DataFrame
) – Pandas DataFrame containing the last name column.lastnamecol (str or int) – Column’s name or location of the name in DataFrame.
state (str) – The state name of Indian electoral rolls data to be used. (default is None for all states)
- Returns:
Pandas DataFrame with 31 additional columns
- Return type:
DataFrame
- classmethod pred_last_state(df: DataFrame, lastnamecol: str, k: int = 3) DataFrame [source]
Predict state based on name. Filters the dataframe to lastnames more than 2 chars, with only English alphabets, strips extra spaces, and converts last names to lowercase. Also drops duplicates. :param df: pandas dataframe with the last name column :param lastnamecol: column name with the last name :param k: the number of states that should be returned (in order). default is 3.
- Returns:
Pandas DataFrame with appended predictions
- Return type:
DataFrame