Skip to content

Commit

Permalink
all_ints() can now handle pd.DataFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
juanshishido committed Aug 28, 2015
1 parent f707582 commit dfed150
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tufte.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,21 @@ def plot_style(ax, plot_type):

def all_ints(x):

if isinstance(x, pd.DataFrame):
x_temp = []
for c in x.columns:
x_temp = x_temp + x[c].tolist()

x = x_temp

if type(x) not in (list, np.ndarray, pd.Series):
raise TypeError('Container must be of type: list, np.ndarray, or pd.Series')

return sum([float(v).is_integer() for v in x]) == len(x)


def cast_to(kind=float, x=None):

if kind == 'float':
x = [round(float(v), 1) for v in x]
elif kind == 'int':
Expand Down

0 comments on commit dfed150

Please sign in to comment.