Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Series.pow() is a series mathematical operation method. This is used to put each element of passed series as exponential power of caller series and returned the results. For this, index of both the series has to be same otherwise error is returned.
Syntax: Series.pow(other, =None, fill_value=None, axis=0)
other: Other series or list type to be put as exponential power to the caller series
level: Value to be replaced by NaN in series/list before operation
fill_value: Integer value of level in case of multi index
Return : Value of caller series with other series as its exponential power
In this example, two Series are created using Pandas .Series() method. None of the series is having null values. The second series is directly passed as other parameter to return the values after operation.
As shown in the output, the returned values are equal to first series with second series as its exponential power.
0 1 1 8 2 25 3 6 4 27 5 16 dtype: int64
Example #2: Handling Null values
In this example, NaN values are also put in the series using numpy.nan method. After that 2 is passed to fill_value parameter to replace null values with 2.
As shown in the output, all NaN values were replaced by 2 before the operation and result was returned without any Null value in it.
0 1.0 1 4.0 2 125.0 3 36.0 4 9.0 5 2.0 6 64.0 7 4.0 dtype: float64
- Python | pandas.map()
- How to Do a vLookup in Python using pandas
- Python | Pandas Series.sem()
- Python | Pandas dataframe.mad()
- Python | Pandas dataframe.mean()
- Python | Pandas dataframe.max()
- Python | Pandas.pivot_table()
- Python | Pandas.pivot()
- Python | Pandas.CategoricalDtype()
- Python | Pandas PeriodIndex.second
- Python | Pandas TimedeltaIndex.take()
- Python | Pandas Series.max()
- Python | Pandas dataframe.get()
- Python | Pandas Period.second
- Python | Pandas Series.str.contains()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai