Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
297 views
in Technique[技术] by (71.8m points)

Python pandas dataframe failing to successfully execute to_csv() in run mode while successfully executes in debug mode

I'm using python pandas to create a relatively large dataframe and storing it as a csv file on windows operating system. The dataframe is relatively large in terms of 1000s of rows * 100 columns. The problem I'm seeing is inconsistency in creating the file and storing it during execution without any errors. The valid file name is created dynamically and the data changes every time, but I can get windows to create and save the same dataframe as a csv in debug mode with single stepping, i.e. when I give a gap between the dataframe.to_csv() function and next step, but in run-time irrespective of the delay the file is sometimes generated and sometimes not.

Could someone advise the best way to debug the erratic behavior and what might be the root cause ? I'm sure the data or the file name is not the culprit.

import pandas as pd    
# logic for the valid pd_csv_filename creation 
# logic for the valid dataframe df1 creation & manipulation 

time.sleep(x)
df1.to_csv(pd_csv_fileName, mode='a')
time.sleep(x)

# Check if the file is created

The csv file is not opened during the execution.

question from:https://stackoverflow.com/questions/65844412/python-pandas-dataframe-failing-to-successfully-execute-to-csv-in-run-mode-whi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...