series

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2019 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package series defines the Series, a typed 1-dimensional data structure with an n-level index, analogous to a column in a spreadsheet.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(s1, s2 *Series) bool

Equal compares whether two series are equivalent.

Types

type Config

type Config struct {
	Name            string
	DataType        options.DataType
	Index           interface{}
	IndexName       string
	MultiIndex      []interface{}
	MultiIndexNames []string
	Manual          bool
}

The Config struct can be used in the custom Series constructor to name the Series or specify its data type.

type Element

type Element struct {
	Value      interface{}
	Null       bool
	Labels     []interface{}
	LabelTypes []options.DataType
}

An Element is a single item in a Series.

Example (Null_printer)
s := MustNew("")
fmt.Println(s.Element(0))
Output:
     Value: NaN
      Null: true
    Labels: [0]
LabelTypes: [int64]
Example (Valid_printer)
s := MustNew("foo")
fmt.Println(s.Element(0))
Output:
     Value: foo
      Null: false
    Labels: [0]
LabelTypes: [int64]

func (Element) String

func (el Element) String() string

type Grouping

type Grouping struct {
	// contains filtered or unexported fields
}

A Grouping returns a collection of index labels with mutually exclusive integer positions.

Example (Method_list)
s := MustNew(
	[]string{"foo", "bar", "baz"},
	Config{MultiIndex: []interface{}{[]int{0, 0, 1}, []int{100, 100, 101}}})
g := s.GroupByIndex()
fmt.Println(g)
Output:
{Series Grouping | NumGroups: 2, Groups: [0 | 100, 1 | 101]}

func (Grouping) First

func (g Grouping) First() *Series

First returns the first occurrence of each grouping in the Series.

func (Grouping) Group

func (g Grouping) Group(label string) *Series

Group returns the Series with the given group label, or an error if that label does not exist.

func (Grouping) Groups

func (g Grouping) Groups() []string

Groups returns all valid group labels in the Grouping.

func (Grouping) Last

func (g Grouping) Last() *Series

Last returns the last occurrence of each grouping in the Series.

func (Grouping) Len

func (g Grouping) Len() int

Len returns the number of groups in the Grouping.

func (Grouping) Max

func (g Grouping) Max() *Series

Max for each group in the Grouping.

func (Grouping) Mean

func (g Grouping) Mean() *Series

Mean for each group in the Grouping.

func (Grouping) Median

func (g Grouping) Median() *Series

Median for each group in the Grouping.

func (Grouping) Min

func (g Grouping) Min() *Series

Min for each group in the Grouping.

func (Grouping) Std

func (g Grouping) Std() *Series

Std for each group in the Grouping.

func (Grouping) String

func (g Grouping) String() string

func (Grouping) Sum

func (g Grouping) Sum() *Series

Sum for each group in the Grouping.

type InPlace

type InPlace struct {
	// contains filtered or unexported fields
}

InPlace contains methods for modifying a Series in place.

Example (Method_list)
s := MustNew("foo")
fmt.Println(s.InPlace)
Output:
{InPlace Series Handler}
Methods:
Append
Apply
Drop
DropDuplicates
DropNull
DropRows
Insert
Join
Len
Less
Set
SetRows
Sort
String
Subset
Swap
ToBool
ToDateTime
ToFloat64
ToInt64
ToInterface
ToString

func (InPlace) Append

func (ip InPlace) Append(val interface{}, idx ...interface{}) error

Append adds a row at a specified integer position and modifies the Series in place.

func (InPlace) Apply

func (ip InPlace) Apply(fn func(interface{}) interface{})

Apply a callback function to every value in a Series and modify the Series in place.

func (InPlace) Drop

func (ip InPlace) Drop(row int) error

Drop drops the row at the specified integer position and modifies the Series in place.

func (InPlace) DropDuplicates

func (ip InPlace) DropDuplicates()

DropDuplicates drops any rows containing duplicate index + Series values and modifies the Series in place.

func (InPlace) DropNull

func (ip InPlace) DropNull()

DropNull drops all null values and modifies the Series in place.

func (InPlace) DropRows

func (ip InPlace) DropRows(rowPositions []int) error

DropRows drops the rows at the specified integer position and modifies the Series in place. If an error would be encountered in any row position, the entire operation is cancelled before it starts.

func (InPlace) Insert

func (ip InPlace) Insert(pos int, val interface{}, idxLabels ...interface{}) error

