Python | Pandas Panel.abs ()

NumPy | Python Methods and Functions

Panel.abs() is used to return a Series / DataFrame with the absolute numeric value of each item.

Syntax: Panel.abs ()

Parameters: None

Returns: Series / DataFrame containing the absolute value of each element.

Code # 1:

# import pandas module

import pandas as pd 

import numpy as np

 

df1 = pd.DataFrame ({ ` a` : [ `Geeks` , ` For` , `geeks` , `real` ], 

  `b` : [ - 11 , + 1.025 , - 114.48 , 1333 ]})

 

data = { `item1 ` : df1, ` item2` : df1}

 
# create a panel

 

panel = pd.Panel.from_dict (data, orient = `minor` )

print (panel, "" )

print (panel [ `b` ], `` )

 

print (panel [ `b` ]. abs ( ))

Output:

Code # 2:

< / p>

# pandas module import

import pandas as pd 

import numpy as np

 

df1 = pd.DataFrame ({ ` a` : [ `Geeks` , `For` , ` geeks` ], 

  ` b` : np.random.randn ( 3 )})

 

data = { `item1` : df1, ` item2` : df1}

 
# create a panel

panel = pd.Panel.from_dict (data, orient = `minor` )

 

print (panel [ `b` ])

 

 

df2 = pd.DataFrame ({ `b` : [ 11 , 12 , 13 ]} )

print (panel [ `b ` ]. abs ())

Output:





Get Solution for free from DataCamp guru