首页 > 解决方案 > TFX。CsvExampleGen 中 CsvCoder 的属性:“列与指定的 csv 标题不匹配”

问题描述

我正在使用 TensorFlow Extended 并堆栈在加载的 .csv 文件中。此文件有;分隔,默认无法读取 TFX 生成器CsvExampleGen()。它抛出以下错误:ValueError: Columns do not match specified csv headers

我发现这个问题与内部依赖关系有关,例如tft.coders.CsvCoder()不需要默认参数来解析 .csv 文件。

问题如下:

from tfx.components import CsvExampleGen
from tfx.utils.dsl_utils import external_input

data_path = './data'
intro_component = CsvExampleGen(input=external_input(data_path))
...

标签: pythontensorflowtfx

解决方案


从评论中

当前的解决方案是使用 pandas 转换数据文件:

df = pd.read_csv(_file_path, sep=';')

df.to_csv(_file_path)

(从奥莱克斯转述)。


推荐阅读