Series.agg() is used to pass a function or list of functions to be applied to a series or even to each element of a series individually. In the case of a list of functions, multiple results are returned by the
agg () method.
Syntax: Series.agg (func, axis = 0) p>
func: Function, list of function or string of function name to be called on Series.
axis: 0 or `index` for row wise operation and 1 or `columns` for column wise operation.
Return Type: The return type depends on return type of function passed as parameter.
Example # 1:
This example passes a lambda function that simply adds 2 to each value in the series. Since the function will be applied to each series value, the return type is also series. A random row of 10 elements is generated by passing an array using a random Numpy method.
As shown in the output, f an function has been applied to each value, and 2 — to each value in the series.
Example # 2: Passing a list of functions
This example passes a list of some default Python functions and the
agg method () returns multiple results in multiple variables.
As shown in the output, several results were returned. Min, Max and Sorted Array were returned in different variables result1, result2, result3 respectively.
This book is an indispensable guide focuses on Machine Learning and R Programming, in an instructive and conversational tone which helps them who want to make their career in Big Data Analytics/ Data ...
As the title promises, this book will introduce you to one of the world’s most popular programming languages: Python. It’s aimed at beginning programmers as well as more experienced programmers wh...
The ability to identify patterns is an essential component of sensory intelli- gent machines. Pattern recognition is therefore an indispensible component of the so-called “Intelligent Control System...
The genesis of this book began in 2012. Hadoop was being explored in mainstream organizations, and we believed that information architecture was about to be transformed. For many years, business intel...