Panel.clip_lower()
is used to return a copy of the input below the truncated threshold.
Syntax: Panel.clip_lower (threshold, axis = None, inplace = False)
Parameters:
threshold: Minimum value allowed. All values below threshold will be set to this value.
float: every value is compared to threshold.
array-like: The shape of threshold should match the object it’s compared to.
axis: Align self with threshold along the given axis.
inplace: Whether to perform the operation in place on the data.
Returns: same type as input.
Code # 1: Create a panel with using from_dict ()
# 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, "" ) |
Output:
Code # 2: Using clip_lower ()
# 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, " " ) print (panel [ ’b’ ], ’ ’ ) df2 = pd.DataFrame ({ ’b’ : [ 11 , 12 , 13 ]}) print (panel [ ’b’ ]. clip_lower (df2 [ ’ b’ ] , axis = 0 )) |
Output:
Code # 3:
# create an empty panel import pandas as pd import numpy as np data = { ’Item1’ : pd.DataFrame (np.random.randn ( 7 , 4 )), ’Item2’ : pd.DataFrame (np.random.randn ( 4 , 5 ))} pen = pd.Panel (data) print (pen [ ’Item1’ ], ’ ’ ) p = pen [ ’Item1’ ] [ 0 ]. clip_lower (np.random.randn ( 7 )) print (p) |
Output: