Skip to content

Commit

Permalink
MAINT: Makes compatible with latest pandas (#112)
Browse files Browse the repository at this point in the history
* MAINT: Makes compatible with latest pandas
Fixes #111 Pandas changed the reduce functionality
http://pandas.pydata.org/pandas-docs/stable/whatsnew.html?highlight=rolling_mean#changes-to-make-output-of-dataframe-apply-consistent
the new api is backwards incompatible with >0.23.4. The changes in this
pull request work with both versions of pandas. There may be a better
way to achive this, though I think it is preferable to keep
sourcetracker compatible with the recent versions of pandas

* Added the replace flag back in

* Added the replace flag back in

* updated changelog
  • Loading branch information
johnchase authored and lkursell committed Dec 17, 2018
1 parent 889f409 commit b81220f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 2.0.1-dev (changes since 2.0.1 go here)

* Updated subsample function to be compatible with new version of pandas
* A unified API for sourcetracking with Gibbs sampling, including
leave-one-out cross-validation, has been created and is accessible as
``sourcetracker.gibbs``.
Expand Down
6 changes: 4 additions & 2 deletions sourcetracker/_sourcetracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@ def subsample_dataframe(df, depth, replace=False):
pd.DataFrame
Subsampled dataframe.
'''
f = partial(subsample_counts, n=depth, replace=replace)
return df.apply(f, axis=1, reduce=False, raw=False)
def subsample(x):
return pd.Series(subsample_counts(x.values, n=depth, replace=replace),
index=x.index)
return df.apply(subsample, axis=1)


def generate_environment_assignments(n, num_sources):
Expand Down

0 comments on commit b81220f

Please sign in to comment.