Tagged Questions
Python is a dynamic and strongly typed programming language designed to emphasize usability. Two similar but mostly incompatible versions of Python are in widespread use (2 and 3). If you have a version-specific Python question consider using the python-2.7 or python-3.x tags in addition to the ...
0
votes
0answers
3 views
How to perform deep search when using PynamoDB for DynamoDB
I am using PynamoDB for AWS DynamoDB in python, and having a table like this:
{company_name:'abc', address:{suburb:'Melbourne', state:'VIC'}}
And I need to do a search to get all companies with ...
0
votes
1answer
6 views
What is the . symbol in matlab, how to change it to python
Xnorm = (X-repmat(mu,m,1))./repmat(sigma,m,1);
what does the . here do? And if I want to change it to the python, what should I do?
-2
votes
1answer
11 views
How to make regex that matches a number with commas for every three digits?
I am a beginner in Python and in regular expressions and now I try to deal with one exercise, that sound like that:
How would you write a regex that matches a number with commas for
every three ...
0
votes
0answers
4 views
Pandas groupby - grouping users and counting the type of subscription
I'm attempting to use pandas to group members, to count the number of subscription types that a member has purchased and get a total spent per member. Once loaded the data resembles:
df =
Member ...
3
votes
0answers
7 views
Pandas slow on data frame replace
I have an Excel file (.xlsx) with about 800 rows and 128 columns with pretty dense data in the grid. There are about 9500 cells that I am trying to replace the cell values of using Pandas data frame:
...
-4
votes
0answers
24 views
Is this possible with Python? [on hold]
Back when I was 10 years old, we have a school competition on who can get the most points on Mathletics.
One of the challenges was a burst of arithmetic problems in 60 seconds. I remember looking up ...
0
votes
0answers
4 views
Ear detection opencv not working
This is my code but it only shows back the image no ears are detected. Any help is appreciated, thank you.
#!/usr/bin/python2.7
import numpy as np
import cv2
le_cascade = cv2.CascadeClassifier('/...
0
votes
1answer
15 views
How to add prefix to files' names, replace a character, and move to new directory?
For example, the files will look like FG-4.jpg FG-5.jpg, etc. and need to be copied to a new directory and named test_FG_4.jpg test_FG_5.jpg, etc.
I'm new, this is the code I have so far:
...
0
votes
1answer
17 views
using variable name within list as string for file save python
I have a python list which contains 4 elements, each of which is a time-series dataset.
e.g.,
full_set = [Apple_px, Banana_px, Celery_px]
I am charting them via matplotlib and I want to save the ...
1
vote
0answers
5 views
Make Django Project Secret Keys accessible from Google Cloud
I have a Django App running on Google Compute Engine VM instance. I am trying to store all the secret keys of settings.py file securely in the Google Cloud and then fetch those values in settings.py ...
0
votes
0answers
3 views
“'CXXABI_1.3.8' not found” in tensorflow-gpu - install from source
I have re-installed Anaconda2.
And I got the following error when 'python -c 'import tensorflow''
ImportError: /home/jj/anaconda2/bin/../lib/libstdc++.so.6: version `CXXABI_1.3.8' not found (...
0
votes
0answers
5 views
custom report data through python odoo 9
I am trying to print qweb report and pass the data through python. here is my code i referenced ids of two model. ON call it is not even throwing any error.
does anyone know what i am missing. i am ...
0
votes
0answers
10 views
How to read 1-bit unformatted fortran binary data in python?
I want to read numerical model output file in python.
this model output file is unformatted fortran output file.
so, to read in fortran,
OPEN(10, FILE=FILE_NAME, STATUS="OLD", ACCESS="DIRECT", FORM=...
1
vote
0answers
7 views
Python Generated txt not recognized by AJAX .load
Using AJAX the webpage updates as expected when the .txt file is manually changed then saved but the webpage does not update automatically after a python 2.7 logfile.close().
The Python code ...
1
vote
0answers
8 views
How to add the weight as an estimators for the ensemble using brew module in python?
I'm trying to apply ensembleclassifier in my python program. Im using brew package as module. And I tried some codes from brew documentation. Like the following piece of codes that I use to initialize ...
3
votes
3answers
42 views
Find the subset of a set of integers that has the maximum product
Let A be a non-empty set of integers. Write a function find that outputs a non-empty subset of A that has the maximum product. For example, find([-1, -2, -3, 0, 2]) = 12 = (-2)*(-3)*2
Here's what I ...
-8
votes
2answers
34 views
Python sorting alphabetically without list.sort()
I want to sort a list of words alphabetically without using any built-in sorting methods. How would I go about doing this?
0
votes
1answer
33 views
Checking if string contains valid Python code
I am writing some sort of simple web-interpreter for vk.com . I look for messages, check if they are valid Python code, and then I want to execute that code, and return any stdout to code sender. I ...
0
votes
0answers
5 views
Keras convolution filter size issue
I'm very new to Keras, and in my early experiments I've been encountering an error when I create convolutional layers. When I run this code (found here; "Shared vision model" section)
from keras....
0
votes
1answer
14 views
change python default version in a remote server
I'm working in a remote server via ssh, where I have installed anaconda, which is now the default version.
For some scripts, I need to use the default version, where some libraries have been installed....
0
votes
0answers
14 views
Python AST to dictionary structure
I am using the Python ast module to parse expressions like X >= 13 and Y == W. What I need is to transform this expression in a pre-order dictionary found below:
{
"function": "and",
"args": [
...
0
votes
1answer
14 views
In Django, how do I order_by() when reaching across tables?
I'm trying to filter my Friendships objects and then order_by user.first_name, but it's not working. Can anyone tell me what I'm doing wrong?
Here's my models:
class Friendships(models.Model):
...
0
votes
2answers
22 views
Find common values in dictionary that has keys with multiple values
I am new to python and I have a problem. I am trying to find keys with a value; however, the keys have multiple values.
d = {
'a': ['john', 'doe', 'jane'],
'b': ['james', 'danny', 'john'],
...
0
votes
1answer
16 views
PermissionError: [Errno 13] Permission denied @ PYTHON
i am trying to copy a file from one folder to another, but i am getting "PermissionError: [Errno 13] Permission denied". I am working within my home directory and i am the administrator of the PC. ...
2
votes
1answer
44 views
How can I write a C function that takes either an int or a float?
I want to create a function in C that extends Python that can take inputs of either float or int type. So basically, I want f(5) and f(5.5) to be acceptable inputs.
I don't think I can use if (!...
0
votes
0answers
12 views
Union of node and function on node in XPath
I am using Scrapy to crawl some webpages. I want to write an XPath query that will, within a parent <div>, append a couple of characters of text to any child <a> nodes, while extracting ...
0
votes
0answers
12 views
Convert PDF to image and compare
I have hundreds of pdf file i.e (A1,A2, A3....).pdf that I need to go through to compare the content in each page to other set of pdf file i.e (B1, B2, B3....).pdf. Is there a way to import each page ...
1
vote
1answer
20 views
python dynamic object query
I have a python object structured like:
tree = {
"a": {
"aa": {
"aaa": {},
"aab": {},
"aac": {}
},
"ab": {
"aba": {},
...
0
votes
0answers
12 views
issue while generating panorama
I have these 2 images with some overlap
When I try to generate a panorama out of them, I get some weird results. Here is the output image. How can I correct this?
Here is the link to the code I am ...
0
votes
0answers
14 views
How to rotate B and C column in the following code using python
import matplotlib.pyplot as plt
import numpy as np
import xlrd
import xlwt
import pandas as pd
import math
wb = xlrd.open_workbook('Scatter plot.xlsx')
sh1 = wb.sheet_by_name('T180')
sh2=wb....
0
votes
0answers
14 views
How to close excel file and open 2nd excel file in Python?
I am trying to open 1st macro, close and run 2nd macro, and so on.
Followings are my code to run 2 excel macro files sequentially.
I got a error message as "Traceback (most recent call last):~~~~~
...
0
votes
0answers
11 views
Running a Function That Updates Array While Matplotlib Plots it
I have a Python program (main.py) that has a constant stream of data that is handled by a class RTStreamer which basically gets the data -- via a live stream -- and appends it to a numpy array. ...
0
votes
0answers
3 views
JupyterHub openssl self signed cert “Error: error:0906D06C:PEM routines:PEM_read_bio:no start line”
Trying to configure at JupyterHub on a AWS instance using a self signed OPENSSL key/cert pair. I have tried several openssl configurations, and continued to have this same error.
jupyterhub
[I 2016-...
0
votes
0answers
16 views
Django - Splitting admin.py
I tried to split admin.py with the following steps but failed.
- Remove admin.py
- Create folder named "admin"
- Create files in folder "admin". modela.py, modelb.py
- Create "_ init _.py" and leave ...
0
votes
0answers
5 views
python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-LFiDhC/MySQL-python/
I am using PyCharm Community Edition 2016.2.3 on OS X EI Capitan, using Python 2.7.12, pip 8.1.2. I could successfully install xlrd, xlwt, cherrypy, pacang and docx libraries. But when I install mysql ...
0
votes
1answer
20 views
why my links not writing in my file
import urllib
from bs4 import BeautifulSoup
import requests
import readability
import time
import http.client
seed_url = "https://en.wikipedia.org/wiki/Sustainable_energy"
root_url = "https://en....
-1
votes
1answer
21 views
Python class instance variables disappear
I define the response class like this:
class Response(object):
def __index__(self):
self.country = ""
self.time_human = ""
self.time_utc = ""
self.text = ""
...
0
votes
2answers
29 views
Selection Sort Algorithm Python
Working on implementing this algorithm using Python. I thought my logic was okay but apparently not as Python is complaining. The while loop is causing issues. If I remove that it works as expected ...
0
votes
1answer
14 views
how to have multiple arguments in a input fuction in python
This function throws an error at the input function claiming that the arguments are invalid.. any resolutions?
def assignSquareValues():
square=[[0,0,0],
[0,0,0],
...
0
votes
0answers
4 views
postgresql insert timestamp error with python
I use psycopg2 for postgresql. Here is my snippet:
a = "INSERT INTO tweets (Time) VALUES (%s);" % (datetime.now(),)
cursor.execute(a)
this won't work and gives me an error:
ProgrammingError: ...
0
votes
1answer
7 views
Schema - Ability to change email address (primary user id) in Django
Currently my user table looks like this - (all fields are not null)
display_name = CharField # string
email_address = EmailField (primary key) # string
password = CharField ...
0
votes
0answers
9 views
gensim Doc2Vec vs tensorflow Doc2Vec
I'm trying to compare my implementation of Doc2Vec (via tf) and gensims implementation. It seems atleast visually that the gensim ones are performing better.
I ran the following code to train the ...
1
vote
1answer
23 views
Python - Append items to a list while making https requests inside a loop
I am making requests to SPotify API inside a for loop, like so:
track_ids = []
#get track_ids
for track in random.sample(pitchfork_tracks, 10):
results = sp.search(q=track, type='track') #here I ...
0
votes
0answers
12 views
scipy cdist with sparse matrices
I need to calculate the distances between two sets of vectors, source_matrix and target_matrix.
I have the following line, when both source_matrix and target_matrix are of type scipy.sparse.csr....
0
votes
1answer
20 views
selecting date in date ranges wrong result
Following if statement occasionally gives wrong result. any idea why?
if self.start_date <= datetime.datetime.now().date() <= self.end_date:
self._is_current = True
else:...
7
votes
1answer
104 views
How to make an integer larger than any other integer?
I need to create an integer that's larger than any other integer. Use case: library function expects an integer, and the only easy way to force a certain behavior is to pass a very large integer.
In ...
0
votes
1answer
17 views
Iterating through the dropdown list, not able to scrap all the content of the table
I am trying to scrap a website using Python and selenium driver, it works by selecting from the dropdown which changes the content of the table.
Somehow, I am able to scrap through the first table but ...
1
vote
1answer
15 views
Updating Each Row with Minutes Since First Row
I have a file with several million tweets. The first tweet occurred 2013-04-15 20:17:18 UTC. I want to update each tweet row afterward with the minutes since minsSince that first tweet.
I have ...
2
votes
0answers
37 views
Python - write and read current function
I'm working on a solo adventure RPG console game, similar to a MUD but with no Multi-user.. so a D... I'm trying to save the current function the player is in so that they can load their save.
...
0
votes
1answer
13 views
python/django: deployment to heroku fails
I am trying to deploy an app to heroku.
It's a python/django app, and it runs fine on my local machine.
When deploying, heroku downloads the packages defined in requirements.txt, but then stops ...