You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何从CSV文件提取指定数值并写入Pandas DataFrame?

Extract Specific Values from CSV Comments into Pandas DataFrame

I have a Pandas DataFrame containing a column named path. I can iterate over these paths using the following code:

for i, p in enumerate(df['path']):

My goal is to extract a specific numerical value from each CSV file referenced by these paths and write that value back into the DataFrame. Each CSV file uses a comment-based format like this:

some values
some values : some values
some values : some values
some values : some values
some string : the value I want
some string : some values

I believe regular expressions are the right tool for this task, but I'm unsure about the exact syntax to use. I have a template code snippet to build from:

if re.match(r"something", p):
    df = pd.read_csv(p)
    df.iloc[i, value_column] = the value I want

Can someone provide a feasible implementation solution for this?


内容的提问来源于stack exchange,提问作者Allentro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 07:41:11