FloatColumn

class getml.data.columns.FloatColumn(name: str = '', role: str = 'numerical', df_name: str = '')[source]

Handle for numerical data in the engine.

This is a handler for all numerical data in the getML engine, including time stamps.

Args:
name (str, optional):

Name of the categorical column.

role (str, optional):

Role that the column plays.

df_name (str, optional):

name instance variable of the DataFrame containing this column.

Examples:
import numpy as np

import getml.data as data
import getml.engine as engine
import getml.data.roles as roles

# ----------------

engine.set_project("examples")

# ----------------
# Create a data frame from a JSON string

json_str = """{
    "names": ["patrick", "alex", "phil", "ulrike"],
    "column_01": [2.4, 3.0, 1.2, 1.4],
    "join_key": ["0", "1", "2", "3"],
    "time_stamp": ["2019-01-01", "2019-01-02", "2019-01-03", "2019-01-04"]
}"""

my_df = data.DataFrame(
    "MY DF",
    roles={
        "unused_string": ["names", "join_key", "time_stamp"],
        "unused_float": ["column_01"]}
).read_json(
    json_str
)

# ----------------

col1 = my_df["column_01"]

# ----------------

col2 = 2.0 - col1

my_df.add(col2, "name", roles.numerical)

# ----------------
# If you do not explicitly set a role,
# the assigned role will either be
# roles.unused_float.

col3 = (col1 + 2.0*col2) / 3.0

my_df["column_03"] = col3
my_df.set_role("column_03", roles.numerical)

Methods

abs()

Compute absolute value.

acos()

Compute arc cosine.

as_str()

Transforms column to a string.

asin()

Compute arc sine.

assert_equal([alias])

ASSERT EQUAL aggregation.

atan()

Compute arc tangent.

avg([alias])

AVG aggregation.

cbrt()

Compute cube root.

ceil()

Round up value.

cos()

Compute cosine.

count([alias])

COUNT aggregation.

day()

Extract day (of the month) from a time stamp.

erf()

Compute error function.

exp()

Compute exponential function.

floor()

Round down value.

gamma()

Compute gamma function.

hour()

Extract hour (of the day) from a time stamp.

is_inf()

Determine whether the value is infinite.

is_nan()

Determine whether the value is nan.

is_null()

Determine whether the value is nan.

lgamma()

Compute log-gamma function.

log()

Compute natural logarithm.

max([alias])

MAX aggregation.

median([alias])

MEDIAN aggregation.

min([alias])

MIN aggregation.

minute()

Extract minute (of the hour) from a time stamp.

month()

Extract month from a time stamp.

round()

Round to nearest.

second()

Extract second (of the minute) from a time stamp.

sin()

Compute sine.

sqrt()

Compute square root.

stddev([alias])

STDDEV aggregation.

sum([alias])

SUM aggregation.

tan()

Compute tangent.

to_numpy()

Transform column to numpy.ndarray

unique()

Transform column to numpy array containing all distinct values.

update(condition, values)

Returns an updated version of this column.

var([alias])

VAR aggregation.

weekday()

Extract day of the week from a time stamp, Sunday being 0.

with_subroles(subroles[, append])

Returns a new column with new subroles.

with_unit(unit)

Returns a new column with a new unit.

year()

Extract year from a time stamp.

yearday()

Extract day of the year from a time stamp.

Attributes

last_change

The last time any of the underlying data frames has been changed.

length

The length of the column (number of rows in the data frame).

name

The name of this column.

role

The role of this column.

subroles

The subroles of this column.

unit

The unit of this column.