Load the packages


In [ ]:
require 'torch'
require 'Dataframe'

Load the data


In [ ]:
my_data = Dataframe('../../data/realistic_29_row_data.csv')

Checkout the first couple of rows

The simplest example way to have a quick look at the data is to use the output together with head/tail - the simplest form of subsetting


In [ ]:
my_data:head(2):output()
my_data:tail(2):output()

Searching the dataframe

The where can be convenient when you want to find a particular subset


In [ ]:
my_data:where('Gender', 'Male'):head(2):output()

More flexible searching is allowed through custom search functions


In [ ]:
my_data:where(function(row) return row.Gender == "Male" and row.Weight > 70 end):output()

Update

We can easily update the table using an update function


In [ ]:
my_data:
    update(
        function(row) return row.Weight > 88 end,
        function(row)
            row.Weight = 88
            return row
        end)

my_data:
    where(function(row) return row.Gender == "Male" and row.Weight > 70 end):
    output()

The set function

Closely related to the update is the simpler set function


In [ ]:
my_data:
    set{item_to_find = 55.5, 
        column_name = 'Weight', 
        new_value = Df_Dict({Gender = "Female"})}

my_data:
    where(function(row) return row.Gender == "Female" and row.Weight < 60 end):
    output()

In [ ]: