dataframe:  data = {"Category":["Resource","Resource","Resource","Resource"],     "Item1":["Bandwidth","Bandwidth","Bandwidth","Bandwidth"],     "Item2":["DC","OC","DC","OC"],     "Amount":[156.415,396.921,-156.415,-396.921]} df = pd.DataFrame(data)  df = df.groupby(["Category","Item1"],as_index=False).sum() print df   get the result:     Category      Item1        Amount 0  Resource  Bandwidth  5.684342e-14   Why Amount not zero?How can I get the right result?
27
Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?
66277
I have the table below and i want it to read through columns A-B and then sum the values that match their names in columns C-D.  So that in a column elsewhere of a list of names i have the sum of their values from this table. For example Ed features in both columns with a value of 1 and 3, so would return a value of 4. Struggling to get this to work nicely. My actual table consists of 4 columns names and two sets of 4 columns with numbers.    A       B       C   D Steve   Jeff    4   1 James   Calum   1   1 Alex    Andy    2   1 Peter   Ed      0   3 Owen    Harry   1   2 Jeff    Steve   4   1 James   Calum   1   1 Andy    Alex    2   1 Peter   Owen    0   3 Ed      Harry   1   2
50537
I have PG server (9.0.4) installed on Debian x86. In one of my tables I use numeric(6,1):  CREATE TABLE mytable(name text, numfield numeric(6,1))   Also index created for this field:  CREATE INDEX mytable_numfield_idx ON mytable USING btree (numfield);   Everything is going fine if I use this field with real numeric value. As I see the query uses the index:  EXPLAIN ANALYZE SELECT * FROM kodiall WHERE kodgo=123.0      Index Scan using mytable_numfield_idx on mytable  (cost=0.00..8.27 rows=1   width=193) (actual time=0.085..0.087 rows=1 loops=1)      Index Cond: (numfield = 123.0)      Total runtime: 0.131 ms   But the index is ignored for some reason if I use 0.0 or NULL as condition value:  EXPLAIN ANALYZE SELECT * FROM kodiall WHERE numfield=0.0 --EXPLAIN ANALYZE SELECT * FROM kodiall WHERE numfield=NULL      Seq Scan on mytable  (cost=0.00..57.80 rows=1080 width=193) (actual   time=0.033..1.853 rows=1088 loops=1)      Filter: (numfield = 0.0)   What wrong here? Is 0.0 not a numeric value?  In real query I use LEFT JOIN with numfield and values in joined table can be NULL.
78381
I have a simple spreadsheet, two columns "Amount" (col Q) and "Account" (col O).  I want to get the sum of the "Amount" column where the corresponding "Account" forum equals "Paypal".  This is as far as I can get!  =SUM(Q:Q)*(O:O="Paypal")
60608
I have the value 25.00 in a float, but when I print it on screen it is 25.0000000. How can I display the value with only two decimal places?
75500
When I am downloading the CSV file, the results show zeros in the CSV file. How can I download exact NO2 values as shown in Chart after running the mentioned below code in Google Earth Engine? // Create a FeatureCollection from the list and print it. var BergamoGeometry = ee.FeatureCollection(BergamoGeometry); print(BergamoGeometry); Map.centerObject(BergamoGeometry); Map.addLayer(BergamoGeometry); //////////////////////////////////////  var dataset = ee.ImageCollection(&quot;COPERNICUS/S5P/NRTI/L3_NO2&quot;)                  .filterBounds(BergamoGeometry)                   .filter(ee.Filter.date('2019-03-30', '2019-04-29'));                   var NO2 = dataset.select('NO2_column_number_density'); var band_viz = {   min: 0,   max: 0.0002,   palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red'] }; // Create and print the chart. print(ui.Chart.image.series(NO2, BergamoGeometry, ee.Reducer.mean(), 30));
4943
I would like to calculate the sum of values in one column, based on values in another column. To illustrate my question I uploaded the picture below. The second column consists of zipcodes, the third total sales. I would like to know what the total sales per zipcode are? So in this case:  What is the sum of column three for column two's value 1023? Output then should be 4 (0+1+1+2+0). The sum for 1024 then should be 11,5 following the same logic.  As this is quite a large dataset I would like to have the QGIS field calculator (or any other tool) calculate a new field which states the total sales in the zipcode. So far I can't seem to get it working and was hoping someone here could help me.  As you can see I have some missing values, is this a problem in calculation? Perhaps good to mention is that it is a table.
28652
If $X_1,...,X_n$ are iid, what is the mean of the following variable:?  $ \sum (X_i - \bar{X})^2$  I know the answer is $\sigma^2(n-1)$, but how is this calculated in general? If I expand, I get the variables squared, and that turns quite ugly. What's the trick here?
105548
I make a new column in my attribute table and it has a default value (for example 0). I want to (probably using the field calculator) have the result that row 1 has the value 1, row 2=2 and so on, just like a numbered index.  I'd be thankful for a code example for the field calculator (including the use of $rownum (I think I need this for switching to the line)).
95016
I have data with a column containing a number value, and I want to divide the value of each feature by the total sum of all the values in the column (to get a percentage).  So I would like to know if there is some simple syntax in the QGIS field calculator to get the sum of a column, preferably without resorting to for loops and what not.    I have a shapefile where feature A has the value X in column B. How can I summerize the values for all features in column B in order to divide value X to get a percentage for each feature?
105976
I'm trying to create a calculated column that uses the list item's ID field as part of the calculated string value. When I create a new list item, the calculated field seems to always use 0 as the ID value. I know that during creation, the new list items ID is 0 until the content database is updated, which apparently generates the actual ID. Is there a way to get the calculated column to accurately reflect the ID value of the list item?
74783
Is there any built-in methods that are part of lists that would give me the first and last index of some value, like:  verts.IndexOf(12.345) verts.LastIndexOf(12.345)
17985
I'm trying to use those parameters and I receive a difference of ~0.5m    ALON and BSHM APN Points:  coords = [   (dms2rad([31,42,28.5694]),  dms2rad([34,36,23.92196]),  55.671),   (dms2rad([32,46,44.34472]), dms2rad([35,1,22.74061]), 225.046), ]   Transform:  def lla_to_ig05(lon, lat, alt):     import pyproj     lla = pyproj.Proj(proj='latlong', ellps='WGS84', datum='WGS84')     ig05 = pyproj.Proj("+proj=tmerc +lat_0=31.7343936111111 +lon_0=35.2045169444445 +k=1.0000067 +x_0=219529.584 +y_0=626907.39 +ellps=GRS80 +towgs84=-24.002400,-17.103200,-17.844400,-0.33077,-1.852690,1.669690,5.424800 +units=m +no_defs")     x, y, h = pyproj.transform(lla, ig05, lon, lat, alt, radians=True)     return x, y, h for lat, lon, alt in coords:   print(pd.DataFrame(lla_to_ig05(lon, lat, alt))) # pd for pandas   print("")   Output:                 0 0  162790.443392 1  624087.953905 2      55.671000                 0 0  202456.903152 1  742717.095893 2     225.046000   Real numbers:                 0 0  162789.564 1  624088.355 2      55.671000                 0 0  202456.453 1  742718.779 2     225.046000   Any hint will be very helpful!
34147
I'm trying to identify null/0 values in each of my raster bands. How can I loop through all the values of each band? I've tried this code, straight from the gdal/python cookbook website but this just gives stats for each band as a whole and for some reason it actually doesn't print a minimum value of 0 even though my raster does have 0 values, it shows a minimum value of 1.   I want to print every single cell value. Is there a way to do this?   from osgeo import gdal import sys  src_ds = gdal.Open( "INPUT.tif" )  print "[ RASTER BAND COUNT ]: ", src_ds.RasterCount for band in range( src_ds.RasterCount ):     band += 1     print "[ GETTING BAND ]: ", band     srcband = src_ds.GetRasterBand(band)      stats = srcband.GetStatistics( True, True )      print "[ STATS ] =  Minimum=%.3f, Maximum=%.3f, Mean=%.3f, StdDev=%.3f" % ( \             stats[0], stats[1], stats[2], stats[3] )
2846
Why does the following behave unexpectedly in Python?  &gt;&gt;&gt; a = 256 &gt;&gt;&gt; b = 256 &gt;&gt;&gt; a is b True           # This is an expected result &gt;&gt;&gt; a = 257 &gt;&gt;&gt; b = 257 &gt;&gt;&gt; a is b False          # What happened here? Why is this False? &gt;&gt;&gt; 257 is 257 True           # Yet the literal numbers compare properly   I am using Python 2.5.2. Trying some different versions of Python, it appears that Python 2.3.3 shows the above behaviour between 99 and 100.  Based on the above, I can hypothesize that Python is internally implemented such that "small" integers are stored in a different way than larger integers and the is operator can tell the difference. Why the leaky abstraction? What is a better way of comparing two arbitrary objects to see whether they are the same when I don't know in advance whether they are numbers or not?
44756
I just came across an exercise that asks to show that set of numbers in $[0,1]$ which possess decimal expansion not containing the digit $5$ has measure zero. How do I approach this? I tried thinking of relating this to Cantor set but, I see that numbers whose decimal expansion contains the digit $5$ are both contained in the Cantor set as well in its complement too, I thought if it was in the Cantor set and since measure of Cantor set is zero, so it's measure will be zero but this does not happen. In fact how is this set measurable? Any idea?
124264
I have below inputs with huge number of rows  11|ABCD|19900101123123445455|555|AAA|50505050|0000009030 11|ABCD|19900101123123445455|555|AAA|50505050|0000000199 13|ABCD|201803010YYY66666666|600|ETC|20180300|0000084099 11|ABCD|19900101123123445455|555|AAA|50505050|0008995001   And I need to get below output  11|ABCD|19900101123123445455|555|AAA|50505050|9004230 13|ABCD|201803010YYY66666666|600|ETC|20180300|84099   I have been trying with below awk but having too limited knowledge with arrays.  cat test|awk -F"|" '{ a[$1]++;b[$2]++;c[$3]++;d[$4]++;e[$5]++;f[$6]+=$6 }; END { for (i in a); print i, f[i]}'   I need to sum last column of column number 6 and print all first 5 columns, which are separated by pipe and last 6th column as sum of 6th column.