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
8 views

remove unwanted information from entries in a list of numpy arrays [duplicate]

I have this list of arrays and I don't want my end result to contain stuff like "dtype" etc. My question is: how do I acquire the desired result? Desired result: [[0, 1, 3], [2, 4, 5], [6, 7]] ...
0
votes
0answers
4 views

ImportError: cannot import name 'Pdb' from 'IPython.core.debugger'

It seems I can't use Jupyter notebook at all. I've already tried to uninstall and install again but this error persists. [I 19:33:14.916 NotebookApp] KernelRestarter: restarting kernel (1/5), new ...
0
votes
3answers
24 views

How to return values from for loop in python?

I am trying to make a loop go through a provided string and return false if a character that is not recognized is found, and true if all the characters are recognized. I do realize that for loops don'...
0
votes
0answers
3 views

stop ttk.Entry() from reading keyboard

Environment: macOS Catalina, Python 3.7.4, Tcl/Tk 8.6.9, VSC 1.39.1 I have a situation where I am using a bar/qr code scanner to provide a code to a ttk.Entry() method. The reader is seen by the OS ...
1
vote
1answer
21 views

How to output special characters in Python?

I'm programming a basic MapReduce program where the input file is plain text, basically the program counts how many times a word appears in the input, and has to output another plain text file that ...
1
vote
0answers
4 views

How can i extract a zip having password and created by winzip using python?

I have a zip file ( created by winzip ) which i want to extract with python. The problem is zipfile module of Python only extracts zip files which have PKWARE password protection, so i can't extract ...
0
votes
1answer
12 views

how to fix 'TypeError: 'module' object is not callable' in flask?

