Questions tagged [python-3.x]

For questions about Python programming that are specific to version 3+ of the language. Use the more generic [python] tag if your question is not version-specific. Use the [python-2.x] tags for Python 2 questions.

Filter by
Sorted by
Tagged with
0
votes
0answers
5 views

Looking to store two different web urls in a data structure

I have two urls containing the 'hello' string. https://us.search.yahoo.com/search?p=%22hello%22&fr=yfp-t&fp=1&toggle=1&cop=mss&ei=UTF-8 and https://www.google.com/search?safe=...
0
votes
0answers
20 views

Find all possible subsets to get a sum equal to a given number? [closed]

To find possible subsets that sum up to a given number, with contrains that you can not use number greater than a 'max' number. Sum =4, max=3 (1,1,2),(1,2,1),(2,1,1),(1,3),(3,1),(2,2), (1,1,1,1) are 7 ...
0
votes
0answers
7 views

Django Internal Server Error, when DEBUG = False

I have this relatively famous problem but I just can´t found the solution, when my DEBUG = True everything works fine and then I set it to False and it just doesn't work... And I set also the 'ADMINS ...
0
votes
0answers
10 views

Python 3 Django 3.0 Running but not listening or opening port

I am using PyCharm and an instance running in AWS for remote debugging. When I start debugging the server starts and continues to run. However, it is inaccessable and doesn't appear to be grabbing ...
0
votes
0answers
12 views

Hitting 500 error on django with debug=False even with ALLOWED_HOSTS=[“*”]

I am getting 500 errors on every page I try to go with. The only thing that i'm changing is DEBUG to False. Here is my config: SECRET_KEY = os.environ.get("SECRET_KEY", "0$ke!x1bz5cj0mpzo1zfx4omw-...
0
votes
1answer
27 views

chessboard pieces won't display

