【问题标题】:How to format date / time attributes in rapidminer如何在 rapidminer 中格式化日期/时间属性
【发布时间】:2016-08-28 15:25:15
【问题描述】:

我有一个包含 2 列的 .xls 文件。一个称为“msgdate”,其中包含诸如“20160314”(yyyyMMdd)之类的值,另一列称为“msgtime”,其中包含诸如“111215”(HHmmss)之类的值。我想将这 2 列连接为数据类型的 date_time,以便我可以绘制值。我已经尝试了一些事情,但得到一个无法解析的日期错误。我尝试过的事情: 导入文件,选择 msgdate 作为日期数据类型,格式为 yyyyMMdd,它可以工作,但我无法在导入期间设置任何时间格式而不破坏日期格式。 导入文件,选择 msgdate 作为日期数据类型,格式为 yyyyMMdd 并将 msgtime 设置为整数,然后使用 Numerical to Date 运算符,但是生成的值 msgtime 值不正确,结果为 -> Wed Dec 31 18:01:51 CST 1969)。感谢您提供的任何知识,并感谢您花时间阅读本文。

【问题讨论】:

    标签: rapidminer


    【解决方案1】:

    最简单的方法是将两个字段连接为一个,然后解析为一个新的日期时间属性。我假设这两个输入字段已经在下面显示了这个工作的名义。

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="7.0.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="7.0.000" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="generate_data_user_specification" compatibility="7.0.000" expanded="true" height="68" name="Generate Data by User Specification" width="90" x="112" y="136">
            <list key="attribute_values">
              <parameter key="msgdate" value="&quot;20160314&quot;"/>
              <parameter key="msgtime" value="&quot;111215&quot;"/>
            </list>
            <list key="set_additional_roles"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="7.0.000" expanded="true" height="82" name="Generate Attributes" width="90" x="246" y="136">
            <list key="function_descriptions">
              <parameter key="datetime" value="msgdate+msgtime"/>
            </list>
          </operator>
          <operator activated="true" class="nominal_to_date" compatibility="7.0.000" expanded="true" height="82" name="Nominal to Date (3)" width="90" x="380" y="136">
            <parameter key="attribute_name" value="datetime"/>
            <parameter key="date_type" value="date_time"/>
            <parameter key="date_format" value="yyyyMMddHHmmss"/>
            <parameter key="keep_old_attribute" value="true"/>
          </operator>
          <connect from_op="Generate Data by User Specification" from_port="output" to_op="Generate Attributes" to_port="example set input"/>
          <connect from_op="Generate Attributes" from_port="example set output" to_op="Nominal to Date (3)" to_port="example set input"/>
          <connect from_op="Nominal to Date (3)" from_port="example set output" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
    

    希望这有助于您顺利完成任务。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-15
      • 2019-01-05
      • 2021-09-24
      • 2017-03-24
      • 1970-01-01
      • 1970-01-01
      • 2021-08-09
      相关资源
      最近更新 更多