Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- df = pd.DataFrame({
- 'numbers': list(range(10)),
- 'chars': list('abcdefghij'),
- 'floats': [0.1*x for x in range(10)],
- })
- header = 'numbers'
- print('header:', header)
- print('type:', df[header].dtypes)
- print('min,max:', df[header].min(), df[header].max())
- print('-------------------------------')
- header = 'chars'
- print('header:', header)
- print('type:', df[header].dtypes)
- print('min,max:', df[header].min(), df[header].max())
- print('-------------------------------')
- headers = ['numbers', 'floats']
- print('headers:', headers)
- print('--- type ---')
- print(df[headers].dtypes)
- print('--- min ---')
- print(df[headers].min())
- print('--- max ---')
- print(df[headers].max())
- print('-------------------------------')
- print('--- type ---')
- print(df.dtypes['numbers'])
- print(df.dtypes['floats'])
- print('--- min ---')
- print(df.min()['numbers'])
- print(df.min()['floats'])
- print('--- max ---')
- print(df.max()['numbers'])
- print(df.max()['floats'])
- print('-------------------------------')
- '''
- header: numbers
- type: int64
- min,max: 0 9
- -------------------------------
- header: chars
- type: object
- min,max: a j
- -------------------------------
- headers: ['numbers', 'floats']
- --- type ---
- numbers int64
- floats float64
- dtype: object
- --- min ---
- numbers 0.0
- floats 0.0
- dtype: float64
- --- max ---
- numbers 9.0
- floats 0.9
- dtype: float64
- -------------------------------
- --- type ---
- int64
- float64
- --- min ---
- 0
- 0.0
- --- max ---
- 9
- 0.9
- -------------------------------
- '''
Advertisement
Add Comment
Please, Sign In to add comment