[{"data":1,"prerenderedAt":1695},["ShallowReactive",2],{"doc:\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-fractions-and-scientific-notation-in-excel":3,"surround:\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-fractions-and-scientific-notation-in-excel":1661,"ancestors:\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-fractions-and-scientific-notation-in-excel":1670,"children:\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-fractions-and-scientific-notation-in-excel":1675,"related:\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-fractions-and-scientific-notation-in-excel":1676},{"id":4,"title":5,"body":6,"dateModified":1628,"datePublished":1628,"description":1629,"extension":1630,"faq":1631,"keyword":1640,"kind":1641,"meta":1642,"navigation":101,"path":1651,"seo":1652,"slug":1655,"stem":1656,"topics":1657,"type":1659,"__hash__":1660},"docs\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-fractions-and-scientific-notation-in-excel\u002Findex.md","Format Fractions and Scientific Notation in Excel",{"type":7,"value":8,"toc":1617},"minimark",[9,28,33,58,65,389,393,400,635,661,672,845,859,863,1060,1074,1092,1183,1187,1197,1293,1322,1460,1464,1479,1483,1521,1525,1554,1558,1564,1570,1576,1582,1586,1613],[10,11,12,13,17,18,21,22,27],"p",{},"Most report numbers are money or counts, and ",[14,15,16],"code",{},"#,##0.00"," covers them. Two families of numbers need something else. Measurements in trades and engineering are often read as fractions — a 2⅜-inch bolt, a ⅝ drill — and showing them as 2.375 or 0.625 makes people convert in their heads. Scientific values — concentrations of 0.0000123, or Avogadro's 6.02 × 10²³ — become unreadable strings of zeros in a fixed decimal format. Excel has number formats for both, and openpyxl can apply them from Python. The same topic explains a common complaint about generated workbooks: product codes and account numbers that appear as ",[14,19,20],{},"1.23457E+11",", or that silently lose their last digits. This page covers fraction formats, scientific and engineering notation, and the General format's behaviour with long numbers, with every display checked through a LibreOffice export. It belongs to ",[23,24,26],"a",{"href":25},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002F","Applying Number and Date Formats in Excel",".",[29,30,32],"h2",{"id":31},"prerequisites","Prerequisites",[34,35,40],"pre",{"className":36,"code":37,"language":38,"meta":39,"style":39},"language-bash shiki shiki-themes github-light github-dark-high-contrast","pip install openpyxl\n","bash","",[14,41,42],{"__ignoreMap":39},[43,44,47,51,55],"span",{"class":45,"line":46},"line",1,[43,48,50],{"class":49},"sMTad","pip",[43,52,54],{"class":53},"srMev"," install",[43,56,57],{"class":53}," openpyxl\n",[10,59,60,61,64],{},"LibreOffice (",[14,62,63],{},"soffice",") recalculates the workbook and exports each cell as displayed, so formats can be checked without Excel. A small helper does that for every example:",[34,66,70],{"className":67,"code":68,"language":69,"meta":39,"style":39},"language-python shiki shiki-themes github-light github-dark-high-contrast","import csv, subprocess\nfrom openpyxl import Workbook\n\nAS_SHOWN = \"csv:Text - txt - csv (StarCalc):44,34,76,1,,0,false,true,true\"\n\ndef shown(values, formats, name=\"demo\"):\n    wb = Workbook()\n    ws = wb.active\n    for v in values:\n        ws.append([v] * len(formats))\n        for col, fmt in enumerate(formats, start=1):\n            ws.cell(ws.max_row, col).number_format = fmt\n    wb.save(f\"{name}.xlsx\")\n    subprocess.run([\"soffice\", \"--headless\", \"--convert-to\", AS_SHOWN, \"--outdir\", \"calc\", f\"{name}.xlsx\"], check=True, capture_output=True)\n    with open(f\"calc\u002F{name}.csv\", encoding=\"utf-8\") as f:\n        return list(csv.reader(f))\n","python",[14,71,72,82,96,103,116,121,143,154,165,180,195,223,234,262,332,377],{"__ignoreMap":39},[43,73,74,78],{"class":45,"line":46},[43,75,77],{"class":76},"s-kum","import",[43,79,81],{"class":80},"skGVy"," csv, subprocess\n",[43,83,85,88,91,93],{"class":45,"line":84},2,[43,86,87],{"class":76},"from",[43,89,90],{"class":80}," openpyxl ",[43,92,77],{"class":76},[43,94,95],{"class":80}," Workbook\n",[43,97,99],{"class":45,"line":98},3,[43,100,102],{"emptyLinePlaceholder":101},true,"\n",[43,104,106,110,113],{"class":45,"line":105},4,[43,107,109],{"class":108},"sP0c6","AS_SHOWN",[43,111,112],{"class":76}," =",[43,114,115],{"class":53}," \"csv:Text - txt - csv (StarCalc):44,34,76,1,,0,false,true,true\"\n",[43,117,119],{"class":45,"line":118},5,[43,120,102],{"emptyLinePlaceholder":101},[43,122,124,127,131,134,137,140],{"class":45,"line":123},6,[43,125,126],{"class":76},"def",[43,128,130],{"class":129},"s_Opv"," shown",[43,132,133],{"class":80},"(values, formats, name",[43,135,136],{"class":76},"=",[43,138,139],{"class":53},"\"demo\"",[43,141,142],{"class":80},"):\n",[43,144,146,149,151],{"class":45,"line":145},7,[43,147,148],{"class":80},"    wb ",[43,150,136],{"class":76},[43,152,153],{"class":80}," Workbook()\n",[43,155,157,160,162],{"class":45,"line":156},8,[43,158,159],{"class":80},"    ws ",[43,161,136],{"class":76},[43,163,164],{"class":80}," wb.active\n",[43,166,168,171,174,177],{"class":45,"line":167},9,[43,169,170],{"class":76},"    for",[43,172,173],{"class":80}," v ",[43,175,176],{"class":76},"in",[43,178,179],{"class":80}," values:\n",[43,181,183,186,189,192],{"class":45,"line":182},10,[43,184,185],{"class":80},"        ws.append([v] ",[43,187,188],{"class":76},"*",[43,190,191],{"class":108}," len",[43,193,194],{"class":80},"(formats))\n",[43,196,198,201,204,206,209,212,216,218,221],{"class":45,"line":197},11,[43,199,200],{"class":76},"        for",[43,202,203],{"class":80}," col, fmt ",[43,205,176],{"class":76},[43,207,208],{"class":108}," enumerate",[43,210,211],{"class":80},"(formats, ",[43,213,215],{"class":214},"sa561","start",[43,217,136],{"class":76},[43,219,220],{"class":108},"1",[43,222,142],{"class":80},[43,224,226,229,231],{"class":45,"line":225},12,[43,227,228],{"class":80},"            ws.cell(ws.max_row, col).number_format ",[43,230,136],{"class":76},[43,232,233],{"class":80}," fmt\n",[43,235,237,240,243,246,250,253,256,259],{"class":45,"line":236},13,[43,238,239],{"class":80},"    wb.save(",[43,241,242],{"class":76},"f",[43,244,245],{"class":53},"\"",[43,247,249],{"class":248},"sSjpA","{",[43,251,252],{"class":80},"name",[43,254,255],{"class":248},"}",[43,257,258],{"class":53},".xlsx\"",[43,260,261],{"class":80},")\n",[43,263,265,268,271,274,277,279,282,284,286,288,291,293,296,298,300,302,304,306,308,310,313,316,318,321,323,326,328,330],{"class":45,"line":264},14,[43,266,267],{"class":80},"    subprocess.run([",[43,269,270],{"class":53},"\"soffice\"",[43,272,273],{"class":80},", ",[43,275,276],{"class":53},"\"--headless\"",[43,278,273],{"class":80},[43,280,281],{"class":53},"\"--convert-to\"",[43,283,273],{"class":80},[43,285,109],{"class":108},[43,287,273],{"class":80},[43,289,290],{"class":53},"\"--outdir\"",[43,292,273],{"class":80},[43,294,295],{"class":53},"\"calc\"",[43,297,273],{"class":80},[43,299,242],{"class":76},[43,301,245],{"class":53},[43,303,249],{"class":248},[43,305,252],{"class":80},[43,307,255],{"class":248},[43,309,258],{"class":53},[43,311,312],{"class":80},"], ",[43,314,315],{"class":214},"check",[43,317,136],{"class":76},[43,319,320],{"class":108},"True",[43,322,273],{"class":80},[43,324,325],{"class":214},"capture_output",[43,327,136],{"class":76},[43,329,320],{"class":108},[43,331,261],{"class":80},[43,333,335,338,341,344,346,349,351,353,355,358,360,363,365,368,371,374],{"class":45,"line":334},15,[43,336,337],{"class":76},"    with",[43,339,340],{"class":108}," open",[43,342,343],{"class":80},"(",[43,345,242],{"class":76},[43,347,348],{"class":53},"\"calc\u002F",[43,350,249],{"class":248},[43,352,252],{"class":80},[43,354,255],{"class":248},[43,356,357],{"class":53},".csv\"",[43,359,273],{"class":80},[43,361,362],{"class":214},"encoding",[43,364,136],{"class":76},[43,366,367],{"class":53},"\"utf-8\"",[43,369,370],{"class":80},") ",[43,372,373],{"class":76},"as",[43,375,376],{"class":80}," f:\n",[43,378,380,383,386],{"class":45,"line":379},16,[43,381,382],{"class":76},"        return",[43,384,385],{"class":108}," list",[43,387,388],{"class":80},"(csv.reader(f))\n",[29,390,392],{"id":391},"step-1-fractions","Step 1 — Fractions",[10,394,395,396,399],{},"A fraction format has an optional whole-number part, then a numerator and denominator made of ",[14,397,398],{},"?"," placeholders or a fixed number:",[34,401,403],{"className":67,"code":402,"language":69,"meta":39,"style":39},"FRACTIONS = [\"# ?\u002F?\", \"# ??\u002F??\", \"# ???\u002F???\", \"# ?\u002F8\", \"# ?\u002F16\", \"?\u002F?\"]\nvalues = [0.5, 2.375, 0.3333333333, 3.14159265, 0.625, 1.1]\nrows = shown(values, FRACTIONS, \"fractions\")\nprint(f\"{'value':>12}  \" + \"  \".join(f\"{f:>10}\" for f in FRACTIONS))\nfor v, row in zip(values, rows):\n    print(f\"{v:>12}  \" + \"  \".join(f\"{c.strip():>10}\" for c in row))\n",[14,404,405,446,485,504,566,582],{"__ignoreMap":39},[43,406,407,410,412,415,418,420,423,425,428,430,433,435,438,440,443],{"class":45,"line":46},[43,408,409],{"class":108},"FRACTIONS",[43,411,112],{"class":76},[43,413,414],{"class":80}," [",[43,416,417],{"class":53},"\"# ?\u002F?\"",[43,419,273],{"class":80},[43,421,422],{"class":53},"\"# ??\u002F??\"",[43,424,273],{"class":80},[43,426,427],{"class":53},"\"# ???\u002F???\"",[43,429,273],{"class":80},[43,431,432],{"class":53},"\"# ?\u002F8\"",[43,434,273],{"class":80},[43,436,437],{"class":53},"\"# ?\u002F16\"",[43,439,273],{"class":80},[43,441,442],{"class":53},"\"?\u002F?\"",[43,444,445],{"class":80},"]\n",[43,447,448,451,453,455,458,460,463,465,468,470,473,475,478,480,483],{"class":45,"line":84},[43,449,450],{"class":80},"values ",[43,452,136],{"class":76},[43,454,414],{"class":80},[43,456,457],{"class":108},"0.5",[43,459,273],{"class":80},[43,461,462],{"class":108},"2.375",[43,464,273],{"class":80},[43,466,467],{"class":108},"0.3333333333",[43,469,273],{"class":80},[43,471,472],{"class":108},"3.14159265",[43,474,273],{"class":80},[43,476,477],{"class":108},"0.625",[43,479,273],{"class":80},[43,481,482],{"class":108},"1.1",[43,484,445],{"class":80},[43,486,487,490,492,495,497,499,502],{"class":45,"line":98},[43,488,489],{"class":80},"rows ",[43,491,136],{"class":76},[43,493,494],{"class":80}," shown(values, ",[43,496,409],{"class":108},[43,498,273],{"class":80},[43,500,501],{"class":53},"\"fractions\"",[43,503,261],{"class":80},[43,505,506,509,511,513,515,517,520,523,525,528,531,534,537,539,541,543,545,548,550,552,555,558,560,563],{"class":45,"line":105},[43,507,508],{"class":108},"print",[43,510,343],{"class":80},[43,512,242],{"class":76},[43,514,245],{"class":53},[43,516,249],{"class":248},[43,518,519],{"class":53},"'value'",[43,521,522],{"class":76},":>12",[43,524,255],{"class":248},[43,526,527],{"class":53},"  \"",[43,529,530],{"class":76}," +",[43,532,533],{"class":53}," \"  \"",[43,535,536],{"class":80},".join(",[43,538,242],{"class":76},[43,540,245],{"class":53},[43,542,249],{"class":248},[43,544,242],{"class":80},[43,546,547],{"class":76},":>10",[43,549,255],{"class":248},[43,551,245],{"class":53},[43,553,554],{"class":76}," for",[43,556,557],{"class":80}," f ",[43,559,176],{"class":76},[43,561,562],{"class":108}," FRACTIONS",[43,564,565],{"class":80},"))\n",[43,567,568,571,574,576,579],{"class":45,"line":118},[43,569,570],{"class":76},"for",[43,572,573],{"class":80}," v, row ",[43,575,176],{"class":76},[43,577,578],{"class":108}," zip",[43,580,581],{"class":80},"(values, rows):\n",[43,583,584,587,589,591,593,595,598,600,602,604,606,608,610,612,614,616,619,621,623,625,627,630,632],{"class":45,"line":123},[43,585,586],{"class":108},"    print",[43,588,343],{"class":80},[43,590,242],{"class":76},[43,592,245],{"class":53},[43,594,249],{"class":248},[43,596,597],{"class":80},"v",[43,599,522],{"class":76},[43,601,255],{"class":248},[43,603,527],{"class":53},[43,605,530],{"class":76},[43,607,533],{"class":53},[43,609,536],{"class":80},[43,611,242],{"class":76},[43,613,245],{"class":53},[43,615,249],{"class":248},[43,617,618],{"class":80},"c.strip()",[43,620,547],{"class":76},[43,622,255],{"class":248},[43,624,245],{"class":53},[43,626,554],{"class":76},[43,628,629],{"class":80}," c ",[43,631,176],{"class":76},[43,633,634],{"class":80}," row))\n",[10,636,637,640,641,645,646,649,650,653,654,657,658,660],{},[14,638,639],{},"# ?\u002F?"," shows the whole number and the closest fraction with a one-digit denominator: 2.375 is exactly 2 3\u002F8, and π comes out as 3 1\u002F7. More question marks allow larger denominators and closer approximations — π is 3 14\u002F99 with up to two digits and 3 16\u002F113 — the classic 355\u002F113 — with up to three, accurate to six decimal places. A ",[642,643,644],"em",{},"fixed"," denominator such as ",[14,647,648],{},"# ?\u002F8"," or ",[14,651,652],{},"# ?\u002F16"," rounds to the nearest eighth or sixteenth and does not reduce: 0.625 shows as 10\u002F16, not 5\u002F8, which is exactly what a workshop drawing in sixteenths wants. Leaving out the ",[14,655,656],{},"#"," gives improper fractions: 2.375 becomes 19\u002F8. Whatever is displayed, the cell still holds the exact decimal, so totals are unaffected by the approximation. That cuts both ways: 1.1 shows as 1 1\u002F9 under ",[14,659,639],{},", because 1\u002F10 needs a two-digit denominator and 1\u002F9 is the closest one-digit fraction, so a reader adding up displayed fractions by hand can get a different total from Excel. Choose the denominator size from how precisely the values are known — sixteenths for imperial lengths, two digits for most ratios — rather than defaulting to one digit.",[10,662,663,664,667,668,671],{},"There is also an input-side trap. Typing ",[14,665,666],{},"1\u002F2"," into a General cell in Excel enters the date 1 February (or 2 January, by locale), not a half; people enter fractions as ",[14,669,670],{},"0 1\u002F2"," to avoid it. Workbooks generated from Python do not have that problem, because the code writes the number 0.5 and the format does the rest — but if the workbook is a template people type into, pre-format the input cells with the fraction format so typed fractions are read as numbers.",[673,674,682,683,682,687,682,691,682,699,682,707,682,714,682,720,682,723,682,727,682,730,682,733,682,738,682,743,682,745,682,750,682,752,682,755,682,757,682,760,682,763,682,767,682,769,682,772,682,774,682,777,682,779,682,781,682,784,682,788,682,790,682,793,682,795,682,798,682,800,682,802,682,805,682,808,682,810,682,814,682,816,682,819,682,821,682,824,682,827,682,830,682,832,682,836,682,838,682,841,682,843],"svg",{"viewBox":675,"role":676,"ariaLabelledBy":677,"xmlns":680,"style":681},"4 0 752 242","img",[678,679],"fr-fractions-t","fr-fractions-d","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","width:100%;max-width:752px;height:auto;display:block;margin:1.5rem auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif","\n  ",[684,685,686],"title",{"id":678},"Fraction formats and what they show",[688,689,690],"desc",{"id":679},"Up to one digit shows 2.375 as 2 3\u002F8 and pi as 3 1\u002F7. Up to two digits shows pi as 3 14\u002F99 and up to three digits as 3 16\u002F113. A fixed denominator of 16 shows 0.625 as 10\u002F16 without reducing. Without a whole-number part 2.375 becomes 19\u002F8.",[692,693],"rect",{"x":694,"y":695,"width":696,"height":697,"fill":698},"4","0","752","242","#ffffff",[692,700],{"x":701,"y":702,"width":703,"height":704,"rx":695,"fill":698,"stroke":705,"style":706},"20.0","16.0","88.8","40.0","var(--line,#cdd5e6)","stroke-width:1px",[692,708],{"x":709,"y":702,"width":710,"height":704,"rx":695,"fill":711,"stroke":712,"style":713},"108.8","210.4","#f0f4ff","var(--brand,#5b5cf0)","stroke-width:1.2px",[715,716,462],"text",{"x":717,"y":718,"style":719},"214.0","41.0","font-size:13px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle",[692,721],{"x":722,"y":702,"width":710,"height":704,"rx":695,"fill":711,"stroke":712,"style":713},"319.2",[715,724,726],{"x":725,"y":718,"style":719},"424.4","3.14159",[692,728],{"x":729,"y":702,"width":710,"height":704,"rx":695,"fill":711,"stroke":712,"style":713},"529.6",[715,731,477],{"x":732,"y":718,"style":719},"634.8",[692,734],{"x":701,"y":735,"width":703,"height":736,"rx":695,"fill":737,"stroke":705,"style":706},"56.0","34.0","#e7ebef",[715,739,639],{"x":740,"y":741,"style":742},"32.0","78.0","font-size:12.5px;font-weight:700;fill:var(--text,#172033);text-anchor:start",[692,744],{"x":709,"y":735,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,746,749],{"x":717,"y":747,"style":748},"77.0","font-size:11.5px;font-weight:400;fill:var(--text,#172033);text-anchor:middle","2 3\u002F8",[692,751],{"x":722,"y":735,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,753,754],{"x":725,"y":747,"style":748},"3 1\u002F7",[692,756],{"x":729,"y":735,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,758,759],{"x":732,"y":747,"style":748},"5\u002F8",[692,761],{"x":701,"y":762,"width":703,"height":736,"rx":695,"fill":737,"stroke":705,"style":706},"90.0",[715,764,766],{"x":740,"y":765,"style":742},"112.0","# ??\u002F??",[692,768],{"x":709,"y":762,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,770,749],{"x":717,"y":771,"style":748},"111.0",[692,773],{"x":722,"y":762,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,775,776],{"x":725,"y":771,"style":748},"3 14\u002F99",[692,778],{"x":729,"y":762,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,780,759],{"x":732,"y":771,"style":748},[692,782],{"x":701,"y":783,"width":703,"height":736,"rx":695,"fill":737,"stroke":705,"style":706},"124.0",[715,785,787],{"x":740,"y":786,"style":742},"146.0","# ???\u002F???",[692,789],{"x":709,"y":783,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,791,749],{"x":717,"y":792,"style":748},"145.0",[692,794],{"x":722,"y":783,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,796,797],{"x":725,"y":792,"style":748},"3 16\u002F113",[692,799],{"x":729,"y":783,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,801,759],{"x":732,"y":792,"style":748},[692,803],{"x":701,"y":804,"width":703,"height":736,"rx":695,"fill":737,"stroke":705,"style":706},"158.0",[715,806,652],{"x":740,"y":807,"style":742},"180.0",[692,809],{"x":709,"y":804,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,811,813],{"x":717,"y":812,"style":748},"179.0","2 6\u002F16",[692,815],{"x":722,"y":804,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,817,818],{"x":725,"y":812,"style":748},"3 2\u002F16",[692,820],{"x":729,"y":804,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,822,823],{"x":732,"y":812,"style":748},"10\u002F16",[692,825],{"x":701,"y":826,"width":703,"height":736,"rx":695,"fill":737,"stroke":705,"style":706},"192.0",[715,828,829],{"x":740,"y":717,"style":742},"?\u002F?",[692,831],{"x":709,"y":826,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,833,835],{"x":717,"y":834,"style":748},"213.0","19\u002F8",[692,837],{"x":722,"y":826,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,839,840],{"x":725,"y":834,"style":748},"22\u002F7",[692,842],{"x":729,"y":826,"width":710,"height":736,"rx":695,"fill":698,"stroke":705,"style":706},[715,844,759],{"x":732,"y":834,"style":748},[10,846,847,848,850,851,854,855,27],{},"Fractions read awkwardly in proportional fonts because the numerators and denominators do not line up; the ",[14,849,398],{}," placeholders pad with spaces to help, which works best in a column with a fixed-width font or right alignment. Adding a unit as a literal — ",[14,852,853],{},"# ?\u002F16\""," for inches — keeps the number numeric while showing the unit, as covered for other units in ",[23,856,858],{"href":857},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fwrite-custom-number-format-codes-in-excel-with-python\u002F","Write Custom Number Format Codes in Excel with Python",[29,860,862],{"id":861},"step-2-scientific-and-engineering-notation","Step 2 — Scientific and engineering notation",[34,864,866],{"className":67,"code":865,"language":69,"meta":39,"style":39},"SCI = [\"0.00E+00\", \"0.0E+0\", \"##0.0E+0\", \"0.000000\"]\nvalues = [0.000012345, 0.0042, 6.02214076e23, 1500, 123456789]\nrows = shown(values, SCI, \"scientific\")\nprint(f\"{'value':>14}  \" + \"  \".join(f\"{f:>10}\" for f in SCI))\nfor v, row in zip(values, rows):\n    print(f\"{v:>14}  \" + \"  \".join(f\"{c:>10}\" for c in row))\n",[14,867,868,897,930,947,999,1011],{"__ignoreMap":39},[43,869,870,873,875,877,880,882,885,887,890,892,895],{"class":45,"line":46},[43,871,872],{"class":108},"SCI",[43,874,112],{"class":76},[43,876,414],{"class":80},[43,878,879],{"class":53},"\"0.00E+00\"",[43,881,273],{"class":80},[43,883,884],{"class":53},"\"0.0E+0\"",[43,886,273],{"class":80},[43,888,889],{"class":53},"\"##0.0E+0\"",[43,891,273],{"class":80},[43,893,894],{"class":53},"\"0.000000\"",[43,896,445],{"class":80},[43,898,899,901,903,905,908,910,913,915,918,920,923,925,928],{"class":45,"line":84},[43,900,450],{"class":80},[43,902,136],{"class":76},[43,904,414],{"class":80},[43,906,907],{"class":108},"0.000012345",[43,909,273],{"class":80},[43,911,912],{"class":108},"0.0042",[43,914,273],{"class":80},[43,916,917],{"class":108},"6.02214076e23",[43,919,273],{"class":80},[43,921,922],{"class":108},"1500",[43,924,273],{"class":80},[43,926,927],{"class":108},"123456789",[43,929,445],{"class":80},[43,931,932,934,936,938,940,942,945],{"class":45,"line":98},[43,933,489],{"class":80},[43,935,136],{"class":76},[43,937,494],{"class":80},[43,939,872],{"class":108},[43,941,273],{"class":80},[43,943,944],{"class":53},"\"scientific\"",[43,946,261],{"class":80},[43,948,949,951,953,955,957,959,961,964,966,968,970,972,974,976,978,980,982,984,986,988,990,992,994,997],{"class":45,"line":105},[43,950,508],{"class":108},[43,952,343],{"class":80},[43,954,242],{"class":76},[43,956,245],{"class":53},[43,958,249],{"class":248},[43,960,519],{"class":53},[43,962,963],{"class":76},":>14",[43,965,255],{"class":248},[43,967,527],{"class":53},[43,969,530],{"class":76},[43,971,533],{"class":53},[43,973,536],{"class":80},[43,975,242],{"class":76},[43,977,245],{"class":53},[43,979,249],{"class":248},[43,981,242],{"class":80},[43,983,547],{"class":76},[43,985,255],{"class":248},[43,987,245],{"class":53},[43,989,554],{"class":76},[43,991,557],{"class":80},[43,993,176],{"class":76},[43,995,996],{"class":108}," SCI",[43,998,565],{"class":80},[43,1000,1001,1003,1005,1007,1009],{"class":45,"line":118},[43,1002,570],{"class":76},[43,1004,573],{"class":80},[43,1006,176],{"class":76},[43,1008,578],{"class":108},[43,1010,581],{"class":80},[43,1012,1013,1015,1017,1019,1021,1023,1025,1027,1029,1031,1033,1035,1037,1039,1041,1043,1046,1048,1050,1052,1054,1056,1058],{"class":45,"line":123},[43,1014,586],{"class":108},[43,1016,343],{"class":80},[43,1018,242],{"class":76},[43,1020,245],{"class":53},[43,1022,249],{"class":248},[43,1024,597],{"class":80},[43,1026,963],{"class":76},[43,1028,255],{"class":248},[43,1030,527],{"class":53},[43,1032,530],{"class":76},[43,1034,533],{"class":53},[43,1036,536],{"class":80},[43,1038,242],{"class":76},[43,1040,245],{"class":53},[43,1042,249],{"class":248},[43,1044,1045],{"class":80},"c",[43,1047,547],{"class":76},[43,1049,255],{"class":248},[43,1051,245],{"class":53},[43,1053,554],{"class":76},[43,1055,629],{"class":80},[43,1057,176],{"class":76},[43,1059,634],{"class":80},[10,1061,1062,1065,1066,1069,1070,1073],{},[14,1063,1064],{},"0.00E+00"," is standard scientific notation with three significant figures and a two-digit exponent: 0.000012345 shows as 1.23E-05. Putting ",[14,1067,1068],{},"##0"," before the decimal point turns it into ",[642,1071,1072],{},"engineering"," notation, where the exponent is always a multiple of three, matching the metric prefixes: 12.3E-6 (micro), 4.2E-3 (milli), 602.2E+21. Engineers reading values in µA or kΩ find that much quicker to interpret. A fixed decimal format, by contrast, shows 0.000012 — losing precision — and turns 6.02 × 10²³ into a 24-digit string followed by six meaningless zeros.",[10,1075,1076,1077,1080,1081,1083,1084,1087,1088,27],{},"The number of digits after the decimal point in the format sets the precision shown, not the precision stored. ",[14,1078,1079],{},"0.0E+0"," shows 1500 as 1.5E+3 and 123,456,789 as 1.2E+8; the second is a loss of information a reader cannot see. Pick enough digits for the precision the measurement actually has — three significant figures (",[14,1082,1064],{},") is a common default for laboratory results — and keep the full value in the cell for anyone who needs it. pandas has a parallel choice when writing: ",[14,1085,1086],{},"float_format"," rounds the stored values, while a number format only changes the display, as compared in ",[23,1089,1091],{"href":1090},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fround-numbers-for-excel-output-float-format-vs-number-formats\u002F","Round Numbers for Excel Output: float_format vs Number Formats",[673,1093,682,1098,682,1101,682,1104,682,1107,682,1113,682,1124,682,1129,682,1134,682,1138,682,1142,682,1146,682,1150,682,1155,682,1162,682,1167,682,1171,682,1174,682,1177,682,1180],{"viewBox":1094,"role":676,"ariaLabelledBy":1095,"xmlns":680,"style":681},"4 0 752 233",[1096,1097],"fr-sci-t","fr-sci-d",[684,1099,1100],{"id":1096},"Scientific or engineering notation",[688,1102,1103],{"id":1097},"Scientific notation shows one digit before the decimal point and any exponent, such as 1.23E-05. Engineering notation uses exponents in multiples of three, matching metric prefixes, such as 12.3E-6 for micro.",[692,1105],{"x":694,"y":695,"width":696,"height":1106,"fill":698},"233",[692,1108],{"x":701,"y":702,"width":1109,"height":1110,"rx":1111,"fill":711,"stroke":712,"style":1112},"351.0","201.0","14","stroke-width:2px",[1114,1115,1117],"g",{"transform":1116},"translate(182.5,29.0) scale(1.083)",[1118,1119],"path",{"d":1120,"fill":1121,"stroke":1122,"style":1123},"M9 3h6 M10 3v6l-5 9a2 2 0 0 0 1.8 3h10.4a2 2 0 0 0 1.8-3l-5-9V3","none","var(--brand-strong,#4338ca)","stroke-width:1.66px;stroke-linecap:round;stroke-linejoin:round",[715,1125,1128],{"x":1126,"y":741,"style":1127},"195.5","font-size:14px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","Scientific 0.00E+00",[45,1130],{"x1":1131,"y1":1132,"x2":1133,"y2":1132,"stroke":712,"style":706},"36.0","91.0","355.0",[715,1135,1137],{"x":1126,"y":771,"style":1136},"font-size:12px;font-weight:400;fill:var(--text,#172033);text-anchor:middle","0.000012345 → 1.23E-05",[715,1139,1141],{"x":1126,"y":1140,"style":1136},"137.0","6.02×10²³ → 6.02E+23",[715,1143,1145],{"x":1126,"y":1144,"style":1136},"163.0","one digit before the point",[715,1147,1149],{"x":1126,"y":1148,"style":1136},"189.0","any exponent",[692,1151],{"x":1152,"y":702,"width":1109,"height":1110,"rx":1111,"fill":1153,"stroke":1154,"style":1112},"389.0","#d9f4f1","var(--teal,#0f9488)",[1114,1156,1158],{"transform":1157},"translate(551.5,29.0) scale(1.083)",[1118,1159],{"d":1160,"fill":1121,"stroke":1161,"style":1123},"M12 9a3 3 0 1 0 .01 0z M12 2.5v3 M12 18.5v3 M2.5 12h3 M18.5 12h3 M5.3 5.3l2.1 2.1 M16.6 16.6l2.1 2.1 M5.3 18.7l2.1-2.1 M16.6 7.4l2.1-2.1","var(--teal-ink,#0b6157)",[715,1163,1166],{"x":1164,"y":741,"style":1165},"564.5","font-size:14px;font-weight:700;fill:var(--teal-ink,#0b6157);text-anchor:middle","Engineering ##0.0E+0",[45,1168],{"x1":1169,"y1":1132,"x2":1170,"y2":1132,"stroke":1154,"style":706},"405.0","724.0",[715,1172,1173],{"x":1164,"y":771,"style":1136},"0.000012345 → 12.3E-6",[715,1175,1176],{"x":1164,"y":1140,"style":1136},"6.02×10²³ → 602.2E+21",[715,1178,1179],{"x":1164,"y":1144,"style":1136},"1 to 3 digits before the point",[715,1181,1182],{"x":1164,"y":1148,"style":1136},"exponent a multiple of 3",[29,1184,1186],{"id":1185},"step-3-why-codes-turn-into-123457e11","Step 3 — Why codes turn into 1.23457E+11",[10,1188,1189,1190,1193,1194,1196],{},"Excel's ",[642,1191,1192],{},"General"," format — the default for any cell without a format — shows up to 11 digits; a number with more digits than that is displayed in scientific notation, so the account number 123456789012 appears as ",[14,1195,20],{}," in a normal-width column. LibreOffice is more generous in its CSV export, but the second problem is shared by both:",[34,1198,1200],{"className":67,"code":1199,"language":69,"meta":39,"style":39},"codes = [123456789012, 1234567890123456789]\nrows = shown(codes, [\"General\", \"0\", \"@\"], \"codes\")\nfor v, row in zip(codes, rows):\n    print(f\"{v}  ->  {row}\")\n",[14,1201,1202,1221,1250,1263],{"__ignoreMap":39},[43,1203,1204,1207,1209,1211,1214,1216,1219],{"class":45,"line":46},[43,1205,1206],{"class":80},"codes ",[43,1208,136],{"class":76},[43,1210,414],{"class":80},[43,1212,1213],{"class":108},"123456789012",[43,1215,273],{"class":80},[43,1217,1218],{"class":108},"1234567890123456789",[43,1220,445],{"class":80},[43,1222,1223,1225,1227,1230,1233,1235,1238,1240,1243,1245,1248],{"class":45,"line":84},[43,1224,489],{"class":80},[43,1226,136],{"class":76},[43,1228,1229],{"class":80}," shown(codes, [",[43,1231,1232],{"class":53},"\"General\"",[43,1234,273],{"class":80},[43,1236,1237],{"class":53},"\"0\"",[43,1239,273],{"class":80},[43,1241,1242],{"class":53},"\"@\"",[43,1244,312],{"class":80},[43,1246,1247],{"class":53},"\"codes\"",[43,1249,261],{"class":80},[43,1251,1252,1254,1256,1258,1260],{"class":45,"line":98},[43,1253,570],{"class":76},[43,1255,573],{"class":80},[43,1257,176],{"class":76},[43,1259,578],{"class":108},[43,1261,1262],{"class":80},"(codes, rows):\n",[43,1264,1265,1267,1269,1271,1273,1275,1277,1279,1282,1284,1287,1289,1291],{"class":45,"line":105},[43,1266,586],{"class":108},[43,1268,343],{"class":80},[43,1270,242],{"class":76},[43,1272,245],{"class":53},[43,1274,249],{"class":248},[43,1276,597],{"class":80},[43,1278,255],{"class":248},[43,1280,1281],{"class":53},"  ->  ",[43,1283,249],{"class":248},[43,1285,1286],{"class":80},"row",[43,1288,255],{"class":248},[43,1290,245],{"class":53},[43,1292,261],{"class":80},[10,1294,1295,1296,1298,1299,1302,1303,1306,1307,1309,1310,1313,1314,1317,1318,27],{},"Formatting the 12-digit code with ",[14,1297,695],{}," shows every digit. The 19-digit code cannot be rescued by any format — not even the text format ",[14,1300,1301],{},"@",", which applied to a cell that already holds a number leaves it a number, as the export shows: spreadsheet numbers are double-precision floating point with about 15 significant digits, so 1234567890123456789 is ",[642,1304,1305],{},"stored"," as 1234567890123460000 and the last digits are gone before formatting is considered. Identifiers — card numbers, IBAN-like codes, long order references, barcodes — are not quantities and should be written as ",[642,1308,715],{},". From pandas, keep such columns as strings (",[14,1311,1312],{},"dtype=str"," when reading, ",[14,1315,1316],{},"astype(str)"," before writing) and they arrive in Excel as text with every digit intact, as covered in ",[23,1319,1321],{"href":1320},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-zip-codes-and-ids-with-leading-zeros\u002F","Format ZIP Codes and IDs with Leading Zeros",[673,1323,682,1328,682,1331,682,1334,682,1337,682,1343,682,1350,682,1355,682,1359,682,1363,682,1366,682,1371,682,1378,682,1383,682,1388,682,1394,682,1399,682,1403,682,1405,682,1408,682,1412,682,1415,682,1418,682,1424,682,1427,682,1430,682,1432,682,1435,682,1438,682,1441,682,1446,682,1453,682,1457],{"viewBox":1324,"role":676,"ariaLabelledBy":1325,"xmlns":680,"style":681},"4 0 752 272",[1326,1327],"fr-ids-t","fr-ids-d",[684,1329,1330],{"id":1326},"Long numbers in a report",[688,1332,1333],{"id":1327},"A quantity with many digits is formatted with 0 or",[692,1335],{"x":694,"y":695,"width":696,"height":1336,"fill":698},"272",[692,1338],{"x":1339,"y":702,"width":1340,"height":1341,"rx":1342,"fill":711,"stroke":712,"style":1112},"240.0","280.0","75.5","12",[1114,1344,1346],{"transform":1345},"translate(368.0,29.0) scale(1.000)",[1118,1347],{"d":1348,"fill":1121,"stroke":1122,"style":1349},"M5 9h14 M4 15h14 M10 4l-2 16 M16 4l-2 16","stroke-width:1.80px;stroke-linecap:round;stroke-linejoin:round",[715,1351,1354],{"x":1352,"y":1341,"style":1353},"380.0","font-size:13.5px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","Is it a quantity or an identifier?",[45,1356],{"x1":1352,"y1":1357,"x2":1352,"y2":1358,"stroke":712,"style":1112},"91.5","111.5",[45,1360],{"x1":1361,"y1":1358,"x2":1362,"y2":1358,"stroke":712,"style":1112},"134.7","625.3",[45,1364],{"x1":1361,"y1":1358,"x2":1361,"y2":1365,"stroke":712,"style":1112},"157.5",[1367,1368],"polygon",{"points":1369,"fill":1370},"134.7,161.5 129.7,152.5 139.7,152.5","#5b5cf0",[692,1372],{"x":1373,"y":1374,"width":1375,"height":1376,"rx":1377,"fill":698,"stroke":705,"style":713},"101.1","121.5","67.0","21.0","10",[715,1379,1382],{"x":1361,"y":1380,"style":1381},"136.0","font-size:11.5px;font-weight:700;fill:var(--muted,#5b6780);text-anchor:middle","quantity",[692,1384],{"x":701,"y":1385,"width":1386,"height":1387,"rx":1342,"fill":1153,"stroke":1154,"style":1112},"163.5","229.3","93.0",[1114,1389,1391],{"transform":1390},"translate(122.7,176.5) scale(1.000)",[1118,1392],{"d":1393,"fill":1121,"stroke":1161,"style":1349},"M4 20h16 M7 17v-5 M12 17V7 M17 17v-8",[715,1395,1398],{"x":1361,"y":1396,"style":1397},"223.0","font-size:13.5px;font-weight:700;fill:var(--teal-ink,#0b6157);text-anchor:middle","format 0 or #,##0",[715,1400,1402],{"x":1361,"y":1401,"style":748},"242.5","avoids E+11 display",[45,1404],{"x1":1352,"y1":1358,"x2":1352,"y2":1365,"stroke":712,"style":1112},[1367,1406],{"points":1407,"fill":1370},"380.0,161.5 375.0,152.5 385.0,152.5",[692,1409],{"x":1410,"y":1374,"width":1411,"height":1376,"rx":1377,"fill":698,"stroke":705,"style":713},"313.0","133.9",[715,1413,1414],{"x":1352,"y":1380,"style":1381},"identifier ≤ 15 digits",[692,1416],{"x":1417,"y":1385,"width":1386,"height":1387,"rx":1342,"fill":711,"stroke":712,"style":1112},"265.3",[1114,1419,1421],{"transform":1420},"translate(368.0,176.5) scale(1.000)",[1118,1422],{"d":1423,"fill":1121,"stroke":1122,"style":1349},"M8 11a4 4 0 1 0 .01 0z M11 13l9-9 M17 7l2 2 M15 9l2 2",[715,1425,1426],{"x":1352,"y":1396,"style":1353},"write as text",[715,1428,1429],{"x":1352,"y":1401,"style":748},"keeps leading zeros",[45,1431],{"x1":1362,"y1":1358,"x2":1362,"y2":1365,"stroke":712,"style":1112},[1367,1433],{"points":1434,"fill":1370},"625.3,161.5 620.3,152.5 630.3,152.5",[692,1436],{"x":1437,"y":1374,"width":1411,"height":1376,"rx":1377,"fill":698,"stroke":705,"style":713},"558.4",[715,1439,1440],{"x":1362,"y":1380,"style":1381},"identifier > 15 digits",[692,1442],{"x":1443,"y":1385,"width":1386,"height":1387,"rx":1342,"fill":1444,"stroke":1445,"style":1112},"510.7","#fdefd8","var(--gold,#b4740a)",[1114,1447,1449],{"transform":1448},"translate(613.3,176.5) scale(1.000)",[1118,1450],{"d":1451,"fill":1121,"stroke":1452,"style":1349},"M12 3.5l9.5 17h-19z M12 10v5 M12 17.8v.4","var(--gold-ink,#7a4e06)",[715,1454,1456],{"x":1362,"y":1396,"style":1455},"font-size:13.5px;font-weight:700;fill:var(--gold-ink,#7a4e06);text-anchor:middle","must be text",[715,1458,1459],{"x":1362,"y":1401,"style":748},"numbers lose digits",[29,1461,1463],{"id":1462},"reading-the-values-back","Reading the values back",[10,1465,1466,1467,1470,1471,1474,1475,27],{},"None of these formats changes what Python reads. ",[14,1468,1469],{},"pd.read_excel"," returns 2.375 for a cell showing 2 3\u002F8 and 1.2345e-05 for one showing 12.3E-6, because it reads the stored value and ignores the display. openpyxl does the same, and exposes the format separately as ",[14,1472,1473],{},"cell.number_format",", so a test can check both: that the value is right and that the format is the one intended. If you need the text exactly as a reader sees it — for a comparison against a printed report, say — the LibreOffice export used on this page is the reliable way, as described in ",[23,1476,1478],{"href":1477},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fread-cell-values-as-displayed-in-excel\u002F","Read Cell Values as Displayed in Excel",[29,1480,1482],{"id":1481},"common-pitfalls","Common pitfalls",[1484,1485,1486,1497,1503,1509,1515],"ul",{},[1487,1488,1489,1493,1494,1496],"li",{},[1490,1491,1492],"strong",{},"Expecting fixed denominators to reduce."," ",[14,1495,652],{}," shows 10\u002F16, not 5\u002F8 — by design.",[1487,1498,1499,1502],{},[1490,1500,1501],{},"Approximate fractions in totals."," The display rounds; the value does not.",[1487,1504,1505,1508],{},[1490,1506,1507],{},"Fixed decimals for tiny values."," Use scientific or engineering notation instead.",[1487,1510,1511,1514],{},[1490,1512,1513],{},"Identifiers as numbers."," Long codes show as E+11 or lose digits; write them as text.",[1487,1516,1517,1520],{},[1490,1518,1519],{},"Trusting one application's display."," Check formats where readers will open the file.",[29,1522,1524],{"id":1523},"conclusion","Conclusion",[10,1526,1527,1528,273,1530,649,1532,1534,1535,649,1537,1539,1540,1542,1543,1546,1547,1549,1550,1553],{},"Use ",[14,1529,639],{},[14,1531,766],{},[14,1533,787],{}," to show measurements as the nearest fraction with up to one, two or three digit denominators, and ",[14,1536,648],{},[14,1538,652],{}," for a fixed denominator. Use ",[14,1541,1064],{}," for scientific notation and ",[14,1544,1545],{},"##0.0E+0"," for engineering notation with exponents in multiples of three. Format long quantities with ",[14,1548,695],{}," so they do not collapse to ",[14,1551,1552],{},"E+11"," under General, and write identifiers as text, because numbers keep only about 15 significant digits.",[29,1555,1557],{"id":1556},"frequently-asked-questions","Frequently asked questions",[10,1559,1560,1563],{},[1490,1561,1562],{},"How do I show a number as a fraction in Excel with Python?","\nSet the cell's number_format to a fraction format such as # ?\u002F? for the nearest one-digit fraction or # ?\u002F16 for sixteenths.",[10,1565,1566,1569],{},[1490,1567,1568],{},"How do I format numbers in scientific notation with openpyxl?","\nUse a format such as 0.00E+00; for engineering notation with exponents in multiples of three use ##0.0E+0.",[10,1571,1572,1575],{},[1490,1573,1574],{},"Why does Excel show my number as 1.23457E+11?","\nThe General format displays numbers with more than 11 digits in scientific notation; apply the format 0 or #,##0, or write identifiers as text.",[10,1577,1578,1581],{},[1490,1579,1580],{},"Why do long numbers lose their last digits in Excel?","\nExcel stores numbers with about 15 significant digits, so longer numbers are rounded; store identifiers such as card or order numbers as text.",[29,1583,1585],{"id":1584},"related","Related",[1484,1587,1588,1594,1601,1606],{},[1487,1589,1590,1591,1593],{},"Up one level: ",[23,1592,26],{"href":25}," — number formats from Python.",[1487,1595,1596,1600],{},[23,1597,1599],{"href":1598},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-numbers-in-lakhs-and-crores-in-excel\u002F","Format Numbers in Lakhs and Crores in Excel"," — digit grouping.",[1487,1602,1603,1605],{},[23,1604,1091],{"href":1090}," — rounding versus display.",[1487,1607,1608,1612],{},[23,1609,1611],{"href":1610},"\u002Fadvanced-data-transformation-and-cleaning\u002Fextracting-data-from-messy-excel-sheets\u002Fparse-numbers-with-units-in-excel-cells\u002F","Parse Numbers with Units in Excel Cells"," — the reverse problem.",[1614,1615,1616],"style",{},"html pre.shiki code .sMTad, html code.shiki .sMTad{--shiki-default:#6F42C1;--shiki-dark:#FFB757}html pre.shiki code .srMev, html code.shiki .srMev{--shiki-default:#032F62;--shiki-dark:#ADDCFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s-kum, html code.shiki .s-kum{--shiki-default:#D73A49;--shiki-dark:#FF9492}html pre.shiki code .skGVy, html code.shiki .skGVy{--shiki-default:#24292E;--shiki-dark:#F0F3F6}html pre.shiki code .sP0c6, html code.shiki .sP0c6{--shiki-default:#005CC5;--shiki-dark:#91CBFF}html pre.shiki code .s_Opv, html code.shiki .s_Opv{--shiki-default:#6F42C1;--shiki-dark:#DBB7FF}html pre.shiki code .sa561, html code.shiki .sa561{--shiki-default:#E36209;--shiki-dark:#FFB757}html pre.shiki code .sSjpA, html code.shiki .sSjpA{--shiki-default:#005CC5;--shiki-dark:#FF9492}",{"title":39,"searchDepth":84,"depth":84,"links":1618},[1619,1620,1621,1622,1623,1624,1625,1626,1627],{"id":31,"depth":84,"text":32},{"id":391,"depth":84,"text":392},{"id":861,"depth":84,"text":862},{"id":1185,"depth":84,"text":1186},{"id":1462,"depth":84,"text":1463},{"id":1481,"depth":84,"text":1482},{"id":1523,"depth":84,"text":1524},{"id":1556,"depth":84,"text":1557},{"id":1584,"depth":84,"text":1585},"2026-10-02","Control how Excel shows very small, very large and fractional numbers written from Python: fraction formats with up to one, two or three digit denominators or a fixed denominator such as sixteenths, scientific and engineering notation, why long numbers turn into 1.23457E+11 under the General format, and why IDs longer than 15 digits must be written as text.","md",[1632,1634,1636,1638],{"q":1562,"a":1633},"Set the cell's number_format to a fraction format such as # ?\u002F? for the nearest one-digit fraction or # ?\u002F16 for sixteenths.",{"q":1568,"a":1635},"Use a format such as 0.00E+00; for engineering notation with exponents in multiples of three use ##0.0E+0.",{"q":1574,"a":1637},"The General format displays numbers with more than 11 digits in scientific notation; apply the format 0 or #,##0, or write identifiers as text.",{"q":1580,"a":1639},"Excel stores numbers with about 15 significant digits, so longer numbers are rounded; store identifiers such as card or order numbers as text.","format fractions and scientific notation in excel",null,{"breadcrumb":1643},[1644,1647,1650],{"name":1645,"item":1646},"Home","\u002F",{"name":1648,"item":1649},"Formatting and Charting Excel Reports with Python","\u002Fformatting-and-charting-excel-reports-with-python\u002F",{"name":26,"item":25},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-fractions-and-scientific-notation-in-excel",{"title":1653,"description":1654},"Format Fractions and Scientific Notation in Excel with Python","openpyxl number formats for fractions (# ?\u002F?, # ??\u002F??, # ?\u002F16) and scientific or engineering notation (0.00E+00, ##0.0E+0), plus the General format's E+11 surprise and the 15-digit precision limit.","format-fractions-and-scientific-notation-in-excel","formatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-fractions-and-scientific-notation-in-excel\u002Findex",[1658],"number-formats","how-to","b3LkAZJbpc3bEm-3CN32ef95TFxOuRDye9M7M8J9WwQ",[1662,1666],{"title":1663,"path":1664,"stem":1665,"children":-1},"Format Excel Cells as Currency with Python","\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-excel-cells-as-currency-with-python","formatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-excel-cells-as-currency-with-python\u002Findex",{"title":1667,"path":1668,"stem":1669,"children":-1},"Format Numbers as Percentages in Excel with Python","\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-numbers-as-percentages-in-excel-with-python","formatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-numbers-as-percentages-in-excel-with-python\u002Findex",[1671,1673],{"path":1672,"title":26},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel",{"path":1674,"title":1648},"\u002Fformatting-and-charting-excel-reports-with-python",[],[1677,1680,1683,1686,1689,1692],{"path":1678,"title":1679,"kind":1659},"\u002Fadvanced-data-transformation-and-cleaning\u002Fcleaning-excel-data-with-pandas\u002Fconvert-currency-strings-to-numbers-with-pandas","Convert Currency Strings Like \"$1,234.56\" and \"(500)\" to Numbers with pandas",{"path":1681,"title":1682,"kind":1659},"\u002Fadvanced-data-transformation-and-cleaning\u002Fcleaning-excel-data-with-pandas\u002Fconvert-percentage-strings-to-numbers-with-pandas","Convert Percentage Strings Like \"12.5%\" to Numbers with pandas",{"path":1684,"title":1685,"kind":1659},"\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fexcel-text-function-equivalent-in-pandas","Excel TEXT Function Equivalent in pandas",{"path":1687,"title":1688,"kind":1659},"\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fmatch-excel-rounding-in-pandas","Match Excel Rounding in pandas",{"path":1690,"title":1691,"kind":1659},"\u002Fadvanced-data-transformation-and-cleaning\u002Fworking-with-dates-and-times-in-excel-data\u002Fconvert-excel-time-values-and-durations","Convert Excel Time Values and Durations in Python",{"path":1693,"title":1694,"kind":1659},"\u002Fautomating-reporting-workflows\u002Fbuilding-multi-sheet-excel-dashboards\u002Fadd-variance-arrows-and-trend-indicators-to-a-dashboard","Add Variance Arrows and Trend Indicators to a Dashboard",1790972107015]