Skip to content

Conversation

@tleonhardt
Copy link
Member

@tleonhardt tleonhardt commented Aug 12, 2018

Added special handling to generate_table() for the following data types:

  • pandas DataFrame
  • numpy record arrays
  • dictionaries of iterables

Also:

  • Added data_types.py example
  • Updated README.md
  • Added unit tests for supported data types

This closes #23
This closes #24

Also:
- Added data_types.py example

TODO:
- Updated README.md
- Add unit tests
They are now dealt within in the same way as the tabulate package which assumes the keys are column labels and the values are iterables containing the column values.
Also:
- Updated README.md to briefly mention supported data types
- Updated tox.ini to install numpy and pandas for testing supported data types
Prior to 3.6 dictionaries are not ordered by default
@tleonhardt tleonhardt added the enhancement New feature or request label Aug 12, 2018
@tleonhardt tleonhardt added this to the 0.1.3 milestone Aug 12, 2018
@tleonhardt tleonhardt self-assigned this Aug 12, 2018
@tleonhardt tleonhardt requested a review from anselor August 12, 2018 04:08
@codecov-io
Copy link

codecov-io commented Aug 12, 2018

Codecov Report

Merging #25 into master will increase coverage by 0.28%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #25      +/-   ##
==========================================
+ Coverage   88.05%   88.33%   +0.28%     
==========================================
  Files           1        1              
  Lines         829      849      +20     
==========================================
+ Hits          730      750      +20     
  Misses         99       99
Impacted Files Coverage Δ
tableformatter.py 88.33% <100%> (+0.28%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b2c9d8...41bb4da. Read the comment docs.

…are installed

Also:
- numpy and pandas no longer installed by tox on Python 3.4 (installed for all other Python versions)
    - This is to fix a crazy slow install time on Python 3.4 and to also hopefully to increase code coverage
@tleonhardt
Copy link
Member Author

@anselor
I improved how tableformatter handles a couple common tabular data types, namely:

  • Pandas DataFrames
  • dictionaries of iterables
    These data types are now handled in a manner which should likely match the expectation of a reasonable user and is essentially identical to how tabulate handles them.

I also improved how Numpy record arrays are handled, though I believe I slightly deviated from how tabulate handles them - I did what seemed to make sense, but I have never used this data type, so I don't have a great feel for it.

The one outstanding question in my mind is should we modify how we handle iterables of dictionaries to be identical to how tabulate handles them or leave them the way we handle them now. I think this is an awkward data type regardless, but the way tabulate handles it probably makes the most sense. What do you think?

@tleonhardt
Copy link
Member Author

@anselor If you don't have any feedback I'll merge this in sometime this weekend

@tleonhardt
Copy link
Member Author

It may not be the perfect solution, but it is definitely an improvement and a step in the right direction, so I am going to merge it in. We can improve it further as we best see fit.

@tleonhardt tleonhardt merged commit 33a6f5e into master Aug 18, 2018
@tleonhardt tleonhardt deleted the data_types branch August 18, 2018 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make tableformatter work with Pandas DataFrames Test and document how tableformatter works with common datatypes

3 participants