Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63804

Re: efficient way to process data

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'output': 0.05; 'string': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rows': 0.09; 'subject:process': 0.09; 'python': 0.11; 'jan': 0.12; '"a"': 0.16; '"x"': 0.16; '>the': 0.16; 'comma': 0.16; 'complicated,': 0.16; 'delimiter': 0.16; 'emit': 0.16; 'equal.': 0.16; 'germane': 0.16; 'grouped': 0.16; 'latter,': 0.16; 'message-id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; '(you': 0.16; 'looked': 0.18; 'app': 0.19; 'basically': 0.19; 'not,': 0.20; 'form:': 0.24; 'specify': 0.24; 'url:home': 0.24; 'together.': 0.24; 'query': 0.26; 'primary': 0.26; 'header:X -Complaints-To:1': 0.27; 'record': 0.27; 'comparison': 0.31; 'decimal': 0.31; 'larry': 0.31; 'probably': 0.32; 'are:': 0.33; 'maybe': 0.34; 'problem': 0.35; 'something': 0.35; 'operate': 0.35; 'but': 0.35; 'subject:data': 0.36; 'doing': 0.36; 'charset :us-ascii': 0.36; 'should': 0.36; 'example,': 0.37; 'two': 0.37; 'received:76': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'even': 0.60; 'numbers': 0.61; 'matter': 0.61; 'strictly': 0.61; 'first': 0.61; 'more': 0.64; 'within': 0.65; '>from': 0.68; 'business': 0.70; 'yourself': 0.78; 'costly': 0.84; 'tolerance': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: efficient way to process data
Date Sun, 12 Jan 2014 17:43:46 -0500
Organization IISS Elusive Unicorn
References <CACwCsY6KBDVkS5jCMh9GyvhHyVgqcAH3YAYnGpMQvfBwexaTcw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-76-249-21-126.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5389.1389566640.18130.python-list@python.org> (permalink)
Lines 54
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389566640 news.xs4all.nl 2859 [2001:888:2000:d::a6]:46647
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63804

Show key headers only | View raw


On Sun, 12 Jan 2014 14:23:17 -0500, Larry Martell <larry.martell@gmail.com>
declaimed the following:

>I have an python app that queries a MySQL DB. The query has this form:
>
>SELECT a, b, c, d, AVG(e), STD(e), CONCAT(x, ',', y) as f
>FROM t
>GROUP BY a, b, c, d, f
>
>x and y are numbers (378.18, 2213.797 or 378.218, 2213.949 or
>10053.490, 2542.094).
>

	Decimal (Numeric) or floating/real. If the latter, the internal storage
may not be exact (378.1811111111 and 378.179999999 may both "display" as
378.18, but will not match for grouping).

>The business issue is that if either x or y in 2 rows that are in the
>same a, b, c, d group are within 1 of each other then they should be
>grouped together. And to make it more complicated, the tolerance is
>applied as a rolling continuum. For example, if the x and y in a set
>of grouped rows are:
>
	As I understand group by, it will first group by "a", WITHIN the "a"
groups it will then group by "b"... Probably not a matter germane to the
problem as you are concerning yourself with the STRING representation of
"x" and "y" with a comma delimiter -- which is only looked at if the
"a,b,c,d" are equal... Thing is, a string comparison is going to operate
strictly left to right -- it won't even see your "y" value unless all the
"x" value is equal.

	You may need to operate using subselects... So that you can specify
something like

	where	abs(s1.x -s2.x) < tolerance or abs(s1.y-s2.y) < tolerance
		and (s1.a = s2.a ... s1.d = s2.d)

s1/s1 are the subselects (you may need a primary key <> primary key to
avoid having it output a record where the two subselects are for the SAME
record -- or maybe not, since you /do/ want that record also output). Going
to be a costly query since you are basically doing

	foreach r1 in s1
		foreach r2 in s2
			emit r2 when...





-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: efficient way to process data Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-12 17:43 -0500

csiph-web