Closed christian-geier closed 6 years ago
Hm - any chance that you are not calling it correctly? You're not supposed to call TableOne.to_csv()
, but rather create a tableone object with t1 = TableOne(data)
, then call t1.to_csv(filename)
to output it to file.
Apologies for the confusion, yes I am calling the method on the object.
My code:
mytable = TableOne(
tropomyosin_df_uncitr_tertiles,
cols, cat_vars_table, 'uncitrullinated_tertile', cols, pval=True
)
mytable.to_csv('uncitrullinated_tertile.csv')
Throws:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-13-eb2346152f1c> in <module>()
----> 1 mytable.to_csv('uncitrullinated_tertile.csv')
AttributeError: 'TableOne' object has no attribute 'to_csv'
Weird! What version of TableOne do you have? If you update do you get the same issue?
@col-slade it sounds like you are using an older version of the package. In the version that you are using, you would call to_csv()
with mytable.tableone.to_csv()
.
You can check the version with:
import tableone
print(tableone.__version__)
Currently we are on version 0.5.4.
Thanks, I had version 0.5.1 installed, running pip install tableone --upgrade installed version 0.5.5 which resolved the issue !
I am trying to have TableOne output the table in an easy to parse format so it can be included in a doc document.
When I call the to_csv method on the TableOne, it throws the error "TableOne object has no attribute 'to_csv'
The package has an example of using to_csv(), I assume it was removed in a prior update / rewrite ?
In that case, what is the recommended method of getting the output in a table format that can be used in ideally LibreOffice ?