2 answers

Replace multiple characters atomicaly

I'm working on decrypting a substitution cipher (not Caesar/ROT) with frequency analysis and no specialized tools. Let's say I wanted to use this cipher dictionary which seems good enough after ...

0 answers

Fastest way to sorting a corpus dictionary into an OrderedDict - python

Given a corpus/texts as such: Resumption of the session I declare resumed the session of the European Parliament adjourned on Friday 17 December 1999 , and I would like once again to wish you a happy ...

1 answer

Compare chars between strings to ASCII table position

I'm new to python and trying to write a program to compare strings; specifically the characters in sequence in each string and the decimal ASCII values of these characters. For example, I have string ...

0 answers

Python : How to Make Nodes Fixed And Adding Nodes On Other Location in a tree type strcuture?

I Am Making A Kind If Program In Which Nodes Are Added Dynamically In A Tree Type Structure Using Animation In Networkx Python . The code is working fine without any error but every time a new node is ...

2 answers

how to use a terminal embedded in a PyQt GUI

There is an existing environment and framework usable via Bash terminal around which I want to make a GUI. What I have in mind is the following flow: In a Bash session, the framework environment is ...

1 answer

numpy cross-correlation - vectorizing

I have a large number of cross-correlations to calculate and I'm looking for the fastest way to do it. I'm assuming vectorizing the problem would help rather than doing it with loops I have a 3D ...

0 answers

Model selection for linear regression with categorical variables

I regressed the dependent variable Rating (numeric) on Judge which is categorical. The output of the first model is given at the end of the question. Only Judge John Foy and Linda Murphy came out to ...

6 answers

Execute Python every x seconds without reopening tabs

I am trying to make my python code autoupdate. The problem is that the code pulls up four html files, so four new tabs in the browser, every time it runs. I tried auto-updating using an answer from a ...

1 answer

Using a shared variable in a function

Hi I'm following a neural net tutorial where the author seems to be using shared variables everywhere. From my understanding, a shared variable in theanos simply is a space in memory that can be ...

1 answers | 8 mins ago by Dr.Knowitall on Stack Overflow stackoverflow.com
1 answer

For-Else Statement with Multiple If-Break Conditions

I wrote a simple python module that returns the prime numbers up to a given N, using a bool flag is_prime as follows: def generate_primes_up_to(M): n = 2 primes = [] while n <= M: ...

1 answers | 10 mins ago by Mattia on Stack Overflow stackoverflow.com
2 answers

Serving images directly from GCS in GAE using Blobstore API and Images API

Many questions and answers on Blobstore and Google Cloud Storage(GCS) are two or three years old, while things change dramatically these years. GCS is no longer a standalone service. It is integrated ...

0 answers

JQuery AJAX not working in django

I tried integrating the autocomplete from here : http://flaviusim.com/blog/AJAX-Autocomplete-Search-with-Django-and-jQuery/ , but it doesn't seem to work. Here is what i have tried so far: I am ...

3 answers

How to understand the first parameter in Flask instance init?

When create a Flask instance , we always use __name__ as the first arguments, but why? class flask.Flask(import_name, static_path=None, static_url_path=None,static_folder='static', ...

3 answers | 29 mins ago by storen on Stack Overflow stackoverflow.com
1 answer

Python, subprocess, pipe and select

I have a python program where I continuously read the output of other program launched via subprocess.Popen and connected via subprocess.PIPE The problem I am facing is that it sometime lost ...

1 answers | 37 mins ago by shodanshok on Stack Overflow stackoverflow.com
2 answers

OR element wise operation over two binary lists

I have the following code of two binary lists and I want to obtain a resulting list in which the element i will be the OR operation applied to the i elements of the two lists: from operator import ...

2 answers

numpy advanced indexing feature or bug?

numpy advanced indexing anomalies. I encountered this while working on an assignment for CS 190.1X. Took a while for me to grasp the dimensions. >>> a = np.ndarray([3,3],int) >>> ...

2 answers | 43 mins ago by bicepjai on Stack Overflow stackoverflow.com
2 answers

variable size array matching

I have a data file which is sorted based on the first column 1 3 2 3 6 4 8 5 6 2 4 9 5 2 2 There is a key with three items, say seen = [4 8 5] that I want to search in the above array. Since some ...

2 answers | 47 mins ago by mahmood on Stack Overflow stackoverflow.com
1 answer

How to enhance parallelism in a python client for elasticsearch?

I am new to elasticsearch and I need to optimize a python client to do the search/indexing on a elasticsearch cluster. It seems to me that the bottleneck is the client itself, and that elasticsearch ...

1 answer

Google App Engine: How to do queries interact when they execute a function decorated by ndb.transaction

Just to understand the inner workings of ndb.transaction, I tried the following experiment. The Conference API in Udacity example was used to create a conference with just one seat available. I ...

5 answers

Beyond for-looping: high performance parsing of a large, well formatted data file

I am looking to optimize the performance of a big data parsing problem I have using python. In case anyone is interested: the data shown below is segments of whole genome DNA sequence alignments for ...

2 answers

Why getparent() don't work as expected?

I need to make some manipulations with text inside one of tags and want to get parent tag for every found text node for it Code: import lxml.etree import pprint s = ''' <data> data text ...

2 answers | 57 mins ago by El Ruso on Stack Overflow stackoverflow.com
9 answers

Python division

Can somebody explain this to me? I was trying to normalize a set of numbers from -100 to 0 to a range of 10-100 and was having problems only to notice that even with no variables at all, this does ...

0 answers

How to edit each line in a text file and change it to an HTML file in python

I've got a list of wikipedia links where each link is on a new line. What I want to do is cut the link (https://en.wikipedia.org/wiki/) from each line but store it in a variable called "prelink", put ...

5 answers

A + B without arithmetic operators, Python vs C++

I was trying to solve an old question: Write a function that add two [integer] numbers A and B. You should not use + or any arithmetic operators. The best solution is like this, quote from here: ...

2 answers

convert two 1D arrays to set of tuples

Suppose that we have the following arrays a = np.asarray([1,2,3]) b = np.asarray([4,5,6]) How can we turn a and b into the following array c containing tuples? c = [(1,4),(2,5),(3,6)]

2 answers | 1 hour ago by Alfredo on Stack Overflow stackoverflow.com
1 answer

“AttributeError: 'module' has no attribute 'player'” when attempting to load python object into C++ with Boost::Python

Error in terminal as follows: AttributeError: 'module' has no attribute 'player' Python file: character_py.py import sys sys.path.append('./character') import character player = ...

1 answers | 1 hour ago by rearden on Stack Overflow stackoverflow.com
0 answers

Identify contiguous segments of a non-contiguous numpy array

In the example below, we have a contiguous array, and a view of the same array that is non-contiguous: shape = (5, 100) A = np.arange(np.product(shape)).reshape(shape) # Everything is contiguous at ...

2 answers

Appending values to two key defaultdict in python

From a text file, I am trying to append one following value as the value from the two previous values as the keys. Here is mt code: # this is a sample file. The output that I would like is ...

1 answer

adding column to dataframe based on count from another dataframe

I have a dataframe ranksdf containing player names, dates, and their ranking per the date. The date column is a parsed datetime object (maybe relevant for date comparison later): player date ...

1 answers | 1 hour ago by beta on Stack Overflow stackoverflow.com
0 answers

Django: CSRF cookie not set

I want to post a form in my django project resulting in a "CSRF cookie not set." error. views.py from django.shortcuts import render from django.template import RequestContext from ...

15 30 50 per page
1 2 3