简体   繁体   English

如何更新/追加 Csv 文件中的模型名称列相对于值为 0 的另一列(Epoch)

[英]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.

相关问题 如何相对于Spark中的另一个列数据更新列名 - How to update column name with respect to another column data in spark python根据另一个csv文件更新csv文件的列值 - python update a column value of a csv file according to another csv file 我想相对于另一列拖动 integer 中的列值 - I want to drag a column value which are in integer with respect to another column 如何遍历 CSV 文件并根据另一列的值更新一列中的值 - How to iterate over a CSV file and update values in one column based on the value of another column pandas 数据框将一个列值附加到另一个具有列表元素的 Pandas 列 - pandas dataframe append a column value to another pandas column which has a list elements 如何获得“No”列的最大值。 关于 pandas 中的“名称”列 - How to get maximum value of column "No." with respect to column "Name" in pandas 如何读取csv文件的特定列在Ipython中有空格 - How to read a specific column of a csv file which has space in Ipython Pandas:获取具有列值的行并用另一个值更新评论列 - Pandas: get the row which has column value and update comments column with another value 如何按列名过滤值,然后将具有相同值的行提取到另一个CSV文件? Python /熊猫 - How to filter values by Column Name and then extract the rows that have the same value to another CSV file? Python/Pandas 如何在不使用熊猫的情况下将 append 列从 csv 文件到另一个 csv 文件? - how to append a column from a csv file to another csv file without using panda?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM