Skip to content

Commit

Permalink
support pandas 0.22 #73
Browse files Browse the repository at this point in the history
  • Loading branch information
tompollard committed Nov 8, 2018
1 parent f65eadc commit de0f03f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -17,7 +17,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.5.14',
version='0.5.15',

description='TableOne',
long_description=long_description,
Expand Down
16 changes: 13 additions & 3 deletions tableone.py
Expand Up @@ -5,7 +5,7 @@
"""

__author__ = "Tom Pollard <tpollard@mit.edu>, Alistair Johnson"
__version__ = "0.5.14"
__version__ = "0.5.15"

import pandas as pd
from scipy import stats
Expand Down Expand Up @@ -656,7 +656,12 @@ def _create_tableone(self,data):
The complete table one.
"""
if self._continuous and self._categorical:
table = pd.concat([self.cont_table,self.cat_table],sort=False)

# support pandas<=0.22
try:
table = pd.concat([self.cont_table,self.cat_table],sort=False)
except:
table = pd.concat([self.cont_table,self.cat_table])
elif self._continuous:
table = self.cont_table
elif self._categorical:
Expand Down Expand Up @@ -699,7 +704,12 @@ def _create_tableone(self,data):
n_row = pd.DataFrame(columns = ['variable','level','isnull'])
n_row.set_index(['variable','level'], inplace=True)
n_row.loc['n', ''] = None
table = pd.concat([n_row,table],sort=False)

# support pandas<=0.22
try:
table = pd.concat([n_row,table],sort=False)
except:
table = pd.concat([n_row,table])

if self._groupbylvls == ['overall']:
table.loc['n','overall'] = len(data.index)
Expand Down

0 comments on commit de0f03f

Please sign in to comment.