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

como pasar una hora de string a int

ISA_MOSQUERAISA_MOSQUERA Member Posts: 1 Learner I
hola a todos, 
Necesito ayuda para convertir mi formato de hora. Dentro del conjunto de datos que tengo, mi hora está en formato de xx H xx MIN xx SEG,  por ejemplo 0 H 47 MIN 48 SEGEstoy intentando convertir estos tiempos en formato de un numero especifico de minutos o segundos, donde las 0 H 47 MIN 48 SEG convertirían en 47.8 minutos o 2,868 segundos

Answers

  • CKönigCKönig Employee-RapidMiner, Member Posts: 70 RM Team Member
    Hi @ISA_MOSQUERA

    If you want to convert dates, have a look at the operator "Nominal to Date" in combination with "Date to Numerical". For more difficult use cases, the operator "Generate Attributes" has extended date functionality.
  • CKönigCKönig Employee-RapidMiner, Member Posts: 70 RM Team Member
    edited November 2023
    Here is a short example:

    <div><?xml version="1.0" encoding="UTF-8"?><process version="10.2.000"></div><div>&nbsp; <context></div><div>&nbsp; &nbsp; <input/></div><div>&nbsp; &nbsp; <output/></div><div>&nbsp; &nbsp; <macros/></div><div>&nbsp; </context></div><div>&nbsp; <operator activated="true" class="process" compatibility="10.2.000" expanded="true" name="Process"></div><div>&nbsp; &nbsp; <parameter key="logverbosity" value="init"/></div><div>&nbsp; &nbsp; <parameter key="random_seed" value="2001"/></div><div>&nbsp; &nbsp; <parameter key="send_mail" value="never"/></div><div>&nbsp; &nbsp; <parameter key="notification_email" value=""/></div><div>&nbsp; &nbsp; <parameter key="process_duration_for_mail" value="30"/></div><div>&nbsp; &nbsp; <parameter key="encoding" value="SYSTEM"/></div><div>&nbsp; &nbsp; <process expanded="true"></div><div>&nbsp; &nbsp; &nbsp; <operator activated="true" class="utility:create_exampleset" compatibility="10.2.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="112" y="34"></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="generator_type" value="comma separated text"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="number_of_examples" value="100"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="use_stepsize" value="false"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <list key="function_descriptions"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="add_id_attribute" value="false"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <list key="numeric_series_configuration"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <list key="date_series_configuration"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <list key="date_series_configuration (interval)"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="time_zone" value="SYSTEM"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="input_csv_text" value="timestamp&#10;0 H 47 MIN 48 SEC"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="column_separator" value=","/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="parse_all_as_nominal" value="false"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="decimal_point_character" value="."/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="trim_attribute_names" value="true"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <description align="center" color="transparent" colored="false" width="126">0 H 47 MIN 48 SEC</description></div><div>&nbsp; &nbsp; &nbsp; </operator></div><div>&nbsp; &nbsp; &nbsp; <operator activated="true" class="nominal_to_date" compatibility="10.2.000" expanded="true" height="82" name="Nominal to Date" width="90" x="246" y="34"></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="attribute_name" value="timestamp"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="date_type" value="time"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="date_format" value="HH 'H' mm 'MIN' ss 'SEC'"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="time_zone" value="SYSTEM"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="locale" value="English (United States)"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="keep_old_attribute" value="false"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <description align="center" color="transparent" colored="false" width="126">parse the textual representation into a &amp;quot;time&amp;quot; attribute with date format string:&lt;br&gt;&lt;br&gt;HH 'H' mm 'MIN' ss 'SEC'</description></div><div>&nbsp; &nbsp; &nbsp; </operator></div><div>&nbsp; &nbsp; &nbsp; <operator activated="true" class="date_to_numerical" compatibility="10.2.000" expanded="true" height="82" name="Date to Numerical" width="90" x="380" y="34"></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="attribute_name" value="timestamp"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="time_unit" value="minute"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="millisecond_relative_to" value="second"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="second_relative_to" value="minute"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="minute_relative_to" value="day"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="hour_relative_to" value="day"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="day_relative_to" value="month"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="week_relative_to" value="year"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="month_relative_to" value="year"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="quarter_relative_to" value="year"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="half_year_relative_to" value="year"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="year_relative_to" value="era"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="keep_old_attribute" value="true"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <description align="center" color="transparent" colored="false" width="126">convert time attribute to a number representing the total number of minutes (as an integer)</description></div><div>&nbsp; &nbsp; &nbsp; </operator></div><div>&nbsp; &nbsp; &nbsp; <operator activated="true" class="blending:generate_columns" compatibility="10.2.000" expanded="true" height="82" name="Generate Attributes" width="90" x="514" y="34"></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <list key="function_descriptions"></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <parameter key="timestamp_minutes_precise" value="time_get(timestamp,DATE_UNIT_MINUTE)+time_get(timestamp,DATE_UNIT_SECOND)/60"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; </list></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="keep_all_columns" value="true"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <description align="center" color="transparent" colored="false" width="126">convert time attribute to a number representing the total number of minutes (including seconds as a fraction)</description></div><div>&nbsp; &nbsp; &nbsp; </operator></div><div>&nbsp; &nbsp; &nbsp; <operator activated="true" class="date_to_numerical" compatibility="10.2.000" expanded="true" height="82" name="Date to Numerical (2)" width="90" x="648" y="34"></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="attribute_name" value="timestamp"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="time_unit" value="second"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="millisecond_relative_to" value="second"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="second_relative_to" value="day"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="minute_relative_to" value="day"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="hour_relative_to" value="day"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="day_relative_to" value="month"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="week_relative_to" value="year"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="month_relative_to" value="year"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="quarter_relative_to" value="year"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="half_year_relative_to" value="year"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="year_relative_to" value="era"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="keep_old_attribute" value="true"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <description align="center" color="transparent" colored="false" width="126">convert time attribute to a number representing the total number of seconds (as an integer)</description></div><div>&nbsp; &nbsp; &nbsp; </operator></div><div>&nbsp; &nbsp; &nbsp; <connect from_op="Create ExampleSet" from_port="output" to_op="Nominal to Date" to_port="example set input"/></div><div>&nbsp; &nbsp; &nbsp; <connect from_op="Nominal to Date" from_port="example set output" to_op="Date to Numerical" to_port="example set input"/></div><div>&nbsp; &nbsp; &nbsp; <connect from_op="Date to Numerical" from_port="example set output" to_op="Generate Attributes" to_port="table input"/></div><div>&nbsp; &nbsp; &nbsp; <connect from_op="Generate Attributes" from_port="table output" to_op="Date to Numerical (2)" to_port="example set input"/></div><div>&nbsp; &nbsp; &nbsp; <connect from_op="Date to Numerical (2)" from_port="example set output" to_port="result 1"/></div><div>&nbsp; &nbsp; &nbsp; <portSpacing port="source_input 1" spacing="0"/></div><div>&nbsp; &nbsp; &nbsp; <portSpacing port="sink_result 1" spacing="0"/></div><div>&nbsp; &nbsp; &nbsp; <portSpacing port="sink_result 2" spacing="0"/></div><div>&nbsp; &nbsp; </process></div><div>&nbsp; </operator></div><div></process></div>

Sign In or Register to comment.