Skip to content

Instantly share code, notes, and snippets.

@BinarySpoon
Last active October 16, 2020 10:15
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 BinarySpoon/05f078030a05bf4280bb046e1375e473 to your computer and use it in GitHub Desktop.
Save BinarySpoon/05f078030a05bf4280bb046e1375e473 to your computer and use it in GitHub Desktop.
# date sorting -->
df['date'] = date_list
form = (lambda date: datetime.strptime(date, "%m/%d/%Y"))
# sorting chronologically -->
df['index'] = sorted(range(len(date_list)), key=lambda x : form(date_list[x]))
# removing med notes column -->
df.drop('text', axis=1,inplace=True)
# final sorted series indices -->
final = list(df['index'])
final_series = pd.Series(final)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment