Skip to content

Commit 3ce01cf

Browse files
committed
ENH: closes #288
1 parent 786fed7 commit 3ce01cf

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

pandas/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@
3131

3232
from pandas.tools.merge import merge, concat
3333
from pandas.tools.pivot import pivot_table, crosstab
34+
from pandas.tools.describe import value_range

pandas/tests/test_tools.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#import unittest
2+
3+
from pandas import DataFrame
4+
from pandas.tools.describe import value_range
5+
6+
import numpy as np
7+
8+
def test_value_range():
9+
df = DataFrame(np.random.randn(5, 5))
10+
df.ix[0,2] = -5
11+
df.ix[2,0] = 5
12+
13+
res = value_range(df)
14+
15+
assert( res['Minimum'] == -5 )
16+
assert( res['Maximum'] == 5 )
17+
18+
df.ix[0,1] = np.NaN
19+
20+
assert( res['Minimum'] == -5 )
21+
assert( res['Maximum'] == 5 )

pandas/tools/describe.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from pandas.core.series import Series
2+
3+
def value_range(df):
4+
'''
5+
Return the minimum and maximum of a dataframe in a series object
6+
7+
Parameters
8+
----------
9+
df : dataframe
10+
11+
Returns
12+
-------
13+
(maximum, minimum) : Series
14+
15+
'''
16+
return Series((min(df.min()), max(df.max())), ('Minimum', 'Maximum'))

0 commit comments

Comments
 (0)