Skip to content

Instantly share code, notes, and snippets.

@ivankeller
Last active May 5, 2023 13:35
Show Gist options
  • Save ivankeller/8d0f01165323928afc71c56f7d71b238 to your computer and use it in GitHub Desktop.
Save ivankeller/8d0f01165323928afc71c56f7d71b238 to your computer and use it in GitHub Desktop.
function that output the string required for constructing a given Pandas dataframe (useful on tests)
def dataframe_constructor(df):
return "df = pd.DataFrame(%s)" % (str(df.to_dict()).replace("nan"," float('nan')").replace('array', 'np.array'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment