Newest 'python' Questions - Stack Overflow

Questions tagged [python]

Python is a multi-paradigm, dynamically typed, multipurpose programming language, designed to be quick (to learn, to use, and to understand), and to enforce a clean and uniform syntax. Two similar but incompatible versions of Python are commonly in use, Python 2.7 and 3.x. For version-specific Python questions, use the [python-2.7] or [python-3.x] tags. When using a Python variant or library (i.e Jython, Pypy, Pandas, Numpy), please include it in the tags.

0
votes
0answers
4 views

Flipping negative values to plot up instead of down in bar graph

I have the following dataframe: col1 col2 day 2019-06-26 3.450006 -3.150000 2019-06-27 5.249994 -2.849982 2019-06-28 7.249994 -2....
0
votes
0answers
6 views

module 'cv2' has no attribute 'selectROI'

I've got a fresh install of OpenCV 3.2 with contribs, ffmpeg, and numpy. However, when I try to use the function selectROI I get an attribute error and I cannot figure out why!!! I've tried to ...
0
votes
1answer
4 views

PySide2 equivalent of PyQt5's loadUiType() to dynamically mix in UI designs

TL;DR: I want a drop-in replacement for PyQt5's loadUiType() function from its uic module that works with PySide2 and Python 3.6+. I want to migrate a PyQt5 application to PySide2. A common pattern I ...
0
votes
0answers
5 views

parse_and_bind() for keys other than <tab>

Is it possible to use "?" for tab-complete besides tab key in python? python allows to use key with parse_and_bind('tab: complete'), but I don't see any option for binding other keys like '?'; ...
1
vote
0answers
12 views

ProjectEuler 7. 10001st prime

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? k = 10001 b = 2 for i in range(2, 100000): if i % 2 != 0 ...
0
votes
0answers
11 views

Evaluation of list comprehension inside functions not working

Why does eval() of expressions with list comprehension work fine, if done outside a function, but cease to work under all circumstances, as soon as I run the same commands inside a function? E. g., ...
0
votes
0answers
4 views

Polar pcolormesh plot shows offset (how to display two arrays in different hemispheres of a polar plot?)

How can I (in python) accurately and flexibly display two arrays in different hemispheres of a polar plot? I would like to plot an array such that half of it appears on the top hemisphere of a polar ...
0
votes
0answers
2 views

How to display a tiled map file in pygame using pytmx

I'm trying to make a game and import a tmx file as a map. I'm just wondering how to blit a tiled map to a pygame display with coordinates to move it. how would i go about doing this with pytmx? Any ...
0
votes
0answers
12 views

changes to inner list are not persisted

