[英]How to Update/Append Model Name Column in Csv File with Respect to Another Column(Epoch) which has value 0
I am writing model history in csv in which later on I am adding a new column model name where I need to update model name everytime when I run with timestamp.But currently what I am facing is that it is updating the model name not just for the latest one but for all wherever it finds Epoch value as 0. Kindly Help if anybody have any idea.我正在 csv 中编写模型历史记录,稍后我将添加一个新的列模型名称,每次使用时间戳运行时都需要更新模型名称。但目前我面临的是它正在更新模型名称,而不仅仅是为了最新的,但对于所有发现 Epoch 值为 0 的地方。如果有人有任何想法,请提供帮助。
Training CSV Contains the given data and model_na varible basically conatains FileName_Time stamp which you can see in model name column---训练 CSV 包含给定的数据和 model_na 变量基本上包含 FileName_Time 标记,您可以在模型名称列中看到它---
epoch accuracy loss val_accuracy val_loss 0 0.5991348 0.954963956 0.61725134 0.928029025 1 0.6101555 0.934882281 0.61725134 0.926564478 2 0.6101555 0.933647258 0.61725134 0.925897177 3 0.6101555 0.933986878 0.61725134 0.925625712 4 0.6101555 0.93378263 0.61725134 0.92587147 5 0.6101555 0.933501081 0.61725134 0.925496578 6 0.6101555 0.934000334 0.61725134 0.925522646 7 0.6101555 0.933863895 0.61725134 0.926479578 8 0.6101555 0.933888928 0.61725134 0.926321284 0 0.59779584 0.954151712 0.61725134 0.925566993 1 0.6101555 0.935797452 0.61725134 0.926761304 2 0.6101555 0.935356209 0.61725134 0.926412033 3 0.6101555 0.933948885 0.61725134 0.925769904 0 0.6020188 0.956590114 0.61725134 0.928246004 1 0.6101555 0.935971673 0.61725134 0.925614129 2 0.6101555 0.934430503 0.61725134 0.926334595 3 0.6101555 0.933712303 0.61725134 0.927097352 4 0.6101555 0.933796334 0.61725134 0.925467268 5 0.6101555 0.93388608 0.61725134 0.925654634 6 0.6101555 0.933794685 0.61725134 0.925489133 7 0.6101555 0.933911282 0.61725134 0.926129941
I am using given code write now--- ''' df = pd.read_csv('\\History\\training.csv')我现在使用给定的代码写入--- ''' df = pd.read_csv('\\History\\training.csv')
Type_new = pd.Series([]) Type_new = pd.Series([])
for i in range(len(df)):对于范围内的 i(len(df)):
if df["epoch"][i] == 0:
Type_new[i]=model_na
df.insert(0, "Model_Name", Type_new) df.insert(0, "Model_Name", Type_new)
df.to_csv('\\History\\cleaned_twitter_final.csv',index=False) df.to_csv('\\History\\cleaned_twitter_final.csv',index=False)
''' Current Output---- '''电流输出----
Model_Name epoch accuracy loss val_accuracy val_loss LSTM_Model_19_Feb_2020_122031 0 0.5991348 0.954963956 0.61725134 0.928029025 1 0.6101555 0.934882281 0.61725134 0.926564478 2 0.6101555 0.933647258 0.61725134 0.925897177 3 0.6101555 0.933986878 0.61725134 0.925625712 4 0.6101555 0.93378263 0.61725134 0.92587147 5 0.6101555 0.933501081 0.61725134 0.925496578 6 0.6101555 0.934000334 0.61725134 0.925522646 7 0.6101555 0.933863895 0.61725134 0.926479578 8 0.6101555 0.933888928 0.61725134 0.926321284 LSTM_Model_19_Feb_2020_122031 0 0.59779584 0.954151712 0.61725134 0.925566993 1 0.6101555 0.935797452 0.61725134 0.926761304 2 0.6101555 0.935356209 0.61725134 0.926412033 3 0.6101555 0.933948885 0.61725134 0.925769904
Expected Output---预期输出---
Model_Name epoch accuracy loss val_accuracy val_loss LSTM_Model_19_Feb_2020_122031 0 0.5991348 0.954963956 0.61725134 0.928029025 1 0.6101555 0.934882281 0.61725134 0.926564478 2 0.6101555 0.933647258 0.61725134 0.925897177 3 0.6101555 0.933986878 0.61725134 0.925625712 4 0.6101555 0.93378263 0.61725134 0.92587147 5 0.6101555 0.933501081 0.61725134 0.925496578 6 0.6101555 0.934000334 0.61725134 0.925522646 7 0.6101555 0.933863895 0.61725134 0.926479578 8 0.6101555 0.933888928 0.61725134 0.926321284 LSTM_Model_19_Feb_2020_132031 0 0.59779584 0.954151712 0.61725134 0.925566993 1 0.6101555 0.935797452 0.61725134 0.926761304 2 0.6101555 0.935356209 0.61725134 0.926412033 3 0.6101555 0.933948885 0.61725134 0.925769904
得到了解决方案......可以使用 csv 记录器......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.