tompollard / tableone

Create "Table 1" for research papers in Python
https://pypi.python.org/pypi/tableone/
MIT License
161 stars 38 forks source link

TypeError: concat() got an unexpected keyword argument 'sort' #72

Closed anandithaaa closed 5 years ago

anandithaaa commented 5 years ago

The above error occurs when trying to create a table, I think it may have something to with a pandas update that no longer requires the sort keyword.


TypeError Traceback (most recent call last)

in () 3 4 ----> 5 myTable = TableOne(final) ~/anaconda3/lib/python3.6/site-packages/tableone.py in __init__(self, data, columns, categorical, groupby, nonnormal, pval, pval_adjust, isnull, ddof, labels, sort, limit, remarks, label_suffix) 163 164 # combine continuous variables and categorical variables into table 1 --> 165 self.tableone = self._create_tableone(data) 166 # self._remarks_str = self._generate_remark_str() 167 ~/anaconda3/lib/python3.6/site-packages/tableone.py in _create_tableone(self, data) 700 n_row.set_index(['variable','level'], inplace=True) 701 n_row.loc['n', ''] = None --> 702 table = pd.concat([n_row,table],sort=False) 703 704 if self._groupbylvls == ['overall']: TypeError: concat() got an unexpected keyword argument 'sort'
tompollard commented 5 years ago

Thanks for reporting this! Please could you let me know what version of pandas you are running?

import pandas
print(pandas.__version__)
anandithaaa commented 5 years ago

0.23.4! :)

tompollard commented 5 years ago

I'm able to run the the demo notebook (https://github.com/tompollard/tableone/blob/master/tableone.ipynb) using Pandas 0.23.4 without error, so I think something else is going on here. Please could you add code to reproduce the error, perhaps using the sample dataset from the notebook?:

from tableone import TableOne
import pandas as pd

# load sample data into a pandas dataframe
url="https://raw.githubusercontent.com/tompollard/tableone/master/data/pn2012_demo.csv"
data=pd.read_csv(url)

# next steps here
anandithaaa commented 5 years ago

Here you are:

screen shot 2018-10-08 at 1 00 06 pm

tompollard commented 5 years ago

Thanks. Please could copy and paste the output of pandas.show_versions()?

jraffa commented 5 years ago

Would be a good idea to start from a clean notebook too.

-- Jesse Raffa

On October 8, 2018 at 13:09:09, Tom Pollard (notifications@github.commailto:notifications@github.com) wrote:

Thanks. Please could copy and paste the output of pandas.show_versions()?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/tompollard/tableone/issues/72#issuecomment-427910582, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIO5sUSAtDoJBGDogtVtuOJfBu7pok7qks5ui4a1gaJpZM4XNE_u.

anandithaaa commented 5 years ago

Ahh restarting the kernel fixed the problem! Thank you, sorry for the trouble.

It's rather odd though.. I've only been working for a few hours today and I reproduced the error 4 or 5 times, the first time being really early on in the session.