I have a 2d list, and I am trying to swap values based on index. the values are swapped correctly, but at the end of the iteration the values are not persisted. for attr_i, attr in enumerate(...
0
votes
2answers
25 views

Is there a way to get just a specific string from another string?

Let say I have the next string: string = "<dialog id="105">\xa<state>confirmed</state>\xa</dialog>" The length of this string may vary. Is there a way that I can get just the ...
0
votes
0answers
3 views

Add individual users to Project in Django

I am building a basic project management app using Django, where a Project can have any number of users. How can I create a form to add users one at a time? The default behavior of Django provides ...
1
vote
0answers
8 views

How to parse arguments in python (spyder)?

I am following this tutorial and trying to run the below part of the script. I am using python 3.7 and spyder 3.3.4. ap = argparse.ArgumentParser() ap.add_argument("-d", "--dataset", required=True, ...
-1
votes
0answers
5 views

deployment using weblogic.deployer

usually when i deploy using weblogic.deployer i do like this---- java -cp weblogic.Deployer -verbose -noexit -adminurl -user <> -password <> -name TestPage -source -stage -upload -deploy -...
0
votes
0answers
9 views

Early reference to row of a csv file imported as list break my read dataset?

I am opening, reading and storing into a list data structure the content of a csv file (https://www.kaggle.com/ramamet4/app-store-apple-data-set-10k-apps). I tried to store header and rest of the ...
-1
votes
0answers
22 views

Hackerrank problem: several for loops in a list comprehension

I'm resolving a problem in hackerrank, have a look: https://www.hackerrank.com/challenges/between-two-sets/problem I m trying to have one line of code so I tried to create a list, that go through ...
1
vote
0answers
9 views

running a python program from c++

I have a python code which runs CNN training/inference. Generally you would run the code with many flags as follow python MY_PYHTON_FILE train -XX flag1 -YY flag2 .... I would like to be able to run ...
0
votes
0answers
4 views

TF Transform RuntimeError: AssertionError [while running 'AnalyzeAndTransformDataset/TransformDataset/Transform']

I'm working with the following code using tensorflow-transform: import tensorflow as tf import apache_beam as beam import tensorflow_transform as tft from tensorflow_transform.beam import impl as ...
0
votes
0answers
16 views

How do I delete associated symbols when using Notepad++?

So lets say I have the argument pyautogui.typewrite(["tab"]) and I want to remove the [] brackets to switch from a key to a string, when I click in-front of the last bracket is shows the first bracket ...
0
votes
0answers
10 views

fcntl.lockf inside a context manager of a file

I have a piece of code (python 3.7) that is as below: import os, fcntl with open("testfile", 'w') as tf: fcntl.lockf(tf.fileno(), fcntl.LOCK_EX | fcntl.lock_NB) ... some code that does some ...
-2
votes
0answers
13 views

Need to format my output in table format using pandas for Cosine Similarities

I have tried to format my output in table using print function but it not readable. Can someone help me to make a proper table format using pandas? def calculate_similarity(self, ...
-1
votes
1answer
28 views

How to generate a list of random numbers with the 5% occurance of particular values?

I need to generate a list of 100 random integer numbers. However, I need to create the values in such way that large values occur only in 5% of cases, while the rest of values are equal to 0. This is ...
0
votes
0answers
8 views

sns.kdeplot - Y-axis of the plot is undesirable

I'm trying to plot a distribution graph in Python using sns.kdeplot. You can use x = np.random(size=100) to generate a sample data, but my actual data has completely different values (I don't have ...
1
vote
1answer
10 views

How to create a keras layer with a custom gradient in TF2.0?

since in TensorFlow 2.0 they plan on unifying all high-level APIs under keras (which I'm not much familiar with) and removing Sessions altogether, I was wondering: How can I create a custom keras ...
-2
votes
0answers
7 views

how to keep a tkinter window open into which buttons pressess print infomration

i have a tkinter gui. i have buttons that write into files random numbers. i want to keep a seperate window open that logs all the data being written into the files. since it wont let me post this ...
0
votes
0answers
8 views

Downloading pandas output as saved files instead of links

I'm trying to add an image to each episode for a podcast scrape. The RSS feed is a great help, but it seems the unique link for each episode can't be used as it's not an actual link as there's no .jpg ...
0
votes
0answers
10 views

Converting a Multi-Index Dataframe into a Class

I have a multi-index dataframe that contains data regarding various chain/parents stores, their branches for each week for n number of weeks. The data includes fields such as "starting inventory", "...
0
votes
0answers
7 views

Correct syntax on az dls fs move?

I am attempting to move some files from one directory to another in ADLS using azcli tool. Here is my command: az dls fs move --account <my dlsname> --source-path /temp/ -- destination-path /...
0
votes
0answers
9 views

Nondeterministic DataFrame existence in Pandas while trying to debug pytest using breakpoint()

I was trying to debug why one of my pytests was failing, and I used python3.7's breakpoint() in my pytest. I have the below code: (Pdb) train_df Acquisition_personal_win_amount ... ...
1
vote
0answers
12 views

trying to access a ManyToManyField from db query but returning None

Im tring to access a ManyToManyFireld property after model query but get back None. This is what the model looks like. class Role(models.Model): ROLES = Choices('user', 'staff', 'admin') ...
0
votes
0answers
10 views

Problem with firebase_admin database collections() method, in python

I used to use this code to get a copy of Firestore database to local, but the last day I find this error suddenly: google.api_core.exceptions.InvalidArgument: 400 Document parent name "projects/some-...
0
votes
0answers
9 views

WSGI - Flask with Multiple-processes Routing Requests to Same Instance

I wrote a chat server that was running as expected with a single process Flask which keeps sessions in memory and saves to disk at the end of each conversation. I need to deploy it with multiple ...
0
votes
0answers
9 views

Radial color map on mesh plot

I'm trying to plot a mesh with a radial colormapping. That is, I want that all the points in a constant radius to have the same color. I tried this example https://docs.enthought.com/mayavi/mayavi/...
0
votes
4answers
48 views

Creating an algorithm to solve a problem in python

Algorithm Objective: link to the pictures i took while giving the amazon interview: [https://boards.wetransfer.com/board/shl7w5z1e62os7nwv20190618224258/latest][pictures] Eight houses, represented ...
0
votes
1answer
18 views

How to pass list of conditions to method which checks all posibble combination of conditions?

I have pandas data frame, and list of conditions: import pandas as pd inp = [{'c1':10, 'c2':100, 'c3':120}, {'c1':11,'c2':110,'c3':120}, {'c1':12,'c2':120, 'c3':25}] df = pd.DataFrame(inp) filter1 = ...
0
votes
1answer
14 views

Flask Web App link user with sqlite3 list problem

Iam coding a bullyng reports web app in python with flask and a database in sqlite3 with 3 lists "usuarios", "victimas" and "testigos". Table usuarios is to list all the users (schools) registered ...
0
votes
0answers
10 views

Generating a page dynamically in Django

I'm tyring to generate a page dynamically in Django but i can't find a way to do this. In my DB, i have a table containing some items, this table is "dynamic"; so i will keep adding and removing ...
-1
votes
0answers
16 views

I'm trying to send post request and scrap the XHR response

I'm trying to scrap post response from web site. The website i trying to scrap data from is www.editapromo.com import requests with requests.Session() as c: url = 'http://www.editapromo.com/' ...
1
vote
2answers
18 views

Matplotlib won't show minor ticks when using subplots

I have several subplots and want to adjust the axis ticks settings by ax.tick_params. Everything works fine, however, the minor ticks are not shown. Here is a code example import matplotlib.pyplot as ...
-1
votes
1answer
18 views

How to test whether service is working using pytest

I have a piece of code, which I have to test using pytest: from flask import Flask, render_template app = Flask(__name__) # two decorators, same function @app.route('/') @app.route('/index.html') ...
0
votes
0answers
8 views

how to connect SqlAlchemy to access multiple databases servers (from different servers)

I am trying to connect multiple tables from different schema's into one query in Python?created individual variable for each conn under the variable called connections, but the error shows that ...
1
vote
1answer
12 views

Django Form not recognising model Attribute

Django doesn't seem to recognise the model object in my custom user form. This is the error: Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "...
1
vote
0answers
16 views

How to prevent colorbar from moving up/down as heatmap height changes? Matplotlib/seaborn

I am generating a heatmap dynamically and the number of categories on the y and x axes may be different each time. How can I position the colorbar next to the heatmap so that it is always anchored at ...
1
vote
0answers
15 views

ValueError: Unknown label type: 'continuous-multioutput' when fitting data

I want to predict multiple outcomes based on one input parameter with scikit-learn's MultiOutputClassifier. For some reason I always get this error, and I do not know whats the problem: ValueError: ...
0
votes
0answers
8 views

Error with the pytube module while attempting to do yt = YouTube(url)

I have a function called downloadSong which is used to download a song from youtube when given a url, but it's drawing an error I've tried searching through a docs and the read me, but I haven't seen ...
0
votes
1answer
23 views

How to monkeypatch a single variable value in pytest

I have a function: def test(): url = "/test/pvc/name" if "pvc" in url: return True else: return False Now to test this function I want to patch the url variable. How can ...
-1
votes
1answer
11 views

Is there a way to delete all the 'junk' that comes when printing a file from the internet

I want to print a file from the internet with the \n' b' etc. from urllib.request import urlopen data = urlopen('http://willswebdev.000webhostapp.com/plan.txt') for line in data: print(line) b'...
1
vote
0answers
18 views

Symmetric cipher for integer algorithm/method

I am looking for a bijective transform that I can use NOT for encryption, but for obfuscation. The idea is to take integers such as 1, 2, 3, 4 and project them onto another axis. The main idea is to ...
0
votes
0answers
13 views

Is there any api or method that returns me the year of any technology launched or released?

I am trying to find the year and month of particular technology say snapdragon 625 so I want to know the year and month in which it got launched or released. I have tried Wikipedia api to get the ...
0
votes
2answers
15 views

Python beautifulsoup printing the element desired

After I find the desired element I have this: [<div class="statsValue">$1,615,422</div>, <div class="statsValue">1</div>, <div class="statsValue">2</div>] I would ...
-1
votes
1answer
11 views

How can I import data from MongoDB to Panda?

I want to analyze a database hosted in Mongo. Therefore, I want to connect the mongo URI to pandas, so I can run all my python queries freely in my Jupyter Lab environment. Let's day that this is my ...