Insert inserts a new row into the Series immediately before the specified integer position and modifies the Series in place. If the original Series is empty, replaces it with a new Series.

func (InPlace) Join

func (ip InPlace) Join(s2 *Series) error

Join converts s2 to the same type as the base Series (s), appends s2 to the end, and modifies s in place.

func (InPlace) Len

func (ip InPlace) Len() int

Len returns the length of the underlying Series (required by Sort interface)

func (InPlace) Less

func (ip InPlace) Less(i, j int) bool

func (InPlace) Set

func (ip InPlace) Set(row int, val interface{}) error

Set sets the values in the specified row to val and modifies the Series in place. First converts val to be the same type as the index level.

func (InPlace) SetRows

func (ip InPlace) SetRows(rowPositions []int, val interface{}) error

SetRows sets all the values in the specified rows to val and modifies the Series in place. First converts val to be the same type as the index level. If an error would be encountered in any row position, the entire operation is cancelled before it starts.

func (InPlace) Sort

func (ip InPlace) Sort(asc bool)

Sort sorts the series by its values and modifies the Series in place.

func (InPlace) String

func (ip InPlace) String() string

func (InPlace) Subset

func (ip InPlace) Subset(rowPositions []int) error

Subset subsets a Series in place.

func (InPlace) Swap

func (ip InPlace) Swap(i, j int)

Swap swaps the selected rows in place.

func (InPlace) ToBool

func (ip InPlace) ToBool()

ToBool converts Series values to bool in place.

func (InPlace) ToDateTime

func (ip InPlace) ToDateTime()

ToDateTime converts Series values to datetime in place.

func (InPlace) ToFloat64

func (ip InPlace) ToFloat64()

ToFloat64 converts Series values to float64 in place.

func (InPlace) ToInt64

func (ip InPlace) ToInt64()

ToInt64 converts Series values to int64 in place.

func (InPlace) ToInterface

func (ip InPlace) ToInterface()

ToInterface converts Series values to interface in place.

func (InPlace) ToString

func (ip InPlace) ToString()

ToString converts Series values to string in place.

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index contains index selection and conversion

Example (Valid_printer)
s := MustNew([]string{"foo", "bar", "baz"})
fmt.Println(s.Index)
Output:
{Series Index | Len: 3, NumLevels: 1}

func (Index) AppendLevel

func (idx Index) AppendLevel(values interface{}, name string) error

AppendLevel adds a new index level to the end of the current index and modifies the Series in place.

func (Index) At

func (idx Index) At(row int, level int) interface{}

At returns the index value at a specified row position and index level but returns nil if either integer is out of range.

func (Index) Convert

func (idx Index) Convert(dataType string, level int) error

Convert converts an index level to datatype in place.

func (Index) DropLevel

func (idx Index) DropLevel(level int) error

DropLevel drops the specified index level and modifies the Series in place.

func (Index) DropNull

func (idx Index) DropNull(level int) error

DropNull drops null index values at the index level specified and modifies the Series in place.

func (Index) Filter

func (idx Index) Filter(level int, cmp func(interface{}) bool) []int

Filter an index level using a callback function test. The Filter function iterates over all index values in interface{} form and applies the callback test to each. The return value is a slice of integer positions of all the rows passing the test. The caller is responsible for handling the type assertion on the interface, though this step is not necessary if the datatype is known with certainty. For example, here are two ways to write a filter that returns all rows with the suffix "boo":

#1 (safer) error check type assertion

 s.Index.Filter(0, func(val interface{}) bool {
		v, ok := val.(string)
		if !ok {
			return false
		}
		if strings.HasSuffix(v, "boo") {
			return true
		}
		return false
	})

Input: bamboo 0 leaves 1 taboo 2

Output: []int{0,2}

#2 (riskier) no error check

 s.Filter(func(val interface{}) bool {
		if strings.HasSuffix(val.(string), "boo") {
			return true
		}
		return false
	})

func (Index) Flip

func (idx Index) Flip(level int) (*Series, error)

Flip replaces the Series values with the labels at the supplied index level, and vice versa.

func (Index) InsertLevel

func (idx Index) InsertLevel(pos int, values interface{}, name string) error

InsertLevel inserts a level into the index and modifies the Series in place.

func (Index) Len

func (idx Index) Len() int

Len returns the number of items in each level of the index.

func (Index) Less

