Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def range(series):
- return series.max() - series.min()
- df.apply(range, axis = 0)
- # or
- df.apply(lambda series: series.max() - series.min(), axis = 0)
- '''
- Mon 20
- Thu 13
- Wed 25
- '''
- df.apply(range, axis = 1)
- # or
- df.apply(lambda series: series.max() - series.min(), axis = 1)
- '''
- Steven 18
- Elan 30
- Ivelin 13
- '''
- ########################################################
- summer.Athlete.apply(lambda x: x[0]) # working with all elements in Athlete column
- summer.iloc[:, 1:3].applymap(lambda x: x[0]) # working with all elements in first and second column
- ########################################################
- # Calculate for all numerical columns the range between highest and lowest value!
- cars.iloc[:, 0:-2].apply(lambda x: x.max() - x.min(), axis = 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement