Comments (2)
The issue with long numbers being truncated when exported to Excel from Superset is due to Excel's limitation of handling a maximum precision of 15 digits for numbers. This results in numbers longer than 15 digits being truncated or rounded. To prevent this, you can modify the df_to_excel
function in Superset to convert long numbers to strings before exporting. This approach ensures that Excel treats these numbers as text, avoiding truncation or scientific notation conversion.
Here's a modification you can apply:
import io
from typing import Any
import pandas as pd
def df_to_excel(df: pd.DataFrame, **kwargs: Any) -> Any:
output = io.BytesIO()
# Convert long numbers to strings to avoid truncation
for column in df.columns:
if df[column].dtype == 'int64': # Check if the column is of int64 type
df[column] = df[column].astype(str)
# Handle timezones
for column in df.select_dtypes(include=["datetimetz"]).columns:
df[column] = df[column].astype(str)
with pd.ExcelWriter(output, engine="xlsxwriter") as writer:
df.to_excel(writer, **kwargs)
return output.getvalue()
This code checks each column's data type and converts int64
columns to strings, ensuring that long numbers are accurately represented in the exported Excel file. Keep in mind, converting numbers to strings might not be ideal if you plan to perform numeric operations on these values in Excel, as they will be treated as text.
Details
Sources
- superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx
- superset/utils/excel.py
- superset/commands/sql_lab/export.py
- superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/controlPanel.ts
- superset-frontend/src/setup/setupFormatters.ts
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a ๐ if this is helpful and ๐ if it is irrelevant.
To continue the conversation, mention @dosu.
from superset.
@jose-vines-toteat let us know if you want to open a PR to solve the problem. We'd love to get feedback on Dosu's suggestions here, since if it leads to a fix, that's pretty amazing.
from superset.
Related Issues (20)
- **[100% Working]*{NEW-METHOD)!^Amazon Gift Card Codes Generator [20% off]
- **[100% Working],,[100% Working] Free Amazon Gift Card Codes Generator 2024
- **{Latest Update in[New Method] Free Amazon Gift Card Codes Generator 2024#Available USA
- **[100% Working],,[100% Working] Free Amazon Gift Card Codes Generator 2024$$Available IN CANADA,,
- ++(โfREE fORTNITE v-bUCKS cODES gENERATOR 2024 fREE vBUCKS cODES)
- ^^[FREE]^Updated 2024 Free V Bucks Generator Links: A Curated List
- ~+(Guaranteed Wins!) Fortnite V Bucks Generator 2024 Free VBucks Codes Daily Updated Link 100%-WORKING [ gjm]
- **[LATEST UPDATE]~Are There Any Fortnite V Bucks Codes Gift Cards Available in May 2024?
- ~@~FREE!! Fortnite V Bucks Generator updated Get Free Psn code (May 2024)
- ~**(100% Working) Free Fortnite V Bucks Generator 2024$Available For USA
- **(GET Working) Fortnite V Bucks Code Generator Free Fortnite V Bucks Hack 2024$$Available IN CANADA,,
- **[100% Working],,[100% Working] Free(New Method) Free Fortnite V Bucks Generator 2024$$Available IN CANADA,,
- **(Free Access) Get Free Fortnite V Bucks Generator 2024 No Survey Without Any Verification
- Xbox Free Gift Card Codes 2024 โ๏ธFree Xbox Gift Card Codes โ๏ธ Free Xbox Gift Cards
- %[@[FReE!!]@]โXbox Gift Card Codes 2024 ๐ฎ Up to $100 in Free Xbox Codes in UNDER 5 minutes!
- ~!~750$ free cash app money generator 2024
- ~Daily'S.FrEe*~ Cash App Money Generator 2024โ GET Updated $750 Cash App Money Code
- ~@~[GET 10K-200K] Free TikTok Follower Generator 2024-2025
- ~@~๊ฅThe Ultimate Guide to Getting Free TikTok Followers in 2024! [ u2Gq]
- **[100% Working],,(Free Access) Get Free Fortnite V Bucks Generator 2024 No Survey Without Any Verification$$Available in USA
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 superset.