Re: Data structure for plotting monotonically expanding data set

2021-06-05 Thread Martin Di Paola
One way to go is using Pandas as it was mentioned before and Seaborn for plotting (built on top of matplotlib) I would approach this prototyping first with a single file and not with the 1000 files that you have. Using the code that you have for parsing, add the values to a Pandas DataFrame

Re: Data structure for plotting monotonically expanding data set

2021-06-04 Thread Chris Nyland
I agree with dn. While you could scrape the text files each time you want to display a user from a design perspective it makes more sense to use a database to store the data. This doesn't mean that you need to get rid of the text files or change the format that they are written to but instead that

Re: Data structure for plotting monotonically expanding data set

2021-05-27 Thread dn via Python-list
On 27/05/2021 21.28, Loris Bennett wrote: > Hi, > > I currently a have around 3 years' worth of files like > > home.20210527 > home.20210526 > home.20210525 > ... > > so around 1000 files, each of which contains information about data > usage in lines like > > namekb > alice 1

Re: Data structure for plotting monotonically expanding data set

2021-05-27 Thread Peter J. Holzer
On 2021-05-27 11:28:11 +0200, Loris Bennett wrote: > I currently a have around 3 years' worth of files like > > home.20210527 > home.20210526 > home.20210525 > ... > > so around 1000 files, each of which contains information about data > usage in lines like > > namekb > alice 1

Re: Data structure for plotting monotonically expanding data set

2021-05-27 Thread Edmondo Giovannozzi
Il giorno giovedì 27 maggio 2021 alle 11:28:31 UTC+2 Loris Bennett ha scritto: > Hi, > > I currently a have around 3 years' worth of files like > > home.20210527 > home.20210526 > home.20210525 > ... > > so around 1000 files, each of which contains information about data > usage in lines

Re: Data-structure for multiway associativity in Python

2018-01-28 Thread Steven D'Aprano
On Sun, 28 Jan 2018 14:48:02 -0800, qrious wrote: > First list = { 1, 2, 3} > Second list = { 4, 5, 6} > Third list = { 7, 8, 9} > > If I pass 9 as the argument, the return value of the function would be > {7, 8}. subsets = [{1, 2, 3}, {4, 5, 6}, {7, 8, 9}] data = {} for subset in subsets:

Re: Data-structure for multiway associativity in Python

2018-01-28 Thread qrious
On Sunday, January 28, 2018 at 7:00:38 AM UTC-8, Steven D'Aprano wrote: > > Since you specified that there are no lists with shared members, why > bother returning a list of lists? There will only ever be a single > matching list. > That's correct. It will be a single list. My mistake in typi

Re: Data-structure for multiway associativity in Python

2018-01-28 Thread Steven D'Aprano
On Sat, 27 Jan 2018 10:01:47 -0800, qrious wrote: > I need a data structure and a corresponding (hopefully fast) mechanism > associated with it to do the following. While I am looking for the > concept first, my preference for implementation of this will be in > Python. > > [c1, c2,..., cn] is a

Re: Data-structure for multiway associativity in Python

2018-01-27 Thread MRAB
On 2018-01-27 18:01, qrious wrote: I need a data structure and a corresponding (hopefully fast) mechanism associated with it to do the following. While I am looking for the concept first, my preference for implementation of this will be in Python. [c1, c2,..., cn] is a list of strings (for m

Re: Data-structure for multiway associativity in Python

2018-01-27 Thread Dan Stromberg
It's possible, but not common, to do association lists in Python. They're pretty inefficient in just about any language. I'm not totally clear on what you need, but it might be a good thing to do a list of sets - if you're looking for an in-memory solution. On Sat, Jan 27, 2018 at 10:33 AM, Denni

Re: data structure

2017-06-15 Thread Andrew Zyman
Paul Thank you. In my case all "members" of a data structure are classes (except of the id). I showed the classes to highlight the requirement to access their methods as vs simple data types. I think dict of lists should work. Ideally , I hoped to access by name ( vs index), but list will do for n

Re: data structure

2017-06-15 Thread Paul Barry
Hi Andrew. You start by talking about a data structure, then show code that uses "class". Not everything in Python needs to be in a class. I'd look at using a simple Dictionary of lists, indexed on your ID. A list can contain anything, so you can add your objects in there dynamically as needed.

Re: data structure

2017-06-14 Thread Frank Millman
"Andrew Zyman" wrote in message news:caprckxktozonlak8asizonkypd9y_p25fr2rkfkozxoa4bc...@mail.gmail.com... Hello, i wonder what would be a proper data structure for something with the following characteristics: id - number, obj[a..c] - objects of various classes the idea is to be able to upd

RE: Data structure question

2013-11-17 Thread Joseph L. Casale
> How about two dictionaries, each containing the same tuples for > values? If you create a tuple first, then add it to both dicts, you > won't have any space-wasting duplicates. Thanks guys. -- https://mail.python.org/mailman/listinfo/python-list

Re: Data structure question

2013-11-17 Thread Dave Angel
On Mon, 18 Nov 2013 02:03:38 +, "Joseph L. Casale" wrote: I have a need for a script to hold several tuples with three values, two text strings and a lambda. I need to index the tuple based on either of the two strings. Normally a database would be ideal but for a self-contained script

RE: Data structure question

2013-11-17 Thread Joseph L. Casale
> Not entirely sure I understand you, can you post an example? > > If what you mean is that you need to locate the function (lambda) when > you know its corresponding strings, a dict will suit you just fine. > Either maintain two dicts for the two separate strings (eg if they're > "name" and "loca

Re: Data structure question

2013-11-17 Thread Ned Batchelder
On Sunday, November 17, 2013 9:03:38 PM UTC-5, Joseph L. Casale wrote: > I have a need for a script to hold several tuples with three values, two text > strings and a lambda. I need to index the tuple based on either of the two > strings. Normally a database would be ideal but for a self-contained

Re: Data structure question

2013-11-17 Thread Chris Angelico
On Mon, Nov 18, 2013 at 1:03 PM, Joseph L. Casale wrote: > I have a need for a script to hold several tuples with three values, two text > strings and a lambda. I need to index the tuple based on either of the two > strings. Normally a database would be ideal but for a self-contained script > that

Re: Data structure question

2013-11-17 Thread Tim Chase
On 2013-11-18 02:03, Joseph L. Casale wrote: > I have a need for a script to hold several tuples with three > values, two text strings and a lambda. I need to index the tuple > based on either of the two strings. Normally a database would be > ideal but for a self-contained script that's a bit much

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-22 Thread Vlastimil Brom
2010/9/19 Dennis Lee Bieber : > On Sat, 18 Sep 2010 23:00:25 +0200, Vlastimil Brom > declaimed the following in > gmane.comp.python.general: > >> Thank you very much for detailed hints, I see, I should have mention >> the specification with my initial post... >> It is true, that nested tags of the

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-18 Thread Vlastimil Brom
2010/9/18 Dennis Lee Bieber : > On Sat, 18 Sep 2010 10:48:44 +0200, Vlastimil Brom > declaimed the following in > gmane.comp.python.general: > >> >> http://mail.python.org/pipermail/python-list/2008-May/540773.html >> >        Ah, based on that listing you are not worried about embedded tags; > yo

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-18 Thread Vlastimil Brom
2010/9/18 Dennis Lee Bieber : > On Fri, 17 Sep 2010 10:44:43 +0200, Vlastimil Brom > declaimed the following in > gmane.comp.python.general: > > >> Ok, thanks for confirming my suspicion :-), >> Now I have to decide whether I shall use my custom data structure, >> where I am on my own, or whether

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-17 Thread Vlastimil Brom
2010/9/17 MRAB : > On 17/09/2010 00:56, Vlastimil Brom wrote: >> >> 2010/9/17 MRAB: >>> >>> On 16/09/2010 23:11, Vlastimil Brom wrote: ... I put together some code, which works as expected, but I suspect somehow, that there must be better ways of doing it. Two things I

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-16 Thread MRAB
On 17/09/2010 00:56, Vlastimil Brom wrote: 2010/9/17 MRAB: On 16/09/2010 23:11, Vlastimil Brom wrote: ... I put together some code, which works as expected, but I suspect somehow, that there must be better ways of doing it. Two things I am not quite clear about are using the placeholders for

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-16 Thread Vlastimil Brom
2010/9/17 MRAB : > On 16/09/2010 23:11, Vlastimil Brom wrote: >> >>... >> I put together some code, which works as expected, but I suspect >> somehow, that there must be better ways of doing it. >> >> Two things I am not quite clear about are using the placeholders for >> the data identifiers and "

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-16 Thread MRAB
On 16/09/2010 23:11, Vlastimil Brom wrote: Hi all, I'd like to ask for suggestions regarding suitable datastracture for storing textual metadata along with a plain text string. The input format I have is simply text with custom tags like; I'd prefer to have this human readable format the original

Re: Data structure recommendation?

2008-04-18 Thread bearophileHUGS
Jochen Schulz: > Could you please send me an email with an existing From: address? I > tried to reply to you but apparently your From: is forged. Sorry for the delay, I'll send you an email. In the meantime I have created a fast BK-tree implementation for Psyco, on my PC it's about 26+ times faste

Re: Data structure recommendation?

2008-04-10 Thread Jochen Schulz
* [EMAIL PROTECTED]: > > Please plug such good things. It seems the Python community is an > endless source of interesting modules I didn't know about. Your > (single) module looks very nice. I'll take a better look later. Could you please send me an email with an existing From: address? I tried

Re: Data structure recommendation?

2008-04-09 Thread Tim Roberts
"Steven Clark" <[EMAIL PROTECTED]> wrote: > >Thanks for the reply. Can you explain how I could be bitten by >floating point precision here? >I'm familiar with how&why 1.3*3 != 3.9, etc., but I'm not sure how it >applies here, or what you are gaining by converting to int. Well, it depends on how yo

Re: Data structure recommendation?

2008-04-09 Thread Steven Clark
> > I believe the best way to implement this would be a binary search > > (bisect?) on the actual times, which would be O(log N). Though since > > they are timestamps they should be monotonically increasing, in which > > case at least you don't have to go to the expense of sorting them. > > > > "So

Re: Data structure recommendation?

2008-04-08 Thread bearophileHUGS
More bits from your code: neighbours = list() ==> neighbours = [] If you have a recent enough version of Python you can use: candidate_is_neighbour = any(distance < n[1] for n in neighbours) Instead of: candidate_is_neighbour = bool([1 for n in neighbours if distance < n[1]]) It's shorter & simp

Re: Data structure recommendation?

2008-04-08 Thread bearophileHUGS
Few more notes on the code: You may use the @property in such situations (or you may just use attributes, dropping the property). Note that Python doesn't inline functions calls like Java HotSpot does quite often. def __children(self): raise NotImplementedError() children = propert

Re: Data structure recommendation?

2008-04-08 Thread bearophileHUGS
Jochen Schulz: > This solution may be more than you actually need, but I implemented two > metric space indexes which would do what you want (and I wanted to plug > it anyway :)): Please plug such good things. It seems the Python community is an endless source of interesting modules I didn't know

Re: Data structure recommendation?

2008-04-08 Thread Steven Clark
> bisect is definitely the way to go. You should take care with > floating point precision, though. One way to do this is to choose a > number of digits of precision that you want, and then internally to > your class, multiply the keys by 10**precision and truncate, so that > you are working

Re: Data structure recommendation?

2008-04-08 Thread Jochen Schulz
* Steven Clark: > Hi all- > > I'm looking for a data structure that is a bit like a dictionary or a > hash map. In particular, I want a mapping of floats to objects. > However, I want to map a RANGE of floats to an object. This solution may be more than you actually need, but I implemented two me

Re: Data structure recommendation?

2008-04-07 Thread Paul McGuire
On Apr 7, 3:58 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > > I believe the best way to implement this would be a binary search > (bisect?) on the actual times, which would be O(log N). bisect is definitely the way to go. You should take care with floating point precision, though. One way to do

Re: Data structure recommendation?

2008-04-07 Thread Charles Mason
If you can imply a partial order on your ranges then you can get O(n lg n) random access using a heap data structure. You'll have to implement your own heap, but heap search is easy to implement (it's Heapify that might require a little thinking). This will only work, of course, if your ranges ar

Re: Data structure recommendation?

2008-04-07 Thread Steve Holden
Steven Clark wrote: > Hi all- > > I'm looking for a data structure that is a bit like a dictionary or a > hash map. In particular, I want a mapping of floats to objects. > However, I want to map a RANGE of floats to an object. > > This will be used for timestamped storage / lookup, where the floa

Re: Data structure recommendation?

2008-04-07 Thread Martin v. Löwis
> I know that foo.get() will be called many times for each foo.put(). Is > there any way to achieve O(1) performance for foo.get(), maybe via > some kind of hash function? Or is the best thing to use some kind of > binary search? If you know something about the density of the input values, O(1) is

Re: Data structure and algorithms

2007-01-29 Thread Beej
On Jan 29, 10:15 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > The instructor learned his lesson: no more assignments > done in "any language I can understand" Without naming names, there was a person at my university who gained a certain amount of notoriety by implementing a file system fo

Re: Data structure and algorithms

2007-01-29 Thread Beej
On Jan 29, 1:50 pm, "azrael" <[EMAIL PROTECTED]> wrote: > thanks guys. i see that there is no way then to go back to C to > satisfy my prof and get a grade Seconding what Dennis says below, it is totally possible to use Python for this. I didn't mean to discourage you from using Python--I just w

Re: Data structure and algorithms

2007-01-29 Thread azrael
thanks guys. i see that there is no way then to go back to C to satisfy my prof and get a grade -- http://mail.python.org/mailman/listinfo/python-list

Re: Data structure and algorithms

2007-01-29 Thread Beej
On Jan 28, 2:56 pm, "azrael" <[EMAIL PROTECTED]> wrote: > class Node: > def __init__(self, cargo=None, next=None): > self.cargo = cargo > self.next = next This is OK for the node itself, but maybe you should try writing a LinkedList class that you use: class LinkedList(object): de

Re: Data structure and algorithms

2007-01-29 Thread Steve Holden
Terry Reedy wrote: > "azrael" <[EMAIL PROTECTED]> wrote in message [...] > | > | but this was not dinamicly enough for me (or my prof.) so > > dynamic? I have no idea what you mean by 'not dynamic enough'. > > Python is not C or C++. It does not have pointers. Trying to program in C > in Pyt

Re: Data structure and algorithms

2007-01-28 Thread Diez B. Roggisch
azrael schrieb: > i'd like to get more control like in c with pointers. I want to loose > the data after disabling: > list=[] list.append(Node(1)) list.append(Node(2)) list[0].next=list[1] > > > 1, 2 > > list.append(Node(3)) list[1].next=list[2] > > > 1,2

Re: Data structure and algorithms

2007-01-28 Thread Terry Reedy
"azrael" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Hy, i am a student and in 2 days I am writing a test in data | structures and algorithms. I've done my homework and understood all | the implementations and structures. My profesor was so kind to allow | us to use any programi

Re: Data structure and algorithms

2007-01-28 Thread azrael
i'd like to get more control like in c with pointers. I want to loose the data after disabling: >>> list=[] >>> list.append(Node(1)) >>> list.append(Node(2)) >>> list[0].next=list[1] 1, 2 >>> list.append(Node(3)) >>> list[1].next=list[2] 1,2,3 >>> list[0].next=list[2] 1,3

Re: Data structure and algorithms

2007-01-28 Thread Jonathan Curran
What are you trying to make in the first place? A singly linked list? If so google is littered with examples of linked lists done in python. A simple search for 'python linked list' brings up many results. Btw, for future reference, no need for apologetics (the second post). - Jonathan -- http

Re: Data structure and algorithms

