Created
May 10, 2021 19:51
-
-
Save pablomm/2f4c6671999e8abc2feea42ab3ef359f to your computer and use it in GitHub Desktop.
Code snippet code sugestion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Union | |
import pandas as pd | |
# Load dataset with codes order by probability | |
URL = ('https://gist.githubusercontent.com/pablomm/' | |
'99cb95ddf65a1001a3c98312418254a0/raw/' | |
'259deec38e3e1e3da72d2f6b8de8c0690b4d28f7/' | |
'gistfile1.txt') | |
df_search = pd.read_csv(URL, index_col='index') | |
def suggest_codes(cod_1: Union[int, str], cod_2: Union[int, str]) -> pd.DataFrame: | |
""" | |
Args: | |
cod_1 (int): First verification mobile code. | |
cod_2 (int): First verification mobile code. | |
Returns: | |
Dataframe with pin code suggestions sorted by probability. | |
""" | |
cod_1, cod_2 = str(cod_1).zfill(4)[2:], str(cod_2).zfill(4)[2:] | |
if cod_2 < cod_1: | |
cod_1, cod_2 = cod_2, cod_1 | |
key = int(cod_1 + cod_2) | |
return df_search.loc[key] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment