简体   繁体   中英

How save a csv with pandas named with values of an array?

if I have an array of x values, for doing something, how can is it possible to save results in a.csv file that every time is named by a value of x using pandas: for example tempCSV_(x).csv?

I show the code example:

list_of_x=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7]

for x in list_of_x:

       <do something>

  tempCSV.to_csv(tempCSV+ '.csv')

Thank you for help

Just name the file x (but wrap the float in str() ):

list_of_x=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7]

for x in list_of_x:

       <do something>

  tempCSV.to_csv(str(x) + '.csv')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM