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
render image 1:1 on screen in matplotlib
I'm using matplotlib and want to accomplish the equivalent of Matlab's truesize:
resize an image so that 1 pixel renders as 1 pixel on screen
resize the axes and figure around that transformed image ...
-1
votes
1answer
26 views
I need help on my palindrome programm in python [duplicate]
This is my code currently:
def main():
list1 = [(x) for x in input()]
if (list1 == list1.reverse()):
print("The sentence is a palindrome.")
else:
...
0
votes
0answers
10 views
Scraping a webpage for link titles and URLs utilizing BeautifulSoup
I have a webpage of popular articles which I want to scrape for each quoted webpage's hyperlink and the title of the article it's displaying.
The desired output of my script is a CSV file which lists ...
0
votes
0answers
11 views
Running multiple interactive cluster jobs from python, and waiting for them to finish
I'm looking for the best solution for the following problem:
I'm working on a cluster, and I'd like to spawn interactive jobs to the cluster.
However, I'd like to spawn about 7,000 of these jobs, and ...
0
votes
1answer
2 views
Looking a simple AWS CloudWatch program for memory and disk usage monitoring
I need a simple Python program that will:
Run on a Linux server, preferably AWS Linux AMI
Written in Python using AWS Boto library
Get the RAM usage
Get the swap usage
Get the disk usage for a ...
0
votes
0answers
3 views
Trouble Migrating database schema to Heroku (Postgres)
I have everything set up in my local environment and the code for my website up on the Heroku server, I'm just having serious trouble getting the schema to migrate to the postgres database on the ...
-6
votes
0answers
31 views
Shorter or more efficient way to write this code
Is there a shorter way to write this code or parts of it it is part of a bigger one and i need to it be more efficient ad not use the same repetition
People={"Dan":22,
"Matt":54,
...
1
vote
0answers
4 views
Is there a way to outline text with a dark line in PIL?
I'm using python/PIL to write text on a set of PNG images. I was able to get the font I wanted, but I'd like to now outline the text in black.
This is what I have: as you can see, if the background ...
0
votes
0answers
8 views
Python sendto Error TypeError: must be str, not bytes
I've Looked At Other Answered Questions and The Only Solution I've Found Is That It needs to send it encoded. But I still receive this error whether or not this is encoded. Any ideas??? The commented ...
0
votes
0answers
4 views
How to make action logging in Django with Django Rest Framework
Good day everyone!
I need to make logging of the actions in Django 1.10.4 with Django Rest Framework and save them in a file.
I have different serializers and functions in them. I've read ...
-3
votes
0answers
19 views
I need to write some functions from a Python Pandas csv dataset
I went over the course material , but just cant seem to figure it out.
this is course on python data science through coursera and university of michigan.
The following code loads the olympics ...
0
votes
0answers
8 views
Is it possible to Normalize data before applying euler to do softmax?
I'm training a neural network where and I have to make my own softmax from a very large array of data. I am using tensorflow but I have to do a special post_process with the test results. (Note: I ...
0
votes
1answer
12 views
How to get absolute url from xpath?
I am using the following code to get the url of an item:
node.xpath('//td/a[starts-with(text(),"itunes")]')[0].attrib['href']
It gives me something like:
itunes20170107.tbz
However, I'm looking to ...
0
votes
0answers
5 views
How can I launch Jupyter Notebook in Safari?
I am on a Mac OS, and my default browser is Firefox.
In terminal, I ran jupyter notebook --generate-config. Then, in a text editor, I opened ~/.jupyter/jupyter_notebook_config.py
I changed c....
0
votes
0answers
6 views
launching script within gui with qprocess works in 3.4 not 2.7 hanging on raw_input?
I did all of the developing of a gui application in the anaconda IDE and in python 3.4 and using a simple test script I thought it was working well within 3.4 displaying output in realtime and waiting ...
0
votes
1answer
23 views
python error when writing data in csv file
write a python program to write data in .csv file,but find that every item in the .csv has a "b'" before the content, and there are blank line, I do not know how to remove the blank lines; and some ...
0
votes
0answers
8 views
Access methods of member of Parent that references other module, from child [on hold]
New to Python. Apologies for the title. Been searching for days on this problem :S
My code is;
import Z
class A():
def __init__(self):
self.varZ = Z()
self.some_value = None
...
-2
votes
0answers
8 views
PyCharm using a lot of memory - running slow
Problem: Recently my pycharm have began running really slow, and its beginning to get very frustrating.
No it's not my pc, or any of my equipment that is causing it. It ran excellent in the ...
-3
votes
2answers
30 views
How to get the min/max values in a list of arrays?
I have a list of arrays:
m=[ [1, 1, 2, 5, 6, 1] , [5, 6, 8, 5, 6, 7] , [10, 12, 10, 12, 11, 11] , [8, 10, 5, 6, 8, 9] , [6, 5, 10, 12, 15, 19]]
I need to get the max or min of each array in the list....
-2
votes
1answer
26 views
Unsupported operand type in Python [on hold]
Can someone show me what is wrong with this code? The console keeps giving me this error message:
File "payroll.py", line 59, in tax_computation_fourthtier
if x > 0 and x - festier - ...
-4
votes
0answers
16 views
there is a problems on my python code [on hold]
Hi there is a problem on my code i didnt understand what is it please help the code is below
#variablesss
money = 1000
#Messages
print("Welcome To test)
print("Type 'help' For List Of Commands.")
#...
2
votes
2answers
57 views
Why is this if condition working partially?
I have a list of dicts, which I would like to delete all dicts where the value of few specific keys is smaller than their counterpart in another dict :
Here's my code :
for d in ...
1
vote
1answer
13 views
How to match until first occurrence of a pattern?
I am parsing a file and trying to extract multiple sections in the file. One such section is called 'Report', a single file might contain multiple reports. I wish to extract each of these 'Report' ...
0
votes
1answer
8 views
Requests with proxy and thread
I'm trying to use requests to check huge proxies lists. In order to do that, I'm using threads. I really need these threads because I'm using the same code structure latter, in order to make many ...
0
votes
0answers
7 views
how to concat each row's max divided by two part in tensorflow?
I am a new to tensorflow.
Acutually, My question is how to concat each row's max divided by two part in tensorflow?
Here's an example of what I want to do in numpy code.
def concat_rows(matrix,...
0
votes
0answers
5 views
(Python Adafruit FT232H) When running the code for USB on windows it is reading a file that seems to not exist
I am trying to get the I2C to work from laptop using the Adafruit FT232H board. I set it up and did the i2cdetect code, and the I2C pin reads. According to Adafruit if I used the file for raspberry pi ...
-2
votes
0answers
13 views
Cisco File Comparisons
I'm looking for an easy way to compare cisco configuration files using python. I've seen a lot of comments on CiscoConfParse. But i'm trying to see if anything exists already for what i'm trying to do ...
-4
votes
3answers
40 views
Can i stop python outputting negative numbers?
So what i want to do is for python to give me an error or something similar when it detects a negative number is about to be outputted. For example:
for i in range(5):
print(i-5)
This code ...
0
votes
1answer
14 views
Time series prediction with Keras - values close to average
I am doing a one step ahead prediction using 15 previous samples on a dataset using LSTMs in Keras.
The data csv file can be found here:
(https://drive.google.com/file/d/...
0
votes
0answers
3 views
Django multiwidget and validation issue
I have been subclassing multiwidget to create an HTML5 range slider synchronised with a NumberInput field using this code:
class SplitRangeNumberWidget(MultiWidget):
def __init__(self):
widgets = ...
0
votes
0answers
40 views
Random Seed Options
I am very very new to python so please be kind.
I have a python query that is trying to randomize pages to show to the user. So if two people are sitting next to each other and they visit the page ...
0
votes
0answers
5 views
How to update the data on homescreen with Kivy
I am very new with Kivy and trying to build an app with it. Now I have a problem with updating the data on home screen after closing a popup.
Here is the problem:
Tap a button on the home screen and ...
0
votes
0answers
8 views
Python xlrd Named Range for Table Names
I have defined a table (dynamic) with a name and tried to use the name range for this table (it is a table name instead of a name for a cell or for an area) in which VBA could easily fulfill. But I ...
1
vote
4answers
36 views
Pandas: Column that is dependent on another value
I have a Pandas dataframe like the following:
col1 col2 col3 col4
0 5 1 11 9
1 2 3 14 7
2 6 5 54 8
3 11 2 67 44
4 23 8 2 ...
0
votes
3answers
29 views
Loop through list of lists to plot with matplotlib
Trying to create a simple graph using a list of lists with year and value:
test_file = [[2000, 3.8], [2001, -2.4], [2002, 5.8], [2003, -10.5],
[2004, 2.1], [2005, 2.1], [2006, 6.9], [...
0
votes
1answer
14 views
Python Selenium Webdriver won't run, even when PATHed properly, and script written as instructed
I'm trying to learn Webdriver for Python, using a basic understanding of Python, and a more extensive understanding of Selenium and JAVA. I'm following the guide found here. My code:
import unittest
...
0
votes
4answers
48 views
How to assign global variables from dictionary?
This is my dictionary:
vimvar = {'startline' : [ 'startline' , 'int(vim.eval("s:StartLine"))' ],
'startline-1' : [ 'startline' , 'int(vim.eval("s:StartLine"))-1'],
'endline' ...
1
vote
0answers
17 views
Permission denied error in pip installing pyopenssl
As I'm trying to force reinstall pyopenssl, I'm running into the following error when it tries to install pycparser. I am doing this on Windows 7 64-bit with Python 2.7 using the following command:
...
-3
votes
0answers
26 views
Creating a Scatter plot using a averaged value
New to python and I am trying to figure out how to create a scatter plot and then add a regression line. I have variable Year and variable y which is an integer. I need to average the values y per ...
-2
votes
0answers
20 views
invalid syntax on context [on hold]
I am making an application using django, I am trying to retrieve data from my database, but I keep getting an error saying that there is a syntax error with my context.
views.py
from django....
1
vote
0answers
8 views
Disable Cached JSON response on frequent browser calls to django view
In my django app, I use views to call the django method I want to test under development.
When I call my view visiting the mapped url localhost:8000/do_something, twice, it'll return me the cached ...
-3
votes
0answers
20 views
Appending variables to a list
I have some data asigned to variables with common endings. So I wish to make a list with these variables using for example
subject_dems.append(glob.glob('*_age'))
trying to create columns/dataframe ...
2
votes
3answers
24 views
Pandas group Excel data by column and Graph Scatter Plot With Mean
I have a collection of data I am reading out from several Excel files. I can easily read, merge and group the data with pandas. I have two columns of interest in the data, 'Product Type' and 'Test ...
1
vote
1answer
21 views
Why doesn't sympy simplify the Fourier Transform of a derivative?
We know that the Fourier Transform of a derivative is
where k is the fourier variable. Explanation here
My question is, why doesn't sympy use this knowledge? For example:
from sympy import ...
0
votes
1answer
11 views
Multiply Django Apache servers
I currently have one server with an Apache-Django app running on it along with postgresDB.
I would like to add another server with the Apache-Django app that is connected to the same postgresDB ...
0
votes
0answers
10 views
Python webapp to set all query vars to a js object
I am building a simple web app with Python and web.py. My current challenge is to take all query vars (web.input()) and set a JavaScript object in the HTML template. However, I don't know how to ...
-4
votes
1answer
38 views
Remove everything after a number in a string [duplicate]
Is this possible? To delete everything in a string after any number?
Eg.:
some_text = "123 Text"
some_text_2 = "456 Foo"
I want to get only 123 and 456 without the space, and those numbers would be ...
0
votes
0answers
5 views
Use QState.assignProperty with dynamic values at runtime
I have a question to using the QStateMachine-System of PyQt5 properly.
Using
State.assignProperty(aLineEdit, "plainText", "Some text")
allows to set "Some text" to the plainText-property whenever ...
1
vote
2answers
13 views
Highlighting multiple cells in different colors with Pandas
Imagine we have a dataframe and I want to color different cells:
Cells ['Arizona','company'](1st), ['Texas','size'](1099) as green.
Cells ['Florida','veterans'](26), ['Maine','armored'](0) as red.
...
1
vote
1answer
17 views
python subprocess32 with timeout, overflowerror
this is my log
File "/opt/ibm/db2-governor/helpers/utils.py", line 10, in run_cmd
output = proc.communicate(timeout = timeout)[0]
File "/opt/ibm/dynamite/python/lib/python2.7/site-packages/...