Questions tagged "python" (page No.1)

Plotting two arrays of different lengths

So I have some data import pyfits import matplotlib.pyplot a = pyfits.getdata('data.fits') x = a['time'] y = a['flux'] I had a issue with some data where my arrays contained NaN values. To get rid of them, I did the following: x = x[numpy.logical_not(numpy.isnan(x))] y = y[numpy.logical_not(numpy.isnan(y))] Which removes all NaN values from the arrays x and y. The problem ...

use python to modify specific columns in csv

I have a bunch of data in a .csv like this: -959.378170,-0.000026,-94.960000,1508.000000,9.000000, -958.978170,-0.000026,-94.920000,1508.000000,9.000000, -958.578170,-0.000026,-94.880000,1508.000000,10.000000, -958.178170,-0.000026,-94.840000,1508.000000,10.000000, -957.778170,-0.000026,-94.800000,1508.000000,10.000000, The last two columns are supposed to be time. 15 is the hour, 08 is the minute, 6 is the second. The end goal is to join them so that I get something like: -958.978170,-0.000026,-94.920000,15:08:09, -958.578170,-0.000026,-94.880000,15:08:10, How can I do that? ...

How to make a python Package?

Here is my structure, main.py folder1\ button.py folder2\ picturebutton.py folder3\ listbox.py folder4\ customlistbox.py folder5\ ...

deploying IronPython script or static building an application

I created an IronPython script that imports from Python libraries, such as os, sys, etc. as well as .NET libraries. It runs perfectly fine from my Visual Studio IronPython solution but I need to deploy this so other people who don't have IronPython or Python installed can run it. How would I ...

I'm trying to use a @classmethod with filter() in ndb and receiving a error. NDB newbie

I have a custom User model with this classmethod.: @classmethod def by_name(cls, name): u = User.query().filter('name =', name).get() return u And I am getting this error.: TypeError('Cannot filter a non-Node argument; received %r' % arg) This is My first time using NDB and the code worked with db and ...

Why does python seem to allocate more memory than sys.getsizeof accounts for?

Example: import sys class Test(): def __init__(self): self.a = 'a' self.b = 'b' self.c = 'c' self.d = 'd' ...

Pulling the value from parsed XML in Python (only)

I am trying to pull a value (only) from some XML in Python using Beautiful Soup (but I'll gleefully dump it for anything else if recommended). Consider the following bit of code; global humidity, temperature, weatherdescription, winddescription query = urllib2.urlopen('http://www.google.com/ig/api?weather="Aberdeen+Scotland"') weatherxml = query.read() weathersoup = BeautifulSoup(weatherxml) query.close() print weatherxml This prints out the weather forecast for ...

Matplotlib: How to convert a histogram to a discrete probability mass function?

I have a question regarding the hist() function with matplotlib. I am writing a code to plot a histogram of data who's value varies from 0 to 1. For example: values = [0.21, 0.51, 0.41, 0.21, 0.81, 0.99] bins = np.arange(0, 1.1, 0.1) a, b, c = plt.hist(values, bins=bins, normed=0) plt.show() The code above generates a ...

My code doesn't run properly, what is wrong in there?

hand = ['A','Q'] points = 0 player_cards1 = ['2'] value1 = 2 player_cards2 = ['3'] value2 = 3 player_cards3 = ['4'] value3 = 4 player_cards4 = ['5'] value4 = 5 player_cards5 = ['6'] value5 = 6 player_cards6 = ['7'] value6 = 7 player_cards7 = ['8'] value7 = 8 player_cards8 = ['9'] value8 = 9 player_cards9 = ['T'] value9 = 10 player_cards10 = ['Q'] value10 = 10 player_cards11 = ['K'] value11 = 10 player_cards12 = ...

Python: pyplot - plot smooth curves with less clutter and show data points on the curve

I have three lists of float values and each of these lists are pretty lengthy For example each has 250-300 elements. I managed to plot using following code but unfortunately its really hard to read after putting all these lists in one plot. Here is sample of my list: list1 = ...

Initializing logger in python unit test

import logging class TestMyClass(unittest.TestCase): def __init__(self): self.logger = logging.getLogger('MyClassLog') def setUp(self): I am trying to instantiate the logger in the constructor. But I get this error: ...

Python: list.sort() doesn't seem to work

>>> x = set(['216', '217', '214', '215', '212', '213', '210', '211', '165', '264', '218', '219', '133', '132', '131', '130', '137', '136', '135', '226', '139', '138', '166', '24', '25', '26', '27', '20', '21', '22', '23', '95', '28', '29', '222', '288', '346', '4', '161', '8', '163', '348', '119', '868', '258', '120', '121', ...

pymongo how to query nested document to ignore the key but get its value?

I have a documents inserted in mongoDB in the format as below {'Name':{'Surname':{'JON':{'AGE':10}}}} in the example above i want to build a query to ignor the 'JON' but fetch AGE value of all users i tried like db.names.find({'Name.Surname':{$regex:'.'}}) but didn't work.... What i am looking for is something like db.names.find({'Name.Surname.<matchanything>.AGE':{$gt:0}}) Please help me on the same. Thanks in ...

Celery import and SQS connection issue

I'm trying to follow the documentation to get started with celery, but running into hard to debug problems with the sample code. I can't tell if I'm hitting two sides of the same problem, or two unique problems. I can make a connection to the SQS queue through ...

Why combine np.floor function and the // operator in Python?

I am reading the source code of the library 'scikits-image' written in Python, I found the next line of code: n_cellsx = int(np.floor(sx // cx)) I don't know why they join the NumPy function floor and the // operator. Is there any reason to do this? I can't see. I feel ...

how to assign a list of values to a python netcdf4 variable object?

I am trying to use the netCDF4 package with python. I want to do something which I think should be straightforward, but I can't make it work and I can't find any documentation on it. I have a list, and I simply want to store the list in ...

How do I open Excel Application using xlrd or xlwt?

I know I can open MS Excel application using win32com by setting Visible to true Can I use xlrd or xlwt do the same? ...

How to use AddSubclassFactory from wxPython?

I cant find any examples online on how to use this method. I think that It may be something that I will use. Can someone provide me an example on how to use this method? http://wxpython.org/docs/api/wx.xrc.XmlResource-class.html ...

« Previous12345678910 ... 62996300Next »Show All