1 answer

How to use Normalized Mutual Information to evaluate overlapping community from igraph in python

Given the increasing popularity of algorithms for overlapping clustering, in particular in social network analysis, quantitative measures are needed to measure the accuracy of a method. I need know …

44 secs ago
0 answers

Joining two lists that correspond to each other to create a list of class objects

I am trying to create a single list that contains the username and password of an unspecified amount of users. I am trying to make this list contain class objects of type "User", which is included ...

1 min ago
0 answers

python requests - POSTing Multipart/form-data without filename in HTTP request

I am trying to replicate the following POST request using the requests module in python: POST /example/asdfas HTTP/1.1 Host: example.com User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) ...

1 answer

What am I doing wrong? - Output to file in python 3.x

Here is some of the code I have - My issue is in the generateTable() function: from arrayheap import ArrayHeap class HuffmanNode(): def __init__(self, ch, freq, left=None, right=None): …

1 answer

403 error when scrapying this website

I am trying to crawl a website this website returns Error, query failed in the body. then I click on Find USED tab. then I click search to get the result. the search button is actually making a post …

4 mins ago
0 answers

Speeding up arithmetic with Python Decimal library

I am trying to run a function that is similar to Google's PageRank algorithm (for non-commercial purposes, of course). Here is the Python code; note that a[0] is the only thing that matters here, and …

1 answer

Pyside QFileDialog.getOpenFileNames how do I get the filename and path as string instead if tuple

This line of code return the filename and path in unicode, I can't used it. How to get only the filename and string? Code: logfile = QFileDialog.getOpenFileNames(None, caption, directory, ...

8 mins ago
1 answer

Send iOS Push Notifications from Google App Engine python

I have been looking everywhere for example code on how to do this from a python written server over GAE - but with no luck. Can someone please help me with the function to do this? (It should be ...

0 answers

How to apply a function to each row of a pandas dataframe inplace?

I don't want anything returned. Just modify the values in a data frame row by row, in place using a function. How do I do it? So far all my attempts seem to return a data frame.

14 mins ago
3 answers

Using TastyPie to update a ForeignKey field to null

Is it possible to use TastyPie to update a ForeignKey field to None? Related question: tastypie won't remove foreignkey reference during PUT What I have: class SomeObject(models.Model): ...

16 mins ago
2 answers

Why is the Regex not working?

I wrote a Regex to pull a time stamp off a Youtube video and I tested it in Regex101 where it seemed to work, but when I use it in Python i get strange outputs. The regex is ...

1 answer

ImportError: No module named streams

I am setting up django(1.6) project locally. I have installed all modules including activity-stream but When I try to run server "python manage.py runserver 8081", i am getting this error Traceback …

17 mins ago
1 answer

Css prefixer module for Python?

Such prefixer library exists for JS, it allows to prefix CSS content with vendor prefixes. Does same / similar module exist for Python? I'd want to use it in Py3.

21 mins ago
2 answers

Python - How to write a list of strings and ints to file efficiently

I've got a list, containing lists of strings and ints, for example: l = [['+1', 12, 13, 14], ['+1', 13, 14, 15]] I need to write this list into a file, every sub-list in a separate row. I did it …

21 mins ago
0 answers

Trouble Loading libgphoto2.dylib into python

I have gphoto installed properly and I can use all the features with my camera, but for some reason gphoto = ctypes.CDLL('libgphoto2.dylib') Throws an error. $ python Python 2.7.5 (default, Aug …

21 mins ago
1 answer

pyplot.imshow() data selection

i am using pyplot.imshow() to plot the color map of a galaxy, the data is a 50x50 array (2500 spectral pixels) for a data cube, but the galaxy itself only spans a small portion of the frame at an ...

22 mins ago
1 answer

How to store variable length list of dict-type objects with FKs in Django SQL DB

Let's say I'm getting some JSON in the format of... "fellowPlayers": [ { "championId": 110, "teamId": 100, "summonerId": 34258805 …

24 mins ago
0 answers

Accessing ndarray and discarding invalid positions - Python

I have two related questions about accessing a matrix position that in fact does not exists. First, I have an matrix with rows rows and cols columns. From this matrix, I have to get sets of n x n sub …

25 mins ago
2 answers

Numpy: get only the array rows that have a value in an interval

I have a numpy array which which has a shape of (10, 3) and looks like: 10 | xxx | yyy 11 | xxx | yyy 13 | xxx | yyy 14 | xxx | yyy 15 | xxx | yyy 17 | xxx | yyy 19 | xxx | yyy .............. What …

27 mins ago
0 answers

Python to Ruby: I need to open a file parse the data and multithread with it

I need to translate this into Ruby: ids = [i.strip() for i in open('ids.txt','r')] proxies = [i.strip() for i in open('socks.txt','r')] for (i,j) in izip(ids,proxies): i = parseID(i) j = ...

2 answers

Use tweepy search API. But get much fewer result than I search on the website. Why?

for result in tweepy.Cursor(api.search, q = "www.nature.com", count = 100).items(): count = count + 1 print count There's only 11 results by using tweepy search API. But when I search at ...

1 answer

Using Pycurl in Pycharm

I'm trying to run a script that begins: from pycurl import * However, this throws the error: Traceback (most recent call last): File "/Users/adamg/PycharmProjects/untitled/UrlToText.py", line 1, …

0 answers

Long Boundary Detection in a Noisy Image

I'm trying to extract a single long boundary from a rather noisy image (forgive the green, the image is converted to grayscale in any case). I've tried running various edge detection and threshold ...

0 answers

Numpy read complex numbers from text file

I have used numpy to save a matrix of complex numbers. The output file looks like that: (1.100412357301083777e-02+1.471303433818593742e-02j) ...

35 mins ago
2 answers

Can't parse a second table with beautifulsoup even if the first one works?

I am trying to parse tables using beautifulsoup. The first one on my page was easy but I cannot parse a similar table on the same page. I do not understand why. Here is the code. Thanks in advance …

2 answers

Creating Matrices

I'm trying to create a game of Minesweeper on python3 and the first thing im trying to do is have the user use command line input for the number of rows and columns that they wish to play with. Then I …

38 mins ago
2 answers

Get file object from file number

Let's say I have a list of the opened files (actually, of the file numbers): import resource import fcntl def get_open_fds(): fds = [] soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) …

40 mins ago
1 answer

python urllib2 request is prepending newline chars to post data

I have a simple python (2.7.5) script using urllib2 to post data to a django (1.6.2) app on a server. When the request arrives at the server, one of the posted values has been truncated and one of the …

1 answer

Evaluation missing in SublimeREPL Python

I'm trying to get SublimeREPL to work with Python. However, whenever I send a Python command to the REPL with the keyboard shortcut, only output from stdout is displayed. The evaluation of the command …

5 answers

Writing to csv file Python

I am trying to write to CSV file but there are blank rows in between. How can I remove the blank rows? Thanks in advance. import csv b = open('test.csv', 'w') a = csv.writer(b) data = [['Me', ...

48 mins ago
15 30 50 per page
1 2 3