func (idx Index) Less(i, j int) bool

Less compares two elements and returns true if the first is less than the second. Required by Sort interface.

func (Index) Reindex

func (idx Index) Reindex(level int) error

Reindex converts an index level in place to an ordered default range []int{0, 1, 2,...n}

func (Index) RenameLevel

func (idx Index) RenameLevel(level int, name string) error

RenameLevel renames an index level in place but does not change anything if level is out of range.

func (Index) SelectName

func (idx Index) SelectName(name string) int

SelectName returns the integer position of the index level at the first occurrence of the supplied name, or -1 if not a valid index level name.

func (Index) SelectNames

func (idx Index) SelectNames(names []string) []int

SelectNames returns the integer positions of the index levels with the supplied names.

func (Index) Set

func (idx Index) Set(row int, level int, val interface{}) error

Set sets the label at the specified index row and level to val and modifies the Series in place. First converts val to be the same type as the index level.

func (Index) Sort

func (idx Index) Sort(asc bool)

Sort sorts the index by index level 0 and modifies the index in place.

func (Index) String

func (idx Index) String() string

func (Index) SubsetLevels

func (idx Index) SubsetLevels(levelPositions []int) error

SubsetLevels modifies the Series in place with only the specified index levels.

func (Index) Swap

func (idx Index) Swap(i, j int)

Swap swaps two labels at index level 0 and modifies the index in place. Required by Sort interface.

func (Index) SwapLevels

func (idx Index) SwapLevels(i, j int) error

SwapLevels swaps two levels in the index and modifies the Series in place.

func (Index) Values

func (idx Index) Values() [][]interface{}

Values returns an []interface{} of the values at each level of the index

type Series

type Series struct {
	Index   Index
	InPlace InPlace
	// contains filtered or unexported fields
}

A Series is a 1-D data container with a labeled index, static type, and the ability to handle null values

Example (Empty_series)
s := newEmptySeries()
fmt.Println(s)
Output:
{Empty Series}

func FromInternalComponents

func FromInternalComponents(container values.Container, index index.Index, name string) *Series

FromInternalComponents is a semi-private method for hydrating Series within the DataFrame module. The required inputs are not available to the caller.

func MustNew

func MustNew(data interface{}, config ...Config) *Series

MustNew returns a new Series or logs an error and returns an empty Series.

func New

func New(data interface{}, config ...Config) (*Series, error)

New creates a new Series with the supplied values and an optional config.

Example (Config_datatype)
s := MustNew([]interface{}{"1", "foo"}, Config{DataType: options.Float64})
fmt.Println(s)
Output:
0    1.00
1     NaN

datatype: float64
Example (Config_indexName)
s := MustNew([]string{"foo", "bar"}, Config{IndexName: "baz"})
fmt.Println(s)
Output:
baz
  0    foo
  1    bar

datatype: string
Example (Config_nameOnly)
s := MustNew([]string{"foo", "bar"}, Config{Name: "baz"})
fmt.Println(s)
Output:
0    foo
1    bar

datatype: string
name: baz
Example (Datetime_manyRows)
s := MustNew([]time.Time{
	time.Date(2019, 5, 1, 15, 9, 30, 30, time.UTC),
	time.Date(2019, 5, 2, 15, 15, 55, 55, time.UTC),
})
fmt.Println(s)
Output:
0    5/1/2019T15:09:30
1    5/2/2019T15:15:55

datatype: dateTime
Example (Datetime_single)
s := MustNew([]time.Time{time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC)})
fmt.Println(s)
Output:
0    1/1/2019T00:00:00

datatype: dateTime
Example (Exceed_maxRows_even)
options.SetDisplayMaxRows(2)
s := MustNew([]float64{0, 1, 2, 3, 4})
fmt.Println(s)
options.RestoreDefaults()
Output:
0    0.00
...
4    4.00

datatype: float64
Example (Exceed_maxRows_odd)
options.SetDisplayMaxRows(3)
s := MustNew([]float64{0, 1, 2, 3, 4})
fmt.Println(s)
options.RestoreDefaults()
Output:
0    0.00
1    1.00
...
4    4.00

datatype: float64
Example (Float_precision)
s := MustNew([]float64{1.5511, 2.6611})
fmt.Println(s)
Output:
0    1.55
1    2.66

