0

I was trying to convert a data frame to a CSV file using the to_csv() function. But I am getting the error "PermissionError: [Errno 13] Permission denied: 'lamda0.45.csv'". My code is as below:

agent_df.to_csv("lamda{}.csv".format(lamda),sep='\t',  encoding='utf-8')

agent_df is my data frame and I need to identify a CSV file with a corresponding lambda value when used in a loop. NB: I am trying to save the file in the same folder as my program codes. Also, I don't have the same file open anywhere as suggested in these answers.

1 Answers1

0

This error usually occurs when the csv file you're trying to save is already open. Check if it is closed before running the pd.to_csv

Suhas Mucherla
  • 1,383
  • 1
  • 5
  • 17