Code: import tkinter, os from PIL import ImageTk, Image def sortFileImages(files): black = [i for i in files if 'black' in i] white = [i for i in files if 'white' in i] pawns = [[i]*7 ...
0
votes
2answers
32 views

How to make this function work more efficiently to count dominators?

I have to make a function where it would count the amount of dominators in a given list (number to the right of any number has to be smaller for it to be counted as a dominator.) For example, given ...
-3
votes
0answers
15 views

How do I turn a table of a set of answers and the corresponding recommendations into a Python program? [closed]

I'm learning Python and I would like to develop a simple app. How do I turn this table—Recommendations of 3D printing materials (Link to table)—into a python program whereby there is a questionnaire ...
0
votes
1answer
18 views

How to create clusters/groups from knowing associations?

I have a dataframe that has 2 columns: [ID, ASSOCIATED_ID] For each ID, I have a list of other associated IDS from the dataframe. Here is a synthesized version of it: ID ASSOCIATED_ID 1 ...
0
votes
0answers
22 views

Which algorithm should we use? [closed]

We have a CSV file in that we have a bank related mails. We want to seperate that into multiple file similar to there issue.for example all the car loan related issue must go in carloan.csv file all ...
0
votes
0answers
19 views

PCA analysis : IndexError: boolean index did not match indexed array along dimension 0; dimension is 40 but corresponding boolean dimension is 100

I have implemented the logic for PCA but now I'm stuck on index error for the boolean dimension. Following is my code: np.random.seed(1) # random seed for consistency mu_vec1 = np.array([0,0,0]) ...
0
votes
1answer
9 views

Type hinting an enum property that returns an instance of that enum

I have an enum that looks like this: class Direction(Enum): NORTH = 0 EAST = 1 SOUTH = 2 WEST = 3 @property def left(self) -> Direction: new_direction = (self....
0
votes
1answer
12 views

How can I view logs in an Heroku one-off dyno?

I have a script which I have set to execute in my Heroku app but how can I view my logs from a Heroku one-off dyno?
-1
votes
2answers
25 views

AttributeError: module 'turtle' has no attribute 'Turtles' when defining variables

Traceback (most recent call last): File "orbit.py", line 6, in <module> body1 = turtle.Turtles() AttributeError: module 'turtle' has no attribute 'Turtles' I am getting this Error in my ...
0
votes
1answer
13 views

QListView with Index restoring

As extension with another question to my previous post. Having QListView with saving and restoring selection of items in QListview. Indexes of selected item after restoring would not print correctly. ...
0
votes
3answers
46 views

How to get dictionary variable within an object?

I'm writing a pokemon like turn base battle simulator. I have gotten pretty far so well but I'm having a problem. I'm trying to write the moves as a dictionary so that I can then specify the move set ...
-2
votes
2answers
37 views

list of list comparison with respect to a integer value in tuple

I am trying to create a function which takes 2 list of lists and a integer as input: list1 = [[2, 47, -42], [-42, 29, -45], [24, -11, 18], [-34, -4, -14], [-42, -45, 49], [-21, -6, 12]] list2 = [[13, ...
-2
votes
0answers
22 views

How to create an array filled with one? [duplicate]

I would like to know if there any way to make an array filled with value 1 (exactly what numpy.ones does, or numpy.zeros does with 0) but without using any package (like numpy), writing the code ...
0
votes
1answer
53 views

Fastest way to apply a function to each pixel of image?

Started learning python less than a week ago. Maybe my question is really n00b'ish one, but I spent about six hours today trying to find an answer, but failed. I have found multiple solutions of ...
0
votes
0answers
9 views

What exception error to throw when doing a Stripe coupon creation

This is the part of the code that requires an exception name: coupons = {'birthday': 20, 'special': 10, 'contributor': 25} if request.POST['coupon'] in coupons: percentage = coupons[request....
0
votes
0answers
4 views

How can I compute a surface integration from data?

Suppose I have a Nx3 array, where N is a giant number (the amount of points describing a surface) and 3 stands for the 3-dimensional space. This data describes a well-shaped good-looking surface with ...
-4
votes
0answers
25 views

Why can I only create a virtual environment in the directory that python is in?

I have python 3.8 and its located at C:\Users\sd\AppData\Local\Programs\Python\Python38-32. I tried to create a virtual environment using on my desktop using the command: python -m venv test but ...
0
votes
1answer
16 views

Using three version (class, function, lambda) for setting logging Filter

I can create the same Filter in three different ways: 1) As a lambda: import logging handler = logging.StreamHandler() handler.addFilter(lambda record: getattr(record, 'msg') == 'Hello') logger = ...
0
votes
0answers
5 views

Keeping an SSH session persistent across command executions

So this is my current issue: I have a network device and it only allows five connections at a time. An API is written that will connect to the device and pull some info. The problem is that the ...
0
votes
1answer
5 views

Difference in output of spacy nlp .vector when applied on sentence?

I am doing the following: import spicy nlp = spacy.load("en") doc = nlp('Hello Stack Over Flow, my name is Steve') doc.vector: In [1]: doc = nlp('Hello Stack Over Flow, my name is Steve') In [2]:...
0
votes
1answer
21 views

What elements are retained between invocations?

It's best practice to reuse client connections in main.py to avoid unneeded network activity What other elements are stored between invocations? What determines this? For example, variables are not ...
-5
votes
0answers
21 views

Detecting identical values in 2d array (python 3.x) [closed]

I am currently trying to program a generalized m,n,k-game, and have almost got it working. However, I am having trouble detecting win conditions. I am storing the 'board' as a 2d array, with each list ...
0
votes
1answer
20 views

Query params for Java API call using HTTPURLConnection

I am trying to set up a query params for an API call. I need to call an API and get results for a specific time. I was able to get it done in python where I use a dictionary to specify key value pair ...
-3
votes
3answers
50 views

Python Bulk 'If' Statements

I'm drawing a blank on what should be a simple question so any help is appreciated. Is there a better way to handle all these 'if' statements rather than having them copied into each function? This ...
3
votes
4answers
66 views

How to avoid using global variables in Python

I use global variables but I've read that they aren't a good practice or pythonic. I often use functions that give as a result many yes/no variables that I need to use in the main function. For ...
0
votes
0answers
13 views

groupby(), agg() and lambda function

I have a dataset where the same first name appears in multiple rows with different values in col2 and col5. I want to group the dataset by the first name and do aggregation function where I can get ...
0
votes
0answers
9 views

stopping python requests during connection

I'm working on a multithreading project where I open more connections with python requests in more threads. These threads work in a loop. Over and under the loop there is an handler which tells the ...
0
votes
0answers
6 views

How to deploy a Tezos smart contract influenced by UI inputs with ConseilJS

I wish to be able to create a Tezos smart contract taking input from a UI to supply parameters pubKey,prvKey,pubHash for the deployment and minAmount and maxTime to influence the Michelson code. I ...
1
vote
0answers
20 views

THEANO_FLAGS error using GCC with Keras Theano on AWS Lambda

I was trying to get Keras (theano) to process my ML model on AWS Lambda. The inference was taking too long (about 60 seconds per image!), so I found a possible solution on the internet: install GCC ...
1
vote
2answers
33 views

Why does list turn out different than expected?

I have a list with integers. I then want to change the list so that instead of it containing, let's say four 1:s in a row, it shoudl say [[4, 1]]. So I made a function for that, but I get a unexpected ...
0
votes
0answers
13 views

Gradient Descent with Logistic Regression problem

I am trying to understand logistic regression. I have written a cost function and first derivative if cost. then i used scipy.optimize.fmin_tnc . Below is value of theta and cost using that theta. ...
1
vote
2answers
30 views

Filtering for datetime timestamp column based on just day?

My df has a col as Time 2017-10-04 19:00:00 2017-10-03 13:00:00 2017-10-04 04:00:00 2017-10-10 12:00:00 If I want to filter for rows that are on 2017-10-10 or after or a date range just ...
0
votes
1answer
29 views

Empty regex returns and repetitions

I am trying to retrieve some content from a csv, am converting the list objects to strings, and then am attempting to use regex to reduce a bunch of strings to repetitive parts (eventually to count ...
0
votes
1answer
18 views

How to get the filepath from a frame

To get the filename from a frame I can do: exc_type, exc_value, exc_traceback = sys.exc_info() current_frame = exc_traceback.tb_frame filename = current_frame.f_code.co_filename # example.py # how to ...
-1
votes
1answer
39 views

How to generate a pyramid of words in python based on a dictionary of words?

I want to generate a pyramid using Python that has the following structure: The pyramid is built using the following: The user enters an integer between 1 and 15. Then a "word pyramid" of the ...
0
votes
0answers
10 views

how to add a rolling mean column based on a category? [duplicate]

how do I create a new column on the rolling mean of a category (in my case based on city)? Date Name Sales City Mean (city) <-looking to add this column 1/1/12 Mike $345 NYC 345 ...
0
votes
0answers
26 views

Unable to import module 'lambda_function': cannot import name 'WinDLL' from 'ctypes' (/var/lang/lib/python3.7/ctypes/__init__.py

I'm trying to generate a graph with matplotlib in python lambda function. i imported a layer with the library mathplotlib, but it doesn't work. The idea is generate a graph, save it like temp file and ...
0
votes
3answers
23 views

Unable to get_text from select_one using BeautifulSoup

I am trying to parse the time from the below HTML but am unable to use get_text with select_one to extract the data-published-date or datetime within <time class = "published-date relative-date" ......
-5
votes
0answers
18 views

Matplotlib plot evolution of a function [closed]

I found a great image showing the evolution of a function with its parameters. How can I re-create this image in matplotlib?
1
vote
1answer
12 views

Ansible Dictionary/Hash Key as Special Variable

I'm trying to set an Ansible fact as a dict/hash but would like to use a special variable as the key. In my case I want to use the special variable inventory_hostname. However, when I attempt this ...
0
votes
0answers
14 views

How can I download the contents of a web page without providing user credentials?

Suppose I wanted to download http://freakingwebsite.org/user3904/content=321 the contents of this web page as an html file. Let's just assume that no user credentials are required to access that web ...
0
votes
1answer
15 views

The POST method in DJANGO returns “None” when a form is submitted

I have built a small web application that will get the data from a HTML table and dump it into sqlite database. When I use the POST method to capture a particular cell value, it returns none. Could ...
0
votes
0answers
8 views

Why does pyinstaller fail when I have latex installed?

I am trying to compile a python program I just edited and test to an exe and it says it finished but the program error out. I have the output from it being comiled and it seems to look at latex stuff ...
0
votes
1answer
12 views

ec2client.describe_instances returns UnauthorizedOperation after adding condition to IAM policy

My goals is to restrict access to ec2 using tag key. It works fine if I remove the condition from the IAM policy. However, if I add the aws:TagKeys condition then I get UnauthorizedOperation error. ...
0
votes
0answers
18 views

Reading CSV files into python with utf-8-sig BOM and latin-1 encoding

I have a csv file that seems to be encoded in UTF-8 based on the BOM present at the start of the file. However, when I try to open it, I get an error import io import chardet from zipfile import ...