datatype: float64
Example (MaxWidth_index)
s := MustNew([]string{"foo", "bar"}, Config{Index: []string{"This is a very long index row. Very long indeed.", "qux"}, IndexName: "baz"})
options.SetDisplayMaxWidth(10)
fmt.Println(s)
options.RestoreDefaults()
Output:
       baz
This is...    foo
       qux    bar

datatype: string
Example (MaxWidth_value)
s := MustNew([]string{"This is a very long value row. Very long indeed.", "foo"})
fmt.Println(s)
Output:
0    This is a very long value row. V...
1                                    foo

datatype: string
Example (Named_later)
s := MustNew(
	[]string{"foo", "bar", "", "baz"},
)
s.Rename("foobar")
fmt.Println(s)
Output:
0    foo
1    bar
2    NaN
3    baz

datatype: string
name: foobar
Example (Nonsequential_repeating)
s := MustNew(
	[]string{"foo", "bar", "", "baz", "qux", "quux"},
	Config{
		Name:            "foobar",
		MultiIndex:      []interface{}{[]int{0, 0, 1, 1, 0, 0}, []int{10000, 10100, 10200, 10300, 10400, 10500}},
		MultiIndexNames: []string{"id", "code"},
	},
)
fmt.Println(s)
Output:
id  code
 0 10000     foo
   10100     bar
 1 10200     NaN
   10300     baz
 0 10400     qux
   10500    quux

datatype: string
name: foobar
Example (Partially_named_indexes)
s := MustNew(
	[]string{"foo", "bar"},
	Config{
		MultiIndex: []interface{}{
			[]int{0, 1},
			[]int{10000, 10100}},
		MultiIndexNames: []string{"", "code"},
		Name:            "foobar"},
)
fmt.Println(s)
Output:
   code
0 10000    foo
1 10100    bar

datatype: string
name: foobar
Example (Repeating_allowed)
options.SetDisplayRepeatedLabels(true)
s := MustNew(
	[]string{"foo", "bar", "baz", "qux"},
	Config{Index: []int{0, 0, 1, 1}})
fmt.Println(s)
options.RestoreDefaults()
Output:
0    foo
0    bar
1    baz
1    qux

datatype: string
Example (Repeating_multiIndex)
s := MustNew(
	[]string{"foo", "bar", "baz", "qux"},
	Config{MultiIndex: []interface{}{[]int{0, 0, 1, 1}, []string{"A", "A", "B", "B"}}})
fmt.Println(s)
Output:
0 A    foo
       bar
1 B    baz
       qux

datatype: string
Example (Repeating_singleIndex)
s := MustNew(
	[]string{"foo", "bar", "baz", "qux"},
	Config{Index: []int{0, 0, 1, 1}})
fmt.Println(s)
Output:
0    foo
     bar
1    baz
     qux

datatype: string
Example (String)

[START constructor examples]

s, _ := New([]string{"foo", "bar", "", "baz"})
fmt.Println(s)
Output:
0    foo
1    bar
2    NaN
3    baz

datatype: string
Example (String_multiIdx)
s := MustNew(
	[]string{"foo", "bar", "", "baz"},
	Config{MultiIndex: []interface{}{[]int{0, 1, 2, 3}, []int{100, 101, 102, 103}}})
fmt.Println(s)
Output:
0 100    foo
1 101    bar
2 102    NaN
3 103    baz

datatype: string
Example (String_multiIdx_named_sequential_repeating)
s := MustNew(
	[]string{"foo", "bar", "", "baz"},
	Config{
		Name:            "foobar",
		MultiIndex:      []interface{}{[]int{0, 0, 1, 1}, []int{10000, 10100, 10200, 10300}},
		MultiIndexNames: []string{"id", "code"},
	},
)
fmt.Println(s)
Output:
id  code
 0 10000    foo
   10100    bar
 1 10200    NaN
   10300    baz

datatype: string
name: foobar
Example (String_named)
s := MustNew([]string{"foo", "bar", "", "baz"}, Config{Name: "foobar"})
fmt.Println(s)
Output:
0    foo
1    bar
2    NaN
3    baz

datatype: string
name: foobar
Example (String_singleIdx)
s := MustNew([]string{"foo", "bar", "", "baz"}, Config{Index: []int{100, 101, 102, 103}})
fmt.Println(s)
Output:
100    foo
101    bar
102    NaN
103    baz

datatype: string

func (*Series) After

func (s *Series) After(t time.Time) []int

