Skip to content

Instantly share code, notes, and snippets.

@hyunsikhwang
Created July 12, 2021 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyunsikhwang/1f302e44e89bec13e8e5b2d0764c6241 to your computer and use it in GitHub Desktop.
Save hyunsikhwang/1f302e44e89bec13e8e5b2d0764c6241 to your computer and use it in GitHub Desktop.
#KCD #code #extract #range #comma
def ext_KCD(df_KCD, input_KCD):
KCD_1 = input_KCD.replace(' ', '').split(',')
KCD_list = []
for KCD in KCD_1:
if "-" in KCD:
KCD_beg = KCD.split('-')[0].upper()
KCD_end = KCD.split('-')[1].upper()
KCD_list = KCD_list + df_KCD[(df_KCD>=KCD_beg) & (df_KCD<=KCD_end)].unique().tolist()
else:
KCD_list.append(KCD.upper())
return KCD_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment