Skip to content

Commit

Permalink
fixing merge conflicts and re-running tests/Charts.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanhemani committed Jun 20, 2020
2 parents aa00705 + 051f9a3 commit 77e0f74
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 53 deletions.
31 changes: 26 additions & 5 deletions datascience/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import numpy as np
import matplotlib
matplotlib.use('agg', warn=False)
matplotlib.use('agg')
import matplotlib.pyplot as plt
import pandas
import IPython
Expand Down Expand Up @@ -86,7 +86,19 @@ def from_rows(cls, rows, labels):

@classmethod
def from_records(cls, records):
"""Create a table from a sequence of records (dicts with fixed keys)."""
"""Create a table from a sequence of records (dicts with fixed keys).
Args:
records: A list of dictionaries with same keys.
Returns:
If the list is empty, it will return an empty table.
Otherwise, it will return a table with the dictionary's keys as the column name, and the corresponding data.
If the dictionaries do not have identical keys, the keys of the first dictionary in the list is used.
"""
if not records:
return cls()
labels = sorted(list(records[0].keys()))
Expand Down Expand Up @@ -158,7 +170,16 @@ def from_df(cls, df, keep_index=False):

@classmethod
def from_array(cls, arr):
"""Convert a structured NumPy array into a Table."""
"""Convert a structured NumPy array into a Table.
Args:
arr: A structured numpy array
Returns:
A table with the field names as the column names and the corresponding data.
"""
return cls().with_columns([(f, arr[f]) for f in arr.dtype.names])

#################
Expand Down Expand Up @@ -2650,12 +2671,12 @@ def prepare_hist_with_group(group):
values_dict = collections.OrderedDict(values_dict)
if left_end is not None or right_end is not None:
if left_end is None:
if bins[0]:
if bins is not None and bins[0]:
left_end = bins[0]
else:
left_end = min([min(self.column(k)) for k in self.labels if np.issubdtype(self.column(k).dtype, np.number)])
elif right_end is None:
if bins[-1]:
if bins is not None and bins[-1]:
right_end = bins[-1]
else:
right_end = max([max(self.column(k)) for k in self.labels if np.issubdtype(self.column(k).dtype, np.number)])
Expand Down
2 changes: 1 addition & 1 deletion datascience/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import pandas as pd
import matplotlib
matplotlib.use('agg', warn=False)
matplotlib.use('agg')
import matplotlib.pyplot as plt
from scipy import stats
from scipy import optimize
Expand Down
2 changes: 1 addition & 1 deletion datascience/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.15.6'
__version__ = '0.15.7'
200 changes: 154 additions & 46 deletions tests/Charts.ipynb

Large diffs are not rendered by default.

0 comments on commit 77e0f74

Please sign in to comment.