2007-01-28 Thread azrael
I'm not a kid who heard that Python is simple, so he wants to use it and throw it away. I discovered it about 2 months ago, and I learnt it better then c in 2 years. I want to use python for this test because i love it. I am amazed about what i can do i such little time. My god, I even printed

Re: Data structure for ordered sequence

2006-11-16 Thread Fredrik Lundh
robert wrote: >>> how many rectangles do you plan to store in this structure? > >> Around 150 max > > And seeking/change frequency? fix dimensions? Probably for a GUI/mouse thing. > =>Not worth worring about a 2D-tree structure. A Python list ? :-) > Insert/change coordinates at no costs and s

Re: Data structure for ordered sequence

2006-11-16 Thread robert
[EMAIL PROTECTED] wrote: > Fredrik Lundh wrote: >> [EMAIL PROTECTED] wrote: >> >>> I am looking for a data structure to hold rectangles in a 2d space. >>> Please point me to any module which does these operations: >>> Insert a rectangle into a particular co-ordinate. >>> Get the rectangle/s righ

Re: Data structure for ordered sequence

2006-11-14 Thread Steve Holden
Hendrik van Rooyen wrote: > "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > > >> [EMAIL PROTECTED] wrote: >> >> > unless this is homework because the pil people will not let >>> you distribute pils. >> I'm not sure I can parse this sentence fragment. What do you mean? > > oh come on! - you of all

Re: Data structure for ordered sequence

2006-11-14 Thread Hendrik van Rooyen
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > unless this is homework because the pil people will not let > > you distribute pils. > > I'm not sure I can parse this sentence fragment. What do you mean? oh come on! - you of all people should know that "pils" mean

Re: Data structure for ordered sequence

2006-11-13 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > I am looking for a data structure to hold rectangles in a 2d space. > > Please point me to any module which does these operations: > > Insert a rectangle into a particular co-ordinate. > > Get the rectangle/s right/left/above/below side to a

Re: Data structure for ordered sequence

2006-11-13 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I am looking for a data structure to hold rectangles in a 2d space. > Please point me to any module which does these operations: > Insert a rectangle into a particular co-ordinate. > Get the rectangle/s right/left/above/below side to a particular > rectangle. > Get a

Re: Data structure for ordered sequence

2006-11-13 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > unless this is homework because the pil people will not let > you distribute pils. I'm not sure I can parse this sentence fragment. What do you mean? -- http://mail.python.org/mailman/listinfo/python-list

Re: Data structure for ordered sequence

2006-11-13 Thread [EMAIL PROTECTED]
There are probily better ways to do this. The pil library has a rectangle drawing feature, I would check through the docs of wxwindows and tkinter unless this is homework because the pil people will not let you distribute pils. I am going to be looking for the same think let me know if you get a

Re: data structure

2006-09-03 Thread Jason
noro wrote: > Hello again. > > I have a task i need to do and i can't seem to find an elegent > solution. > i need to make a tree like data structure (not necessry a binary tree). > > > i would like each node to access his sons in a dicionary kind of why, > for example: if ROOT node has the name '

Re: Data Structure in Python like STL Stack?

2005-11-28 Thread Fredrik Lundh
Matt Keyes wrote: > Is there a data structure in Python that is akin to the STL stack > object in C++? >>> import collections >>> help(collections.deque) ... class deque(__builtin__.object) | deque(iterable) --> deque object | | Build an ordered collection accessible from endpoints only.

Re: Data Structure in Python like STL Stack?

2005-11-28 Thread Matt Keyes
I didn't know the list has a pop function - that is what I was looking for.   Thanks for the help![EMAIL PROTECTED] wrote: What property of the STL stack is important to you?You can use a Python list as a stack. It has methods append() andpop() which run in amortized-constant-time. It can be tested

Re: Data Structure in Python like STL Stack?

2005-11-28 Thread jepler
What property of the STL stack is important to you? You can use a Python list as a stack. It has methods append() and pop() which run in amortized-constant-time. It can be tested for empty/nonempty in constant time too (if st: # stack is not empty). Jeff pgpU1CCrfIPhk.pgp Description: PGP sig