I'm writing a function to import .dta files that will have the name structure but with different prefixes. How do I reference this prefix in a string filepath name? For example, something like
def import_stata(code):
df=pd.read_stata("code_dataset.dta")
return df
Where code is the prefix that will change. Right now I'm getting an error saying that code_dataset doesn't exist.
Thanks!