- Strength to Increase Rep
- +7
- Strength to Decrease Rep
- -1
- Upvotes Received
- 17
- Posts with Upvotes
- 14
- Upvoting Members
- 11
- Downvotes Received
- 2
- Posts with Downvotes
- 2
- Downvoting Members
- 2
134 Posted Topics
Re: You need to post an attempted effort before anyone will help you with homework. | |
Re: Your best bet is to load all the datafiles into a pandas dataframe. This is the de-facto structure for handling labeled array data, and also has a ton of utilities for data manipulation ESPECIALLY timestamp. post an example of one of your files, maybe the first 30 lines, including header, … | |
Re: The cached property is definatly the best suggestion. If not using that, I would get in the habit of using try: except in these situations. That is syntactially simple and very common, so others reading your code will be able to deduce your intent from the code. | |
Re: Look at python library collections, particularlu the Counter class. | |
Re: I can't really digest the entirety of your code just by looking at it, but another thing you might wanna look into is the polymonial support in numpy. There are some functions, mostly for fitting polynomicals of Nth order to other curves, that might be useful to you. For example: … | |
Re: outstring=' '.join([str(i) for i in range(0,105,5)]) file.write(outstring) Also, it's a good habit not to use the word "file" as this is a python reserved file. I'd recommend outfile or just o. | |
Re: If you use numpy, then you want to avoid iterating item by item. In fact, the whole reason to use numpy, is that you don't have to do this. If you do do this, you get no speed increase over plain python (the speed increase is about 1000-fold btw). You … | |
Re: Can you elaborate on this, your question isn't clear to me. | |
Hi guys, This feels like something that should be possible in Python, and something that I feel like I should know how to do. Image I have a list of numbers: items=[10,20,30] Let's say I wanted iterate over them and define two new variables, a and b. a=[] b=[] for … | |
Re: Can you put all the zipped values into its own list. `allvalues=[zip(ar1.values, br1.values, ar0.values, br0.values), zip(ar2.values, br2.values, ar1.values, br1.values) ... etc]` Then iterate over just this: for zippedvals in allvalues: for w,x,y,z in zippedvals: val = (sqrt((w.data**2)+(x.data**2)))-(sqrt((y.data**2)+(z.data**2))) files[0].write(('%6.20f\n') % (val)) | |
Re: Why not just split at "enclosure_url" rather than "title" and keep only the half you want? | |
Re: I noticed a few things. First, there's no reason to put the entire code into a function (eg main). This is fine, but not mandatory. There's a special line at the bottom of your code that you should add so that if this program is called as an import from … | |
Hi guys, I am running a costly simulation and trying to optimize the output. I'd have a fixed range over which the parameter of interest can vary, and about 100 values it can take in between. We know the result we are looking for and want to find the parameter … | |
Hi guys, I've downloaded 2 cached_property implementations from the internet and both did not work correctly for my programs. Does anyone here used a cached_property function that works really well and could share with me? | |
Re: Install ubuntuu. It is a free oerating system, basically virus free and better than windows. | |
Re: Also, python is going to round (9/5) to 2 since these are integers. Get in the habit of using floats: (9.0/5.0) | |
Re: Bump on snippsat's reply... That is almost certainly the way to do it if you ask me. | |
Re: If you're using linux, this may be handled more simply with a bash script. | |
Re: Bump tot he above poster, it is most certainly better to store variables so they may be accessed by attribute (eg movie.director) | |
Hi, I'm having some difficulty reading in boolean values from a file, particularly false values. Python can understand false values as empty strings, as well as a few other ways. For example: In [43]: bool(0) Out[43]: False In [44]: bool(False) Out[44]: False In [45]: bool('') Out[45]: False The problem is, … | |
Re: Are you sure that's something you can do out of the box with the software development kit provided by google? I know google provides a Python scripting layer for Android development, so that might be a good place to start. | |
Hi, I am trying to create the most general function possible to test if an object passed into it has mutability or not. With some prior help from pytony, it seemed that the best way to do this is to try to set and attribute. If the attribute can be … | |
Re: I would starting working with the Enthought Tool Suite. Their TraitsUI (and now the new Enaml framework) are worth investing the time into. They allow for really simple GUI's that are interactive from the door. In your case, it would be as simple as having a checkbox and when the … | |
Re: Well that just blew my mind. Is it actually quicker to define the pali() function than it would be to just put that expression into the generator expression? EG max((a*b, a, b) for a in range(999, 100, -1) for b in range(a, 100000//a, -1) if str(a*b))==str(a*b)[::-1]) I ask because sometimes … | |
Re: Can't you do: list_of_lists=[list(x) for x in list_of_tuples] This should make a list of lists; however, as PyTony said, this step should not be necessary for implicit compatibility w/ numpy. | |
Re: I know that[ HDF5 for python](http://alfven.org/wp/hdf5-for-python/) understands the concept of chunking and may be a good place to start if you're interested in learning more about handling large data. | |
Re: Not sure how to do this but for handling the images, start with PIL (python image library). PyAudio is probably the goto package for handling audio in python and not sure about video. | |
Re: If you're using a unix-based operating system (aka not windows), you can use the subprocess module to execute shell commands. In effect, you would run latex at the command line through Python. http://docs.python.org/library/subprocess.html Looks like you are using windows though so I'm not quite sure. Sorry | |
Re: Don't use "List" as your variable name, this is a reserved python keyword. Try replacing it with something like "mylist". Also, python's list have building count features so you can do something like: for x in mylist: print x, mylist.count(x) | |
Re: I'm working on a package for the management and easy creation of mutable and immutable records. The idea is that we can either use object subclasses (mutable) or modified named tuples (immutable) as well as a bunch of very handy utilities/functions to create a record storage class in python. The … | |
Re: Your function takes an integer, but you are passing in a list. If you print range(0,100), you will see that this is one object; a list of numbers. Instead, you should pass them one by one, or adjust your function to take in a list of numbers. for i in … | |
Hi, I'm curious about a few conventions. If you have a function that can return a or b based on some conditionals, which do you think is the best/accepted notation? def test(val): if val > 10: return a else: return b Or def test(val): if val>10: return a return b … | |
Hi, I have several functions that I'd like to operate on both mutable and immutable containers (mostly tuples vs. objects) and I'm looking for the optimal way to test for mutability in these objects. I can think of many ways to do this. For example: try setattr: do mutable stuff … | |
Re: Can you be specific on where exactly ou need help? | |
Hi, I have an object subclass that I am using with a cusom __repr__() method. class NewClass(object): def __repr__(self): return ', '.join('%s=%s'%(k, v) for (k,v) in self.__dict__.items()) This works fine (leaving out some more details about my program): test=NewClass(a=1,b=2) print test a=1, b=2 But what I really want for reasons … | |
Re: You can download a new python version and run it separately in ubuntu by putting the new call into your path. Don't uninstall your system version, this will mess up the OS (yes python is integral to ubuntu). By default, your system's python exectuable is installed in /usr/bin/. So let's … | |
This post is a followup to an older dicsussion [on recordmanaging](http://www.daniweb.com/software-development/python/code/429753/custom-named-tuples-for-record-storage). I am writing this to share with colleagues, so it may be a bit fluffy and not straight to the point. I apologize to all the experts. Good programs always start by managing data in a flexible and robust … | |
This code was inspired after several discussions on the forum, and I'm especially indebted to PyTony for all of his help with these aspects. The motivation behind this code is quite simple. I wanted a robust, light and general way of storing CSV data that could be used over and … | |
I have a simple class that stores attributes: In [1]: class Test(object): ...: a=10 ...: b=20 I have a function that returns attributes using attrgetter, and it accepts these through the args parameter to allow a user to pass various attribute fieldnames in. For example: In [4]: def getstuff(*args): ...: … | |
Hi, I've been having trouble posting a code snipet tonight, I keep getting this error: The code snippet in your post is formatted incorrectly. Please use the Code button in the editor toolbar when posting whitespace-sensitive text or curly braces. My code is running fine in wingware IDE with 4 … | |
I'd like to make a dictionary subclass that takes in positional keywords in addition to the standard *args, **kwargs. I found this example on stackoverflow: class attrdict(dict): def __init__(self, *args, **kwargs): dict.__init__(self, *args, **kwargs) self.__dict__ = self a = attrdict(x=1, y=2) print a.x, a.y print a['x'] b.x, b.y = 1, … | |
Hi, I think I have a pretty simple question but my google searches are giving me more information than I need. I think my terminology is not clear. Let's say I'm making a dictionary to hold a datatype very specific to some filetype or data of interest. Let's say I … | |
Re: YOu should start using the pandas package. It has explicit support for handling timeseries data and lots of builtin methods to convert. I imagine you're reinventing wheels somewhat. | |
Hi, I have been subclassing namedtuple to handle my custom data type: fields=['Query', 'u1', 'Accession] Old = namedtuple('Old', fields, verbose=False) class New(Old): def __repr__(self): return 'Overwriting works nicely' p=New('Hi',2,3) print p >>> 'Overwriting works nicely' What I want to do is to add the behavior that some of my fields … | |
Hi guys, This is more a general discussion of methodology than a specific question. I have been working on a, the primary purpose of which is to store an oddly formatted data file (aka not you classic CSV). At the end of the day, the data is stored in a … | |
Re: I would definately implement zztucker's idea. The syntax to reverse a list is: a='hi there' print a[::-1] 'ereht ih' In case that was not clear. | |
Hi guys, I was working with the pandas package and was so impressed with how simple something was that I had to share. Have you ever worked with csv data (in excel for example) and wanted to import the data to python, take either a column average or row average, … | |
Re: I'm not quite clear. You're saying you want to be able to open the file on the fly, and based on what you call, it will automatically ignore the first line and column? Or do you want to alter all the files in one go? | |
![]() | Re: Check out the "enaml" project from enthought. This is an example of a scripting language (or maybe a psuedo scripting language, I don't have a deep understanding really) that has been developed over python. What is your motivation for pursuing this end? As the other posters have implied, you may … ![]() |
The End.