Suppose I have the following DataFrame:  d = {'col1': [1000, 2, 3, 2400000]} df = pd.DataFrame(data=d)    which results in   col1 1000 2 3 2400000   Suppose I would like to have this DataFrame formatting in thousands or millions, depending on the current value, how would I do this? Say I would like the result to be  col1 1K 2 3 2.4M   I know how to do it when I'd like the whole column to be formatting into millions or thousands, but not when it comes to separate values.
26280
What is an easy way in Python to format integers into strings representing thousands with K, and millions with M, and leaving just couple digits after comma?  I'd like to show 7436313 as 7.44M, and 2345 as 2,34K.  Is there some % string formatting operator available for that? Or that could be done only by actually dividing by 1000 in a loop and constructing result string step by step?
5995
When displaying the value of a decimal currently with .ToString(), it's accurate to like 15 decimal places, and since I'm using it to represent dollars and cents, I only want the output to be 2 decimal places.   Do I use a variation of .ToString() for this?
3536
Possible Duplicate:          I want to truncate the decimals like below  i.e.   2.22939393 -> 2.229 2.22977777 -> 2.229
47087
In a Google Spreadsheet, I have a column with values like T1, T2, T13 (i.e. all values starting with the same text prefix). I would like to use a formula on the numerical part of the values of these cells (for conditional formatting). Can I somehow apply it only to the numeric part of the value, i.e. 1, 2, 13? I would like to change the background colour for the cell containing the maximum numeric part of the value?  I know how to extract the numeric part. E.g., if the T-values are in column A, cell B3 can contain this equation:  =if(len(A3)&gt;1,value(right(A3, len(A3)-1)),0)   However I fail to apply any further formula to this. E.g. this doesn't work:  =max(if(len(A2:A)&gt;1,value(right(A2:A, len(A2:A)-1)),0))
48392
I have a vector shapefile with a column with string values. How can I convert this to a column of integer values in another column but keep the categorization.  e.g. from:  col1,newcol2 A, A, B, A, C,    to:  col1,newcol2 A,1 A,1 B,2 A,1 C,3    I'm sure it is in the 'replace' or 'case when' syntax somewhere but I cannot find a clear method via Google etc.
90637
Excel converting value 0503E000 to 5.03E+02 in any cell automatically in CSV I tried to convert it to text number and general but after i save it and reopen it again it goes back to 5.03E+02  How do I stop this from happening?
56650
What is the best way of editing an existing LaTeX table? I need to swap the order of two columns and can't think of an efficient way of doing this.  My table is a long creature of the following structure:  A &amp;     -0.523 &amp;      26.94 &amp;     0.8243 &amp;     0.0000 &amp;     -12.67 \\ B &amp;     -0.614 &amp;      30.02 &amp;     0.8509 &amp;     0.0000 &amp;     -13.12 \\ C &amp;     -0.630 &amp;      32.92 &amp;     0.9254 &amp;     0.0000 &amp;     -21.45 \   I need to change the values so that it is:   A &amp;     26.94 &amp;      -0.523 &amp;     0.8243 &amp;     0.0000 &amp;     -12.67 \\ (etc)   The thoughts that I had were to import it into Excel and to drag columns around, and then use the concatenate() function to produce the number &amp; number structure. I feel like there might be a better way of doing this that I am unaware of.
58187
I have a 20,000 line spreadsheet in Apple Numbers, and I need to fill a column with data. I don't want to sit there dragging down the fill handle for thousands of rows.   How can I fill the whole column with a value?
52496
Why in the following tables the results of formatting of S columns are different, i.e. dependent on, where the column is in table? Consequently those tables have different width.  \documentclass{article}                \usepackage{siunitx}     \usepackage{array}  \newcommand\mc[1]{\multicolumn{1}{c}{#1}}      \begin{document} \begin{tabular}{c c|                   *{2}{S[table-format=2.2,                        table-space-text-post=\si{\,\%}\ ]&lt;{\,\%}|}                 }     \hline A  &amp;    B       &amp;   \mc{C}  &amp;   \mc{D}  \\  \hline xx &amp; xx xxx     &amp;   12.34   &amp;   56.78   \\  \hline \end{tabular}  \bigskip \begin{tabular}{c|                  *{2}{S[table-format=2.2,                        table-space-text-post=\si{\,\%}\ ]&lt;{\,\%}|}                 c}     \hline A  &amp;   \mc{C}  &amp;   \mc{D}   &amp;    B     \\   \hline xx &amp;   12.34   &amp;   56.78    &amp; xx xxx   \\   \hline \end{tabular}     \end{document}     As you can see, the difference is in the space between numbers and accompanied sign \%. Probably in formatting of D columns I miss something obvious :-(
70051
How can I format Floats in Java so that the float component is displayed only if it's not zero? For example:   123.45 -> 123.45 99.0   -> 99 23.2   -> 23.2 45.0   -> 45   Edit: I forgot to mention - I'm still on Java 1.4 - sorry!
115650
I need to typeset some very large numbers that span a number of lines, is there a way in LaTeX to do this?
5342
I have a dataset in csv file format that I'm loading into pgfplotstable. I can't change the format of the original csv, and being financial data it has a column of item names and two or three explanatory data points at the top of the table. e.g.  \documentclass{article} \usepackage{array,datatool,pgfplotstable}   \begin{filecontents}{sample.csv}     item,2008,2009,2010,2011      ,Actual,Actual,Forecast,Forecast      ,GBP,GBP,GBP,GBP      ,('000),('000),('000),('000) rounded     Area 1 OP, 1000000,1500000,1750000,250000     Area 2 OP, 400000,500000, 450000,-50000     Area 51 OP, 300000,375000,390000,15000     No P, 1250000, 1000000, 950000, 50000     Residuals, 800000, 80000, 90000, 10000   \end{filecontents}  \pgfplotstableread[col sep=comma]{sample.csv}\mystuff   I'm stumped at the next stage which is to typeset \mystuff so I have comma separators and can add a row that sums the 'Area' columns. At the moment to display the table I have to do something like  \begin{document}  \pgfplotstableread[col sep=comma,header=false]{sample.csv}\mystuff  \pgfplotstabletypeset[   columns/0/.style={string type},   columns/1/.style={string type},   columns/2/.style={string type},   columns/3/.style={string type},   columns/4/.style={string type}]\mystuff  \end{document}   How do I tag the top three rows as string and the rest of the last four columns as integer type so I can format and transform them?
45046
I've started a new job and it involves looking at a bunch of big numbers. Is there an easy way to add commas to an int or decimal field to make it readable?  For example, SQL Server outputs the column on the left, but for my own sanity, I need it to look like the one on the right:  2036150 -&gt; 2,036,150     ...or would I have to write some heinous   left(right(vandalized_data),6),3) + ',' + right(left(vandalized_data),6),3)   function?  The perfect thing would be commas in the display grid, then plain integers in the output.
75350
Is it possible to have automatic rounding of numbers in a table?  Say that I have this, made in the usual way with a tabular environment:  pi  | 3.14592654 e   | 2.7182818284 phi | 1.6180339887   Can I control how many significant digits are shown without truncating the numbers manually myself?   So for example, if I need four significant digits, the numbers should appear as  pi  | 3.1459 e   | 2.7183 phi | 1.6180   Bonus points for actually rounding the numbers according to the usual rules without simply truncating them.    I understand this is probably non-trivial, so here's a relaxed version that will also work in my circumstances (all numbers have one and the same precision and character count):  (How) Can I control how many characters are rendered in a column of a table?  So if I define the text in the columns as:  \begin{tabular} % some black magic column definition    text &amp; alongword\\    text &amp; anotherlongword\\    text &amp; morelongwords\\ \end{tabular}   I'd like to get something like:  text along text anoth text morel   I know there are non-TeX ways to do this, and I will probably resolve to writing a script if all else fails, but I'm curious whether there's a way to do it solely with TeX &amp; friends.
53171
Formatting numbers on a VF page, but I do a bunch of processing the Apex Class, so I would rather return the formatted String value from the controller.   I am doing something like this, but I just want the second number to appear as "(1500)" rather "-1500"  Getting lost in the Message Format docs, so hoping someone can guide me in the right direction...  List&lt;String&gt; args = new String[]{'0','number','###,###,###'}; system.debug('Positive' + String.format(  ( (1000) - (500.50)  ).round().format(), args) ); system.debug('Negative' + String.format(  ( (-1000) - (500.50)  ).round().format(), args) );
117263
Currently the network has a very inconsistent track record when it comes to injecting thousands separators in numbers >= 4 digits. Sometimes on the same page there will be commas in one element and not in another.  The primary advantage to using thousands separators is that it makes a number easier to read, at least for me.  The primary disadvantage is that it makes them harder to read for folks who use different languages or locales, where commas are actually decimals, and thousands separators may be decimals, spaces or other characters (or not even an existent concept).  I've seen arguments that the SE network should use comma separators because "the site is American" or because "English is the language of the Internet." I am not quite obnoxious enough to say I agree with either of those statements. And as a Canadian living in the United States, where arguments about m/d/y vs. d/m/y, gallons vs. liters and miles vs. kilometers have plagued me my entire adult life, it would be fantastic to have some consensus about this and to see some consistency implemented across the network.  I understand that . But I still think it's a valuable discussion to have - should we force thousands separators, prevent them, or cater to the individual locale? The downsides to catering per language are (a) screen shots and other artifacts may still seem strange to users of different locales and (b) what if my computer is set to US-English but I would prefer not to see thousands separators? Perhaps the answer is to  instead of listing out the entire number in some places but not others - then the discussion about separators becomes moot.     PLEASE NOTE: This is not a bug report about the individual cases where the use of thousands separators is inconsistent. There are    , and if pluralization has taught us anything, it seems to be . I hope it is the intention for the localization efforts to push all number and other common formatting tasks through common functions to eliminate this chance for discrepancy.This post is an attempt to discuss what the policy should be, in general, not to discuss individual instances of this inconsistency.
108143
I need to pivot one column (Numbers column). example need this data:  a 1 a 2 b 3 b 4 c 5 d 6 d 7 d 8 d 9 e 10 e 11 e 12 e 13 e 14   Look like this  a 1 2 b 3 4 c 5 d 6 7 8 9 e 10 11 12 13 14   any help would be greatly appreciated...