Skip to content

Commit

Permalink
handle object type
Browse files Browse the repository at this point in the history
  • Loading branch information
tompollard committed Jan 18, 2018
1 parent a3fa260 commit d02b48d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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.3.2',
version='0.3.3',

description='TableOne',
long_description=long_description,
Expand Down
11 changes: 6 additions & 5 deletions tableone.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

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

import pandas as pd
import csv
Expand Down Expand Up @@ -79,9 +79,7 @@ def __init__(self, data, columns='autodetect', categorical='autodetect',
# create tables of continuous and categorical variables
if self.continuous:
self._cont_describe = self._create_cont_describe(data)
# self._cont_describe_NEW = self._create_cont_describe_NEW(data)
self._cont_table = self._create_cont_table(data)
# self._cont_table_NEW = self._create_cont_table_NEW(data)

# combine continuous variables and categorical variables into table 1
self.tableone = self._create_tableone(data)
Expand Down Expand Up @@ -130,14 +128,17 @@ def _create_cont_describe(self,data):

if self.groupby:
cont_data = data[self.continuous + [self.groupby]]
cont_data = cont_data.apply(pd.to_numeric, errors='ignore')
df_cont = pd.pivot_table(cont_data,
columns=[self.groupby],
aggfunc=aggfuncs)
else:
# if no groupby, just add single group column
df_cont = data[self.continuous].apply(aggfuncs).T
df_cont = data[self.continuous].apply(pd.to_numeric,
errors='ignore').apply(aggfuncs).T
df_cont.columns.name = 'overall'
df_cont.columns = pd.MultiIndex.from_product([df_cont.columns, ['overall']])
df_cont.columns = pd.MultiIndex.from_product([df_cont.columns,
['overall']])

df_cont.index.rename('variable',inplace=True)

Expand Down

0 comments on commit d02b48d

Please sign in to comment.