I am passing to a function several pandas df
:
JavaScript
x
7
1
def write_df_to_disk(*args):
2
for df in args:
3
df.to_csv('/transformed/'+str(df)+'.table',sep='t')
4
5
6
write_df_to_disk(k562,hepg2,hoel)
7
df
here will be a pandas dataframe.
How can I assign the diferent parameters of *args
to a string like above '/transformed/'+str(df)+'.table',sep='t'
??
I want to have three files written to disk with the following path:
JavaScript
1
4
1
`/transformed/k562.table`
2
`/transformed/hepg2.table`
3
`transformed/hoel.table`
4
Advertisement
Answer
ok I think I managed.
JavaScript
1
6
1
def write_df_to_disk(l,*args):
2
for l,df in zip(l,args):
3
df.to_csv('transformed/'+l+'.table',sep='t')
4
5
write_df_to_disk(['k562','hepg2','hoel'],k562,hepg2,hoel)
6