Method: Remi::DataSource::CsvFile#to_dataframe

Defined in:
lib/remi/data_source/csv_file.rb

#to_dataframeObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/remi/data_source/csv_file.rb', line 78

def to_dataframe
  # Assumes that each file has exactly the same structure
  result_df = nil
  extracted.each_with_index do |filename, idx|
    @logger.info "Converting #{filename} to a dataframe"
    csv_df = Daru::DataFrame.from_csv filename, @csv_options

    csv_df[@filename_field] = Daru::Vector.new([filename] * csv_df.size, index: csv_df.index) if @filename_field
    if idx == 0
      result_df = csv_df
    else
      result_df = result_df.concat csv_df
    end
  end

  result_df
end