0

I want to create a function that creates a dataframe named after the function input So for example

def createfile(filename):
     # the code here to create the df as below 
     filename_1 = pd.DataFrame()

but i can't find a way to use the input as part of of the new file

d.b
  • 32,245
  • 6
  • 36
  • 77
  • What kind of file do you want? CSV? `filename_1.to_csv(f'{filename}')` – piRSquared Apr 07 '22 at 15:34
  • what did u mean with named dataframe ? – Nikolay Tsvetanov Apr 07 '22 at 15:36
  • I think @Sandra John wants to name the variable (not the file) with the parameter of the function. Like passing a string to a function to create a variable named from this string. – Lemisourd Apr 07 '22 at 15:46
  • You are right, but i found all comments saying that it's bad thing to do to name variable after function, maybe extracting the file with the needed name is better, thank you all – Sandra John Apr 08 '22 at 03:14

0 Answers0