Comments (1)
Hey @astanin, I appreciate the package, but just wanted to let you know that pandas DataFrames np.int64 numbers are still evaluated as float when there are other float columns. This is because this call to values
causes numpy to upcast all integer columns to float columns. Ideally instead of just using the values
, each cell would be considered individually.
I'm using a quick and dirty hack to get around this by reapplying the appropriate dtype to each cell afterwards here:
rows = [list([tabular_data.dtypes[tabular_data.keys()[i]].type(cell) for i, cell in enumerate(row)]) for row in vals]
This is probably unsafe in ways I don't know, but it does allow me to print the issue's primary example correctly (without this hack it still prints the output the original reported posted):
from tabulate import tabulate
import pandas as pd
df = pd.DataFrame({'A':[1,2,3,4],'B':[.20942, .092384, .019823, .01923]})
print(tabulate(df, floatfmt='.2f', headers=df.columns, tablefmt='pipe'))
| | A | B |
|---:|----:|-----:|
| 0 | 1 | 0.21 |
| 1 | 2 | 0.09 |
| 2 | 3 | 0.02 |
| 3 | 4 | 0.02 |
from python-tabulate.
Related Issues (20)
- colalign argument crashes tabulate if no data HOT 2
- stralign=None breaks table completely
- Idea/Feature Request: Allow callable for `floatfmt`. HOT 3
- Add Argument for setting PRESERVE_WHITESPACE to True or False to tabulate HOT 1
- coltype autodetection assumes "0.0" is a float and the table shows "0", instead of the string "0.0" HOT 1
- Feature Request: MarkupHeader
- No documentation found for formatting table columns, rows, and entries
- Can not tabulate row with a field that looks like a Python Bool using maxcolwidths
- Column wrapping may break ANSI escape codes HOT 2
- Support for Pydantic Models
- Placeholder for empty cells
- When using maxcolwidths in a column that contains None values, tabulate crashes with "NoneType takes no arguments" HOT 4
- [bug] Error if trying to render a table with no rows using maxcolwidths HOT 1
- The `missingval` argument doesn't recognise `np.nan` values, it only recognises `None`
- wasted horizontal space
- Bug: `intfmt` error for strings which contain integer values
- Feature: for numbers, apply the “digit grouping” for integers and floats.
- Discussion: data types of the columns
- SEPARATING_LINE does not work with "outline" formats HOT 1
- TypeError when cell is None HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-tabulate.