I want to create a web service using Python. The service contents are as follows. Receive music files from users Analyze the received file and create a new music file. (The function implementation ...
0
votes
0answers
12 views

Is it possible to have alternative inheritance in python3?

My goal: class BaseClass1: def f(self) class BaseClass2: def f(self) class DerivedClass: def g(self): self.f() # this is either BaseClass1::f() or BaseClass2::f(), depending on ...
-1
votes
3answers
43 views

My while loop won't stop after condtiotion

i made a dice game and you have 3 goes and if you don't guess it with the 3 goes it will show you the number and say you lost but for me it only shows it if you don't guess it in 4 goes. import ...
0
votes
1answer
16 views

How to store multiple player data in python

I'm trying to figure out how can I add multiple player's data using a function, but every time I add the player data, the new one replaces the old data. Here is the code: def AddPlayer(): ...
1
vote
1answer
11 views

Handling ResultProxy objects

I am trying to query my table named "books" and using a raw sql to get a title of the book. Currently, the table hase 5 columns: id, isbn, title, author, p_year. The query is returning me a ...
1
vote
1answer
18 views

Is there a way to assign different jobs (processes) to specific core in linux using python?

I have python functions that should run parallelly in a linux environment utilizing multi cores. Is there a way to specify which core should be used for each process explicitly? Currently, I am ...
0
votes
1answer
8 views

Summation riddle duplicate values seen

def riddle(x): list=[] i=0 for i in range(0,len(x)): for j in range(i,len(x)): for k in range(j,len(x)): if ((x[i]+x[j]+x[k]) ==30) and x[i]!=x[j]!=x[k]:...
0
votes
0answers
20 views

Generating a series of slightly random integers in a numpy array

I want to create composite audio test signals in a numpy array. I need the values to be integers rounded to the nearest whole number. Secondly I want to add random noise or dither. You can see below ...
0
votes
0answers
19 views

Slice dates in a pandas dataframe and convert to string

I have a dataframe with a CAS number Column, this column comes from a Excel sheet. When I copied the Column some of the values changed into a date format and I need to change that back. Example: CAS ...
0
votes
0answers
17 views

Get all the probabilities of one cell to go to another with linear regression

I have a dataset of precincts and results of parties on different elections. After reading this article I really wanted to use linear regression to answer the question : how did voters changed their ...
1
vote
2answers
28 views

Docker-Compose can't connect to MySQL

I'm trying to connect Django project with MySQL using docker. I have the problem when upping docker-compose. It says the next error: super(Connection, self).init(*args, **kwargs2) django.db....
0
votes
0answers
12 views

How to convert form field data before saving to database in a Django ModelForm?

I'm creating an "edit" page in Django python framework (template 'edit_page.html') where user should be able to edit existing data stored in a database. For now I can easily retrieve existing raw data ...
0
votes
0answers
15 views

How to merge two large Pandas dataframes based on their ID - by reading the biggest file through chunks?

I have two CSV files, df1_50GB.csv and df2_1GB.csv. I would like to merge the data frames based on the matched ID value. here is what I did so far f50GB = "df1_50GB.csv" f1GGB = "df1_1GGB.csv" ...
1
vote
1answer
12 views

Obtaining Json data from webpage using python

import requests from bs4 import BeautifulSoup import json # import webpage r= requests.get('https://www.zooplus.fi/shop/koirat/kuivaruoka/royal_canin_size') #find required data-set #results = soup....
-1
votes
2answers
21 views

Java or Python regexp search of large list of words

I have an list of "Nw" English words that I would like to search using "Ne" different regexp's. Nw is several hundred thousand entries, and Ne is several hundred. The regexp's allow only individual ...
-1
votes
0answers
24 views

How do I convert a decimal string into a float? [duplicate]

For example: float('99/57') would give me an error. I have tried the fraction function but that has a similar behaviour to modulus. Im trying to import a bunch of fractions and organize them into a ...
0
votes
0answers
18 views

how to loop input (see my code and you will understand)

I want my code take an input, the input not stoping until i enter empty string, and the table will print in the final output that store all the input before this is my code: # read file and store in ...
-2
votes
1answer
19 views

werkzeug.routing.BuildError [duplicate]

I am trying to get my Flask urls to work, currently, I have this navigation: @app.route("/<category>") def category(category): @app.route("/<category>/<subcategory>") def ...
0
votes
1answer
19 views

AttributeError: 'StreamingPullFuture' object has no attribute 'open'

I am trying to write a job which reads messages from subscriber and output it to bigquery. Python version used is 3.6 . I am receiving error as below while executing the code : Traceback (most ...
0
votes
1answer
12 views

How to set ranges and limits for multiple inputs?

I have three inputs x, y and z. How do I set limits for these inputs? Also if I want x to be always greater than y, but less than z how can I do this? while True: try: x, y, z = (float(...
0
votes
0answers
4 views

Highlight Plotly heatmap cell or change the color of a specific heatmap cell in Plotly

Is it possible to highlight or change the color of a specific heatmap cell in Plotly, I have a requirement of accepting the user input and then highlight those cells on the heatmap. Any help would be ...
0
votes
1answer
12 views

How to split a text file based on common values in a column?

I'm writing in python and I have a text file that looks like the following: chr9 6533147 6533150 NM_000170.2_cds_0_0_chr9_6533017_r chr9 6533150 6533160 NM_000170.2_cds_0_0_chr9_6533017_r chr9 ...
1
vote
0answers
39 views

Why an empty list does not equal False? [duplicate]

The pythonic way to test if a list is empty is: empty_list = [] if not empty_list: print("The list is empty") output: The list is empty Then this code should have the same output: empty_list = ...
1
vote
1answer
38 views

Recursive function variable confusion

megaList = [] clmsArrow = [[3],[2,3,4],[1,3,5],[3],[3],[3],[3]] def columnState(y,amnt): "-1 for all values in a list of lists" megaList.append(y) print(y) for i in range(len(y)): ...
0
votes
1answer
14 views

getting index of a multiple line string

Trying to get an integer in a multi-line string with its value same as its index. Here's my trial. table='''012 345 678''' print (table[4]) if i execute the above, i will get a output of 3 instead ...
2
votes
0answers
15 views

Unresolved reference for imported identifiers that are later rewritten

When I import a function at the top of my file and later use it in a function, in which I reassign it later on, python complains about Unresolved reference '_', e.g.: from django.utils.translation ...
1
vote
1answer
24 views

Why dataframe.columns do not match with columns of printed dataframe?

I am trying to subset a dataframe based on a list of columns name. Here is an example of the code: import pandas as pd import numpy as np arrays = [['A1', 'A1', 'A1', 'A2', 'A2', 'A2', 'A3', 'A3', ...
0
votes
0answers
17 views

Split list in row into multiple chunked rows

I have a pandas data frame where some rows contain a list of results that come back from a system. I'm trying to split those lists into smaller chunks (in the reproducible example below, chunks of 2) ...
0
votes
1answer
21 views

Is there a way to capture stdout from this example?

This is for the Windows environment. Compile the testprocess.py (using pyinstaller) and place the resulting exe in a test folder. In the same folder, run the ptest.py. Testprocess.py starts and ...
-5
votes
0answers
21 views

there are some python3 codes than need completion how can i complete them?

i have several codes here need to be completed however i could not fully understand what it need ? def implies(a, b): if a: return b else: return True q = True for p in (...
0
votes
1answer
23 views

Import directory errors with Python 3.5 and above

I want to import modules from folder and subfolder with Python 3.6. Currently I have a structure like this. └── project │ main.py ├── package1 │ ├── __init__.py │ └── module1....
0
votes
2answers
22 views

Difference between int(input()) and input(int()) in Python 3

when I type code as int(input()) and input(int()) for same input let say 12,output are 12 and 012 . So why this,what is difference in syntax?
0
votes
0answers
11 views

Opencv is installed in my machine, But cannot import in my python project

I have installed openCV in my machine I am using ubuntu 16.04 but cannot import opencv. when importing opencv in my python project I receive this error.... Traceback (most recent call last): File "...
0
votes
1answer
20 views

Error when reading HDF files in Python 3.7 with Pandas.read_hdf function

Previously, I have saved multi columns of dataset into one HDF file. The procedure can be outlined as follows: import pandas as pd from pandas import HDFStore, DataFrame from pandas import read_hdf ...
0
votes
1answer
31 views

Try funtion() for set amount of time in python, else raise error [duplicate]

I'd like to try and run a function for a set amount of time and exit if that function doesn't return. Something like: try (for 3 seconds): function(input0) except TimeoutError: print("...
0
votes
0answers
9 views

Plotting by Index with different labels

I am using pandas and matplotlib to generate some charts. My DataFrame: Journal Papers per year in journal 0 Information and Software ...
0
votes
0answers
8 views

I have a question about tricontourf() from .xyz data

I want to use .xyz data to make contour map. I save each x,y,z as 1-D array. x = latitude, y = longitude, z = depth x, y, z .shape are the same value (=24310) x = lons y = lats z = data ax = plt....
1
vote
1answer
20 views

Python: Pygame installs but doesn't run well, if at all. (Mac, Mojave)

I've been trying to get pygame to work in tkinter, but all i get is two separate windows where everyone else says it works: /a/16550818/12221209 But when I run basic pygame ...
0
votes
1answer
21 views

ModuleNotFoundError: No module named 'surprise'

I have installed scikit-surprise in Windows10. C:\Users\Cosmos Lord>pip install scikit-surprise Requirement already satisfied: scikit-surprise in c:\users\cosmos lord\appdata\roaming\python\python37\...
1
vote
0answers
14 views

Python(3.6): program was not found in path

On Windows 10 (PyCharm IDE), i tried import the pythone-nmap module to get PortScenner. The code i wrote: import nmap ns = nmap.PortScanner() a = ns.nmap_version() print(a) Afterward, i got the ...
0
votes
0answers
8 views

Problem with motion detection .. i try two different codes with same function (AbsDiff)

Python code for Motion detection please help ..
0
votes
2answers
13 views

Try-except with three possibilities in json path

I've got some json with slightly different paths, like the first: dcSubject: fre: 0: Marie(Sainte) 1: Anges and the second: dcSubject: en: 0: Railroads-...
0
votes
0answers
4 views

How to get RSI divergence value (used ta-lib)

I'm thinking about how to get RSI divergence for system trading. Please advise how to get it. Implemented using min and max functions, but did not produce the desired result fastk, res_arr = talib....
0
votes
1answer
31 views

How to permanently +1 a variable outside of a for loop

I have a Python script that pulls cryptocurrency data from Yahoo Finance. It scrapes this data and then inputs it into a Google Sheet. What I want is for this script to run once per day, which I will ...