-
Notifications
You must be signed in to change notification settings - Fork 0
/
series.go
153 lines (128 loc) · 3.64 KB
/
series.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package gandalff
import (
"github.com/caerbannogwhite/preludiometa"
)
type Series interface {
// Utility functions.
printInfo()
// Basic accessors.
// Return the context of the series.
GetContext() *Context
// Return the number of elements in the series.
Len() int
// Return the type of the series.
Type() preludiometa.BaseType
// Return the type and cardinality of the series.
TypeCard() preludiometa.BaseTypeCard
// Return if the series is grouped.
IsGrouped() bool
// Return if the series admits null values.
IsNullable() bool
// Return if the series is sorted.
IsSorted() SeriesSortOrder
// Return if the series is error.
IsError() bool
// Return the error message of the series.
GetError() string
// Nullability operations.
// Return if the series has null values.
HasNull() bool
// Return the number of null values in the series.
NullCount() int
// Return if the element at index i is null.
IsNull(i int) bool
// Return the null mask of the series.
GetNullMask() []bool
// Set the null mask of the series.
SetNullMask(mask []bool) Series
// Make the series nullable.
MakeNullable() Series
// Make the series non-nullable.
MakeNonNullable() Series
// Get the element at index i.
Get(i int) any
// Get the element at index i as a string.
GetAsString(i int) string
// Set the element at index i.
Set(i int, v any) Series
// Take the elements according to the given interval.
Take(params ...int) Series
// Append elements to the series.
// Value can be a single value, slice of values,
// a nullable value, a slice of nullable values or a series.
Append(v any) Series
// All-data accessors.
// Return the actual data of the series.
Data() any
// Return the nullable data of the series.
DataAsNullable() any
// Return the data of the series as a slice of strings.
DataAsString() []string
// Cast the series to a given type.
Cast(t preludiometa.BaseType) Series
// Copie the series.
Copy() Series
// Series operations.
// Filter out the elements by the given mask.
// Mask can be a bool series, a slice of bools or a slice of ints.
Filter(mask any) Series
filterIntSlice(mask []int, check bool) Series
// Apply the given function to each element of the series.
Map(f MapFunc) Series
MapNull(f MapFuncNull) Series
// Group the elements in the series.
group() Series
GroupBy(gp SeriesPartition) Series
UnGroup() Series
// Get the partition of the series.
GetPartition() SeriesPartition
// Sort Interface.
Less(i, j int) bool
equal(i, j int) bool
Swap(i, j int)
// Sort the elements of the series.
Sort() Series
SortRev() Series
// Boolean operations.
And(other any) Series
Or(other any) Series
// Arithmetic operations.
Mul(other any) Series
Div(other any) Series
Mod(other any) Series
Exp(other any) Series
Add(other any) Series
Sub(other any) Series
// Logical operations.
Eq(other any) Series
Ne(other any) Series
Gt(other any) Series
Ge(other any) Series
Lt(other any) Series
Le(other any) Series
}
type SeriesNumeric interface {
Series
// Return the minimum value of the series.
Min() any
// Return the maximum value of the series.
Max() any
// Return the sum of the values of the series.
Sum() any
// Return the mean of the values of the series.
Mean() any
// Return the median of the values of the series.
Median() any
// Return the variance of the values of the series.
Variance() any
// Return the standard deviation of the values of the series.
StdDev() any
// Return the quantile of the values of the series.
Quantile(q any) any
}
type SeriesPartition interface {
// Return the number partitions.
getSize() int
// Return the indices of the groups.
getMap() map[int64][]int
}