mapSeries<T, R> abstract method
Returns a new DataFrame with a modified series according to the
mapper
function
index
is an index of the series to be modified
name
is a name of the series to be modified
index
has precedence over name
if both parameters are specified.
At least one parameter must be specified! Otherwise, the method will throw
an error
T
is a type of the series source value, R
is a type of the mapped value.
If the value's type won't be changed, one needs to provide the same types for
both generic types.
Usage example:
import 'package:ml_dataframe/ml_dataframe';
void main() {
final data = DataFrame([
['col_1', 'col_2', 'col_3'],
[ 2, 20, 200],
[ 3, 30, 300],
[ 4, 40, 400],
]);
final modifiedData = data.mapSeries<num, num>((value) => value * 2, name: 'col_2');
print(modifiedData);
// DataFrame (3 x 3)
// col_1 col_2 col_3
// 2 40 200
// 3 60 300
// 4 80 400
}
Implementation
DataFrame mapSeries<T, R>(R Function(T value) mapper,
{int? index, String? name});