473,382 Members | 1,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Re: Multipart - Counting the amount of Values for One key

En Fri, 29 Aug 2008 14:41:53 -0300, Ron Brennan <br*********@gmail.com>
escribi�:
I am trying to find the amount of values there are pertaining to one key.

For example:

- To find the average of the values pertaining to the key.
- Use the amount of values to calculate a histogram
What is a "multipart"? I know MIME multipart messages but they don't seem
to apply here...
From your other posts I think you're talking about a dictionary mapping
each key to a list of values.
So the values are contained inside a list. It doesn't matter *where* you
store that list, or *how* you get access to it. You have a list of values
- that's all.
Average values (asuming they're all numbers):

def avg(values):
# what to do with an empty list?
return float(sum(values))/len(values) # float() to avoid integer division

There are many libraries that provide histogram support, but using the
bisect module may be enough:

pyfrom random import randrange
pyfrom bisect import bisect
py>
pydata = [randrange(100)+randrange(100) for i in range(1000)]
pybins = range(0, 200, 20) # 0, 20, 40..180
pycounts = [0]*len(bins)
pyfor point in data:
.... bin = bisect(bins, point)-1
.... counts[bin] += 1
....
pyfor bin, count in zip(bins,counts):
.... print bin, count
....
0 16
20 71
40 107
60 140
80 170
100 180
120 148
140 110
160 43
180 15
Also, how do reference a specific value for a key in a multipart?
It's just a list: the third value is values[2], the last one is
values[-1]...

--
Gabriel Genellina

Aug 29 '08 #1
1 1177
In article <ma*************************************@python.or g>,
Gabriel Genellina <ga*******@yahoo.com.arwrote:
>En Fri, 29 Aug 2008 14:41:53 -0300, Ron Brennan <br*********@gmail.com>
escribi�:
>I am trying to find the amount of values there are pertaining to one key.

For example:

- To find the average of the values pertaining to the key.
- Use the amount of values to calculate a histogram

What is a "multipart"? I know MIME multipart messages but they don't seem
to apply here...
From your other posts I think you're talking about a dictionary mapping
each key to a list of values.
So the values are contained inside a list. It doesn't matter *where* you
store that list, or *how* you get access to it. You have a list of values
- that's all.
Aug 30 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Willoughby Bridge | last post by:
Hi - Having trouble getting a multipart series of forms to move to the next form. The problem line is: <form method="post" enctype="multipart/form-data" action="Data_Form1.php"> If the...
1
by: Lord Merlin | last post by:
How do I add up the values of the data from all of the rows returned? i.e - I have a DB, with 148 rows of client info, and I want to addup all the scores. Each entry's score differes. Here is the...
4
by: Jay | last post by:
I'm trying to build a pretty complex form that submits to an email, but am having problems with a certain bunch of funcionality in it... Have a look at this example page......
7
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem...
0
by: scottf35 | last post by:
Hi, I am working on (read that - upgrading) an application. This application creates an HTTPWebRequest object, populates it with values which are then sucked out of the Request.Form object (eg...
4
by: pbd22 | last post by:
hi. could somebody tell me, when uploading a file, i know the form where the upload component is must have enctype=multipart/form-data but, is the same true for the form with the server code to...
26
by: Michael R | last post by:
Hi all. This is an SQL question, so I hope this is the right place to ask it. I'm intersted in "compressing" a table to distinct values of a field or several fields, and having another field...
3
by: Jamie88 | last post by:
This program is for a machine wich gives out coins up to the value of £4.99 using the minimun number of coins, but i'm i really having trouble gettin this to work. Any help would really be...
4
by: virtualweb | last post by:
Not able to pass variables data: Hello .. Im building a form that uploads files with encType="multipart/form-data" but on the same form I need to pass other variables with hidden fields. The...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.