The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Extraer día de la semana de una columna

Elena_PielagosElena_Pielagos Member Posts: 3 Learner I
Hola!
Tengo una columna en mi dataset con fecha (día de la semana, fecha y hora), necesitaría crear una nueva columna en la que me aparezca sólo el día de la semana de dicha fecha. ¿Cómo podría hacerlo?
Gracias!!!

Best Answer

Answers

  • MarcoBarradasMarcoBarradas Administrator, Employee-RapidMiner, RapidMiner Certified Analyst, Member Posts: 272 Unicorn
    Hola @ceaperez espero que este ejemplo te pueda servir para ver cómo puedes cambiar una columna del tipo fecha.
    Puedes copiar el xml y pegarlo en la pestaña XML de rapidminer.
    Puedes leer en el Help del operador Date to Nominal para ver las distintas configuraciones para extraer partes de una fecha.

    <?xml version="1.0" encoding="UTF-8"?><process version="9.8.001">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.8.001" expanded="true" name="Process">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="2001"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <process expanded="true">
          <operator activated="true" class="utility:create_exampleset" compatibility="9.8.001" expanded="true" height="68" name="Create ExampleSet" width="90" x="45" y="34">
            <parameter key="generator_type" value="date series"/>
            <parameter key="number_of_examples" value="100"/>
            <parameter key="use_stepsize" value="false"/>
            <list key="function_descriptions"/>
            <parameter key="add_id_attribute" value="false"/>
            <list key="numeric_series_configuration"/>
            <list key="date_series_configuration">
              <parameter key="Fecha" value="2020-01-01.2021-01-01"/>
            </list>
            <list key="date_series_configuration (interval)"/>
            <parameter key="date_format" value="yyyy-MM-dd"/>
            <parameter key="time_zone" value="SYSTEM"/>
            <parameter key="column_separator" value=","/>
            <parameter key="parse_all_as_nominal" value="false"/>
            <parameter key="decimal_point_character" value="."/>
            <parameter key="trim_attribute_names" value="true"/>
          </operator>
          <operator activated="true" class="subprocess" compatibility="9.8.001" expanded="true" height="82" name="Copia_Fechas" width="90" x="179" y="34">
            <process expanded="true">
              <operator activated="true" class="generate_copy" compatibility="9.8.001" expanded="true" height="82" name="Generate Copy" width="90" x="45" y="34">
                <parameter key="attribute_name" value="Fecha"/>
                <parameter key="new_name" value="Semana"/>
              </operator>
              <operator activated="true" class="generate_copy" compatibility="9.8.001" expanded="true" height="82" name="Generate Copy (2)" width="90" x="179" y="34">
                <parameter key="attribute_name" value="Fecha"/>
                <parameter key="new_name" value="Día"/>
              </operator>
              <operator activated="true" class="generate_copy" compatibility="9.8.001" expanded="true" height="82" name="Generate Copy (3)" width="90" x="313" y="34">
                <parameter key="attribute_name" value="Fecha"/>
                <parameter key="new_name" value="Día_Semana"/>
              </operator>
              <connect from_port="in 1" to_op="Generate Copy" to_port="example set input"/>
              <connect from_op="Generate Copy" from_port="example set output" to_op="Generate Copy (2)" to_port="example set input"/>
              <connect from_op="Generate Copy (2)" from_port="example set output" to_op="Generate Copy (3)" to_port="example set input"/>
              <connect from_op="Generate Copy (3)" from_port="example set output" to_port="out 1"/>
              <portSpacing port="source_in 1" spacing="0"/>
              <portSpacing port="source_in 2" spacing="0"/>
              <portSpacing port="sink_out 1" spacing="0"/>
              <portSpacing port="sink_out 2" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="date_to_numerical" compatibility="9.8.001" expanded="true" height="82" name="Semana_del_Año" width="90" x="313" y="34">
            <parameter key="attribute_name" value="Semana"/>
            <parameter key="time_unit" value="week"/>
            <parameter key="millisecond_relative_to" value="second"/>
            <parameter key="second_relative_to" value="minute"/>
            <parameter key="minute_relative_to" value="hour"/>
            <parameter key="hour_relative_to" value="day"/>
            <parameter key="day_relative_to" value="month"/>
            <parameter key="week_relative_to" value="year"/>
            <parameter key="month_relative_to" value="year"/>
            <parameter key="quarter_relative_to" value="year"/>
            <parameter key="half_year_relative_to" value="year"/>
            <parameter key="year_relative_to" value="era"/>
            <parameter key="keep_old_attribute" value="false"/>
          </operator>
          <operator activated="true" class="date_to_nominal" compatibility="9.8.001" expanded="true" height="82" name="Día_de_la_Semana" width="90" x="447" y="34">
            <parameter key="attribute_name" value="Día_Semana"/>
            <parameter key="date_format" value="EEEE"/>
            <parameter key="time_zone" value="SYSTEM"/>
            <parameter key="locale" value="Spanish (Mexico)"/>
            <parameter key="keep_old_attribute" value="false"/>
          </operator>
          <operator activated="true" class="date_to_nominal" compatibility="9.8.001" expanded="true" height="82" name="Día_del_Mes" width="90" x="581" y="34">
            <parameter key="attribute_name" value="Día"/>
            <parameter key="date_format" value="dd"/>
            <parameter key="time_zone" value="SYSTEM"/>
            <parameter key="locale" value="Spanish (Mexico)"/>
            <parameter key="keep_old_attribute" value="false"/>
          </operator>
          <connect from_op="Create ExampleSet" from_port="output" to_op="Copia_Fechas" to_port="in 1"/>
          <connect from_op="Copia_Fechas" from_port="out 1" to_op="Semana_del_Año" to_port="example set input"/>
          <connect from_op="Semana_del_Año" from_port="example set output" to_op="Día_de_la_Semana" to_port="example set input"/>
          <connect from_op="Día_de_la_Semana" from_port="example set output" to_op="Día_del_Mes" to_port="example set input"/>
          <connect from_op="Día_del_Mes" 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>


Sign In or Register to comment.