[英]Float Dataframe to string txt file
我無法將數據框(浮動)更改為字符串作為 dat 文件。 我的 df 在下面。 在此處輸入圖像描述
使用此代碼將 dataframe 保存為 txt,np.savetxt('foil 5.txt', df.values, fmt='%d') 並運行該文件,字符串模式將浮點數更改為 integer 並重新生成一個文件只有零值。 在此處輸入圖像描述
但我需要這個文件與下面的圖片保持一致。 在此處輸入圖像描述
如果有人已經解決了這個問題,請與我分享過程
你可能想看看to_csv()和read_csv()這些函數將以 txt 可讀的格式保存數據,並將字符串保持為字符串,將浮點數保持為浮點數。
to_csv()
read_csv()
[英]pandas DataFrame to .txt with string and float values
[英]Plotting a .txt file, trouble converting string to float
[英]How to import .txt file to DataFrame as integers, not as string?
[英]could not convert string to float w/ HUGE TXT FILE
[英]could not convert string to float from file.txt
[英]Read float and string from txt
[英]Writing txt-file float
[英]Searching for float value in .txt file
[英]Pandas txt file to dataframe
[英]Convert a txt file to dataframe
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.