After filter - value is after a specific time (datetime).

func (*Series) Append

func (s *Series) Append(val interface{}, idxLabels ...interface{}) (*Series, error)

Append adds a row at the end and returns a new Series.

func (*Series) Apply

func (s *Series) Apply(fn func(interface{}) interface{}) *Series

Apply a callback function to every value in a Series and return a new Series. The Apply function iterates over all Series values in interface{} form and applies the callback function to each. The final values are then converted to match the datatype of the original Series. The caller is responsible for handling the type assertion on the interface, though this step is not necessary if the datatype is known with certainty. For example, here are two ways to write an apply function that computes the z-score of every row and rounds it two decimal points:

#1 (safer) error check type assertion

 s.Apply(func(val interface{}) interface{} {
		v, ok := val.(float64)
			if !ok {
				return ""
			}
		return (v - s.Mean()) / s.Std()

Input: 0 1 1 2 2 3

Output: 0 -1.22... 1 0 2 1.22...

#2 (riskier) no error check

 s.Apply(func(val interface{}) interface{} {
		return (val.(float64) - s.Mean()) / s.Std()
	})

func (*Series) At

func (s *Series) At(position int) interface{}

At returns the value at a single integer position, bur returns nil if the position is out of range.

func (*Series) Before

func (s *Series) Before(t time.Time) []int

Before filter - value is before a specific time (datetime).

func (*Series) Contains

func (s *Series) Contains(substr string) []int

Contains filter - value contains substr (string).

func (*Series) Convert

func (s *Series) Convert(datatype string) *Series

Convert a Series and return as new Series.

func (*Series) Copy

func (s *Series) Copy() *Series

Copy creates a new deep copy of a Series.

func (*Series) DataType

func (s *Series) DataType() string

DataType is the data type of the Series' values. Mimics reflect.Type with the addition of time.Time as DateTime.

func (*Series) Describe

func (s *Series) Describe()

Describe the key details of the Series.

Example (Bool)
s, _ := New([]bool{true, false, false})
s.Describe()
Output:
  len       3
valid       3
 null       0
  sum    1.00
 mean    0.33

datatype: bool
Example (Datetime)
s, _ := New([]time.Time{
	time.Date(2019, 4, 18, 15, 0, 0, 0, time.UTC),
	time.Date(2019, 4, 19, 15, 0, 0, 0, time.UTC),
	time.Time{},
})
s.Describe()
Output:
     len                                3
   valid                                2
    null                                1
  unique                                2
earliest    2019-04-18 15:00:00 +0000 UTC
  latest    2019-04-19 15:00:00 +0000 UTC

datatype: dateTime
Example (Datetime_empty)
s, _ := New([]time.Time{time.Time{}})
s.Describe()
Output:
     len                                1
   valid                                0
    null                                1
  unique                                0
earliest    0001-01-01 00:00:00 +0000 UTC
  latest    0001-01-01 00:00:00 +0000 UTC

datatype: dateTime
Example (Float)
s, _ := New([]float64{1, math.NaN(), 2, 3, 4, 5, math.NaN(), 6, 7, 8, 9})
s.Describe()
Output:
  len      11
valid       9
 null       2
 mean    5.00
  min    1.00
  25%    2.50
  50%    5.00
  75%    7.50
  max    9.00

datatype: float64
Example (Float_empty)
s, _ := New([]float64{})
s.Describe()
Output:
  len      0
valid      0
 null      0
 mean    NaN
  min    NaN
  max    NaN

datatype: float64
Example (Int)
s, _ := New([]int64{1, 2, 3, 4, 5, 6, 7, 8, 9})
s.Describe()
Output:
  len       9
valid       9
 null       0
 mean    5.00
  min    1.00
  25%    2.50
  50%    5.00
  75%    7.50
  max    9.00

datatype: int64
Example (Interface)
s, _ := New([]interface{}{1.5, 1, "", false})
s.Describe()
Output:
  len    4
valid    3
 null    1

datatype: interface
Example (ScalarString)
s, _ := New("foo")
s.name = "bar"
s.Describe()
Output:
   len    1
 valid    1
  null    0
unique    1

datatype: string
name: bar
Example (String)
s, _ := New([]string{"low", "medium", "medium", ""})
s.Describe()
Output:
   len    4
 valid    3
  null    1
unique    2

datatype: string
Example (String_empty)
s, _ := New([]string{"", ""})
s.Describe()
Output:
   len    2
 valid    0
  null    2
unique    0

datatype: string

func (*Series) Drop

func (s *Series) Drop(row int) (*Series, error)

Drop drops the row at the specified integer position and returns a new Series.

func (*Series) DropDuplicates

func (s *Series) DropDuplicates() *Series

DropDuplicates drops any rows containing duplicate index + Series values and returns a new Series.

func (*Series) DropNull

func (s *Series) DropNull() *Series

DropNull drops all null values and modifies the Series in place.

func (*Series) DropRows

func (s *Series) DropRows(positions []int) (*Series, error)

DropRows drops the rows at the specified integer position and returns a new Series.

func (*Series) EQ

func (s *Series) EQ(comparison float64) []int

EQ filter - Equal To (numeric).

func (*Series) Earliest

func (s *Series) Earliest() time.Time

Earliest returns the earliest non-null time.Time{} in the Series. If applied to anything other than dateTime, return time.Time{}.

func (*Series) Element

func (s *Series) Element(position int) Element

Element returns information about the value and index labels at this position but panics if an out-of-range position is provided.

func (*Series) False

func (s *Series) False() []int

False filter - value is false (bool).

func (*Series) Filter

func (s *Series) Filter(cmp func(interface{}) bool) []int

Filter a Series using a callback function test. The Filter function iterates over all Series values in interface{} form and applies the callback test to each. The return value is a slice of integer positions of all the rows passing the test. The caller is responsible for handling the type assertion on the interface, though this step is not necessary if the datatype is known with certainty. For example, here are two ways to write a filter that returns all rows with the suffix "boo":

#1 (safer) error check type assertion

 s.Filter(func(val interface{}) bool {
		v, ok := val.(string)
		if !ok {
			return false
		}
		if strings.HasSuffix(v, "boo") {
			return true
		}
		return false
	})

Input: 0 bamboo 1 leaves 2 taboo

Output: []int{0,2}

#2 (riskier) no error check

 s.Filter(func(val interface{}) bool {
		if strings.HasSuffix(val.(string), "boo") {
			return true
		}
		return false
	})

func (*Series) From

func (s *Series) From(start int, end int) *Series

From subsets the Series from start to end (inclusive) and returns a new Series. If an invalid position is provided, returns empty Series.

func (*Series) GT

func (s *Series) GT(comparison float64) []int

GT filter: Greater Than (numeric).

func (*Series) GTE

func (s *Series) GTE(comparison float64) []int

GTE filter: Greater Than or Equal To (numeric).

func (*Series) GroupByIndex

func (s *Series) GroupByIndex(levelPositions ...int) Grouping

GroupByIndex groups a Series by one or more of its index levels. If no int is provided, all index levels are used.

func (*Series) InList

func (s *Series) InList(list []string) []int

InList filter - value is contained within list (string).

func (*Series) Insert

func (s *Series) Insert(pos int, val interface{}, idxLabels ...interface{}) (*Series, error)

Insert inserts a new row into the Series immediately before the specified integer position and returns a new Series.

func (*Series) Join

func (s *Series) Join(s2 *Series) (*Series, error)

Join converts s2 to the same type as the base Series (s), appends s2 to the end, and returns a new Series.

func (*Series) LT

func (s *Series) LT(comparison float64) []int

LT filter - Less Than (numeric).

func (*Series) LTE

func (s *Series) LTE(comparison float64) []int

LTE filter - Less Than or Equal To (numeric).

func (*Series) Latest

func (s *Series) Latest() time.Time

Latest returns the latest non-null time.Time{} in the Series. If applied to anything other than dateTime, return time.Time{}.

func (*Series) Len

func (s *Series) Len() int

Len returns the number of Elements (i.e., Value/Null pairs) in the Series.

func (*Series) LookupSeries

func (s *Series) LookupSeries(s2 *Series) *Series

LookupSeries performs a vlookup of each values in one Series against another Series.

func (*Series) Max

func (s *Series) Max() float64

Max of a series. Applies to float64 and int64. If inapplicable, defaults to math.Nan().

func (*Series) MaxWidth

func (s *Series) MaxWidth() int

MaxWidth returns the max number of characters in any value in the Series. For use in printing Series.

func (*Series) Mean

func (s *Series) Mean() float64

Mean of non-null series values. For bool values, mean of true values. Applies to float64 and int64. If inapplicable, defaults to math.Nan().

func (*Series) Median

func (s *Series) Median() float64

Median of a series. Applies to float64 and int64. If inapplicable, defaults to math.Nan().

func (*Series) Min

func (s *Series) Min() float64

Min of a series. Applies to float64 and int64. If inapplicable, defaults to math.Nan().

func (*Series) NEQ

func (s *Series) NEQ(comparison float64) []int

NEQ filter - Not Equal To (numeric).

func (Series) Name

func (s Series) Name() string

Name returns the Series' name.

func (*Series) NumLevels

func (s *Series) NumLevels() int

NumLevels returns the number of index levels in the Series.

func (*Series) Quartile

func (s *Series) Quartile(i int) float64

Quartile returns the data's ith quartile point. 1: median between min and median, 2: median, 3: median between median and max. Applies to float and int. If inapplicable, defaults to math.Nan().

func (*Series) Rename

func (s *Series) Rename(name string)

Rename the Series.

func (*Series) SelectLabel

func (s *Series) SelectLabel(label string) int

SelectLabel returns the integer location of the first row in index level 0 with the supplied label, or -1 if the label does not exist.

func (*Series) SelectLabels

func (s *Series) SelectLabels(labels []string, level int) []int

SelectLabels returns the integer locations of all rows with the supplied labels within the supplied level. If an error is encountered, returns a new slice of 0 length.

func (*Series) Set

func (s *Series) Set(row int, val interface{}) (*Series, error)

Set sets the value in the specified rows to val and returns a new Series.

func (*Series) SetRows

func (s *Series) SetRows(rowPositions []int, val interface{}) (*Series, error)

SetRows sets all the values in the specified rows to val and returns a new Series.

func (*Series) Sort

func (s *Series) Sort(asc bool) *Series

Sort sorts the series by its values and returns a new Series.

func (*Series) Std

func (s *Series) Std() float64

Std returns the Standard Deviation of a series.

Applies to: Float, Int. If inapplicable, defaults to math.Nan().

func (*Series) String

func (s *Series) String() string

func (*Series) Subset

func (s *Series) Subset(rowPositions []int) (*Series, error)

Subset subsets a Series based on the supplied integer positions and returns a new Series.

func (*Series) Sum

func (s *Series) Sum() float64

Sum of non-null float64 or int64 Series values. For bool values, sum of true values. If inapplicable, defaults to math.Nan().

func (*Series) Swap

func (s *Series) Swap(i, j int) (*Series, error)

Swap swaps the selected rows and returns a new Series.

func (*Series) ToBool

func (s *Series) ToBool() *Series

ToBool converts Series values to bool and returns a new Series.

func (*Series) ToDateTime

func (s *Series) ToDateTime() *Series

ToDateTime converts Series values to time.Time and returns a new Series.

func (*Series) ToFloat64

func (s *Series) ToFloat64() *Series

ToFloat64 converts Series values to float64 and returns a new Series.

func (*Series) ToInt64

func (s *Series) ToInt64() *Series

ToInt64 converts Series values to int64 and returns a new Series.

func (*Series) ToInterface

func (s *Series) ToInterface() *Series

ToInterface converts Series values to interface and returns a new Series.

func (*Series) ToInternalComponents

func (s *Series) ToInternalComponents() (values.Container, index.Index)

ToInternalComponents is a semi-private method for using a Series within the DataFrame module. The required inputs are not available to the caller.

func (*Series) ToString

func (s *Series) ToString() *Series

ToString converts Series values to string and returns a new Series.

func (*Series) True

func (s *Series) True() []int

True filter - value is true (bool).

func (*Series) Unique

func (s *Series) Unique() []string

Unique returns a de-duplicated list of all non-null values (as []string) that appear in the Series.

func (*Series) Vals

func (s *Series) Vals() interface{}

Vals returns all the values (including null values) in the Series as an interface Use Vals for type assertion.

func (*Series) ValueCounts

func (s *Series) ValueCounts() map[string]int

ValueCounts returns a map of non-null value labels to number of occurrences in the Series.

func (*Series) Values

func (s *Series) Values() []interface{}

Values returns all the values (including null values) in the Series as an interface slice.

func (*Series) XS

func (s *Series) XS(rowPositions []int, levelPositions []int) (*Series, error)

XS returns a new Series with only the rows and index levels at the specified positions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL