Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #110318
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Jignesh Sutar <jsutar@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Summary grid |
| Date | Wed, 22 Jun 2016 14:46:35 +0000 |
| Lines | 29 |
| Message-ID | <mailman.40.1466606829.11516.python-list@python.org> (permalink) |
| References | <CACvW2fz29iNOxe0E0ZrqZU7=ov6s0VZbB_2bLFG37WqgOZEPrw@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de /ZZ+coE7znQnuifvYJxAhQ8tjIvYvALz3NqOgTaT72PQ== |
| Return-Path | <jignesh.sutar@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'data:': 0.07; '[1,': 0.09; 'grid': 0.09; 'rows': 0.09; '"d",': 0.16; '0],': 0.16; '[2,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Summary': 0.16; 'example': 0.26; 'entered': 0.27; 'message-id:@mail.gmail.com': 0.27; 'summary': 0.29; 'print': 0.30; 'code': 0.30; 'skip:[ 10': 0.31; 'this?': 0.34; 'list': 0.34; 'skip:& 20': 0.35; 'received:google.com': 0.35; 'could': 0.35; 'received:74.125.82': 0.35; 'item': 0.35; 'to:addr:python- list': 0.36; 'skip:& 10': 0.37; 'say': 0.37; 'thanks': 0.37; 'data': 0.39; 'to:addr:python.org': 0.40; 'skip:\xc2 10': 0.67 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=J0sYFEDhDY8q8yM/d1Cxb3KzkoQ5hMEhYIG8B89J5sg=; b=Mqk9LEHAE2KeR9j/GCaiJFMQEeb7k2Iu9IDKIUqSOnYmDD2rQrxXOVu0pFmVAqdYAQ cnEAjvT4z0RsJ80KiwtgGbROXKBADyeY3ix/nRJH7RQbMmJn3DgNZh0LOH3xifCh2iLT FkgbvWiXU/O/4mtUULvxWi+le5prr+DKuPXlLJ7wwy7Uhjc1b3+H8ID4FTnFimITB89g Ffw+QpVjFCCy9U+jYvRZblNFuYDAtflFkxEm8JbNBVIX75FFrDtshbVvvoGKP/BjqjoP ick0LTcZPt4oEsSqu/Asc7/WuHNzx+qp7vNJoH/sQrI24cWHjNMrC7688TPnS4HoSxY1 dI+A== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=J0sYFEDhDY8q8yM/d1Cxb3KzkoQ5hMEhYIG8B89J5sg=; b=iSYDa2iywXTWQxWMnhCUCmLMyZIZ4CRzxmQRVLo7Cg5rKqllTMNVORuzztbTIc39Z8 UXKQ/QCX2fNielVMxuGXWoguEgp87hAs9iR8CFko/HXdqISEz7yPRvJpOwKGiyvpUBt7 2zYg/0sGlbPDnNpHmDhY0JKWOYYeo1ePIO9bm62DMbfcdf+Fswj6/4MFpgECUOGqCe6Y NBFTbTE8wmlhNv2kHKWwBv60O8Tq6eaYdiMZLhEgP5OubpTTbe/TpqDbF6WoI9jw0dfZ Sm16W4vQRX4lPfarEGZGJ7si51ShZpf0q7ahxKTdREyRPPQyCMZFqS6wZF4J5/0uMu5m Iwbw== |
| X-Gm-Message-State | ALyK8tKHWI5Bls0+/UQOKDhkKPwMmmcdjHH2+kkZ21B7bBggK7x+bjoAfF1N+xgXGiurd4GrSzrOB+jOZvW7dg== |
| X-Received | by 10.194.82.36 with SMTP id f4mr25593770wjy.104.1466606805803; Wed, 22 Jun 2016 07:46:45 -0700 (PDT) |
| X-Mailman-Approved-At | Wed, 22 Jun 2016 10:47:08 -0400 |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.22 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| 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> |
| X-Mailman-Original-Message-ID | <CACvW2fz29iNOxe0E0ZrqZU7=ov6s0VZbB_2bLFG37WqgOZEPrw@mail.gmail.com> |
| Xref | csiph.com comp.lang.python:110318 |
Show key headers only | View raw
Say I have list of data as given in the example code below, I want to find
all the unique categories (alphabetic letters) and unique IDs (numbers) and
then produce a summary grid as manually entered in the "results". How could
I code this?
Many thanks in advance,
Jignesh
data= ["A.1", "A.2", "A.3", "B.1", "C.2", "C.3", "D.4", "E.5", "E.6"]
cols=[]
rows=[]
for item in data:
i=item.split(".")
if i[0] not in cols: cols.append(i[0])
if i[1] not in rows: rows.append(i[1])
print cols
print rows
results=
[["Row/Col", "A", "B", "C", "D", "E"],
[1, 1, 1, 0, 0, 0],
[2, 1, 0, 1, 0, 0],
[3, 1, 0, 1, 0, 0],
[4, 0, 0, 0, 1, 0],
[5, 0, 0, 0, 0, 1],
[6, 0, 0, 0, 0, 1]]
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Summary grid Jignesh Sutar <jsutar@gmail.com> - 2016-06-22 14:46 +0000 Re: Summary grid Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-06-22 18:43 +0300
csiph-web