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

“ImportError: DLL load failed while importing _openmp_helpers”?

I tried to import resample_img from nilearn.image to use in resampling some medical image. import nibabel as nib import nibabel.processing from nilearn.image import resample_img img = nib.load('./...
0
votes
0answers
10 views

Cannot import pynput

When executing the import pynput command in a script, I get this: [email protected]:~$ python3 Python 3.7.5rc1 (default, Oct 8 2019, 16:47:45) [GCC 9.2.1 20191008] on linux Type "help", "copyright", "...
0
votes
0answers
7 views

However, import sklearn still gives me error. More details are given below. How do i resolve this?

I am using python3.6 (python3.8 was tried earlier for the same problem) on windows 7. I have installed joblib==0.14.0, numpy==1.17.4, scikit-learn==0.22 and scipy==1.3.3 for some Machine Learning ...
0
votes
0answers
9 views

Fully clear terminal on Mac OS X without exiting Python script

I'm running a simple utility with Python3 that takes text input delimited by comma, tab, or pipe (usually copied from csv) and joins the text around " | " for readability. After an empty input is ...
1
vote
1answer
15 views

How to calculate intercept and slope of the simple linear regression fit in python?

I have the following code class Data: def init(self, x, y): """ (Data, list, list) -> NoneType Create a new data object with two attributes: x and y. """ self.x = x self.y ...
-1
votes
0answers
6 views

Rename dictionary based on the Parent ID in Python

Let's say I have a dictionary as below: { "data": [ { "Age": 32, "Emp_id": "A", "Gender": "M", "Result": [ { ...
0
votes
0answers
6 views

pymysql err :self._sock.settimeout(self._write_timeout) in flask

When i use pymysql in flask ,I ofen get a err, when ctrl + f5 flush my web. who can give me some advice. please this is my code: I define a fun to deal with database connection db.py db_host = ...
0
votes
1answer
9 views

Regex specific match

Want to filter exact FOC2345N1UG from the following input. I had used this regex (S\/N:\s\s\s(\S+)) in Python. I am fetching all the ones not the one which is required. NODE module 0/RSP0/CPU0 ASR ...
0
votes
1answer
9 views

pip3 install tensorflow-gpu installs tensorflow version 1.14.0

I am trying to install Tensorflow 2.0. These are the commands that I am running: $ pip3 install tensorflow-gpu When I open a Python Console (in Jetbrains PyCharm) import tensorflow as tf I'm ...
2
votes
3answers
26 views

Remove everything after the first hyphen from the left

I have been trying to remove everything after third - from the left of a string including the - Example My string has INPUT: sukumar-123-656-321-421 ...
0
votes
0answers
7 views

How to redirect tenant to subdomain

I am using django-tenant-schemas to add multi-tenancy to my SaaS website but have not found a good way to redirect tenants to their subdomain automatically. Obviously the tenant will be denied login ...
0
votes
0answers
6 views

Discord.py Warning Command (help me) mass dm

A few days ago I was trying to create a warning command, a dm mass type, but instead of sending to all server users, send just a few people to a specific role. I was able to create just one mass dm ...
0
votes
1answer
9 views

merge two csv file into one csv file using python script

I have two CSV files. The file1 has a header with only one record and file2 has a header and multiple records. file1: dept_id dept_role dept_name dept_date dept_ service 10 ...
1
vote
0answers
14 views

Unexpected, Intermittent execution with python3 list(set(arr))

I'm doing a few algorithm questions and ran into a strange issue in one of my test cases. The get_num_groups function returns an integer that the assert statements verify. The first assert statement ...
0
votes
0answers
13 views

TypeError: string indices must be integers-Python-Foursquare

Trying to convert json file to pandas df and wrote below code but getting TypeError: string indices must be integers error. Please suggest. sample of input df "df_query_res" I am trying to iterate ...
0
votes
0answers
12 views

Verifying that an object instance complies with ABC in Python

I have an API that receives a serialized representation of an object that I expect to comply with a particular interface (known at development time). The serialized data I receive includes details ...
0
votes
0answers
6 views

recursive function for compare two tuples and return one tuple with no repetitions

I've tried everything, but I can't make this function work at all. At least not the way I want. def uniao(x, y): a = list(x) b = list(y) i = len(a)-1 j = len(b)-1 if a == b: return tuple(a) +...
0
votes
1answer
9 views

How to plot a dictionary in Python into a 3D plot?

I have a dict whose values can be accessed by the form d[k][i] (It's a dict d containing 25 smaller dicts d[k], which themselves contain 25 values d[k][i]). I don't know how to turn these into a 3d ...
1
vote
1answer
18 views

validate the data frame header with pandas regex

In pandas data frame has email header. for that i want to validate few domain names and special characters are available i have to save into new sheet as invalid sheet. Here is the example data frame ...
0
votes
1answer
18 views

Can not generate probability for Monte Carlo Simulation in python 3.x?

I have created a high-level Python random function for a Monte Carlo Simulation in python and my code is running correctly. However, I'm not able to generate a probability to draw: 2 - blue and 2 - ...
-2
votes
0answers
19 views

First time using recursion and it is not working the way I expect [closed]

Ive been trying to do Project Euler recently and I got stuck on problem 78 in which part of the problem is getting the partitions of a number. I tried making code using recursion and pentagonal ...
-1
votes
1answer
32 views

How can I make my function handle an exception?

I have a function which looks like this def read_data(input_file_name): """ (str) -> list, list Read data from the path specified by the string input_file. Data looks like: 18, ...
0
votes
0answers
12 views

Wrapping sub class constructor call in super constructor call

I am trying to write an abstract class constructor, which would allow me to perform an action using a constant random seed without affecting the outside world. I figured out a way to use np.random....
0
votes
0answers
9 views

python : ImportError: dlopen failed: “/data/data/org.teammate.teammate/files/app/ibm_db_dlls/ibm_db.dll” has bad ELF magic

i am trying to use ibm-db in my python-android app. i am getting below error when app runs on android phone:- python : ImportError: dlopen failed: "/data/data/org.teammate.teammate/files/app/...
1
vote
1answer
15 views

regex match if word_B and word_C are within N words of each other, and word_A not in the M preceding words

Looking to match 2 words near each other, only if another given word is not preceding (meaning with possible other words in between). We can assume that if word A appears, it will be before word B, ...
2
votes
2answers
44 views

Translate a block of code to list comprehension syntax

I have 2 lists with the next structure and a pointer: list1 = [{'ip1':[1,2], 'ip2':[2,3]}, {'ip3':[3]}, {'ip4':[4]}, {'ip1':[1,2], 'ip2':[3], 'ip3':[5,6,7]}] list2 = [1, 3, 4, 10, 25] pointer = '...
0
votes
0answers
3 views

How to provide python3 access to HIDAPI?

Last year, OSX High Sierra was successfully outfitted with HIDAPI: brew install hidapi A HID device was successfully read with python 2.7 sudo python2 test5.py Python 3.7 was installed yesterday. ...
0
votes
1answer
43 views

How to use exit() in Python 3

import sys import time start = time.time() key = input('Type your key:') x = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', '...
0
votes
1answer
6 views

File (.tar.gz) download and processing using urlib and requests package-python

SCOPE: Which library to use? urllib Vs requests I was trying to download a log file available at a url. URL was hosted at aws and contained file name as well. Upon accessing the url it ...
-4
votes
1answer
32 views

Why does python returns out-of-bounds when it's not?

Seems to work fine in the first loop, but not the second one. Why is that? I think it should work without problems. import numpy as np rows = 20 seatsInRow = 1000000 randRow = lambda: np.random....
0
votes
0answers
10 views

pygame space invaders problems

I am trying to create a space invaders game and I have ran into some problems. 1. I want to randomly generate invaders at the start of the game and I want them to re spawn anytime I hit them with a ...
-2
votes
0answers
41 views

Python word jumble

The objective is to take a snip of a poem or phrase, run it through a logical sequence, call a function, and end up with the snip of the poem or phrased jumbled with longer words capitalized and ...
0
votes
2answers
28 views

How do you check if a file exists or not? [duplicate]

so I am trying to code for an RLE program. I need to compress and decompress files, but I struggled to check if a file exists or not. can you help me with this please! this is my programming so far: ...
0
votes
0answers
9 views

Polygon intersection for Numba/Multiprocessing

I know there are already hundreds of threads out there that treat polygon clipping (i.e. getting the intersection area of two polygons). In my case, there are up to a few hundred thousand polygons ...
-1
votes
1answer
23 views

add together numbers from an array who have 3 factors only

array = [3,6,7,9,21,100] so only 6 and 21 should be added together below is what I have tried def getFactors(n): # Create an empty list for factors factors=[]; # Loop over all factors for i in ...
-1
votes
1answer
14 views

Pyton erro “AttributeError module 'string' has no attribute 'lstrip' ”

When starting this code, I can’t save the file found on the website. I get an error "AttributeError module 'string' has no attribute 'lstrip' " I can not solve the problem with " string.lstpri" , ...
0
votes
0answers
6 views

cannot do label indexing on with these indexers (Animation)

I was trying to animate a plot from a csv. I am working at google colab fig, ax = plt.subplots() xdata , ydata = [], [] graficar, = plt.plot([],[],'b*') def init(): ax.set_xlim(0, int(len(planetas[...
0
votes
2answers
51 views

How to print all the values of the list?

I have a function which looks like thus class Data: def init(self, x, y): """ (Data, list, list) -> NoneType Create a new data object with two attributes: x and y. """ self.x =...
0
votes
0answers
18 views

Matplotlib savefig background always transparent

Problem I cannot seem to get savefig() to actually save a PNG file without a transparent figure background. This is having read and tried all the suggestions previously posted, answered, cursed ...
-3
votes
1answer
15 views

Coding with python software and using .py files - security re internet attacks?

can somebody explain to me please: 1) Can a python ".py" file just by its mere "existence" on your hard drive (if not opening it), cause any kind of malicious harm for your computer system? And if ...
0
votes
0answers
9 views

How to extract dictionary attribute from XML file? (Biopython)

I am analysing some protein data from UniProt and am filtering out some of the unwanted attributes in the XML file. Each record looks like the following: ID: Q6GZX4 Name: 001R_FRG3G Description: ...
-3
votes
1answer
20 views

Can I add to the value at a certain index in a list? (Python3.7) [duplicate]

Random_list = [(40,40)] Random_list[0][0] += 10 Print(random_list[0][0]) This is an example, in this program the goal is to output 50, I want to add 10 to the index of 0, this gives me an error. I’m ...
0
votes
0answers
15 views

Converting from one numpy dtype to another in python

import datetime import pytz refdate=datetime.datetime(2019,1,1,0,0,0,tzinfo=pytz.UTC) for obj in datetime_list: print(obj) print(refdate) dt= obj-refdate obj='2019-12-05T16:41:55.176647' ...
-1
votes
0answers
11 views

how to split dict in list with python

I have a file like : 0 [{'id': '976', 'firstname': 'John', 'surname':... 1 [{'id': '982', 'firstname': 'Abhijit', 'surnam... 2 [{'id': '980', 'firstname': 'Peter', 'surname'... 3 [...
0
votes
0answers
19 views

overlay one part of image onto another image

There are two corresponding images, the second one reflects the mask area of the first one. How to over lay the red area in the second image onto the first image?
0
votes
1answer
15 views

How can I read and process 100 bytes at a time from a large CSV file?

The below csv is only a snippet of my main data file. customer.csv customer_id,order_id,number_of_items 10,4736,9 5,3049,1 1,4689,3 6,4114,9 1,4524,15 2,3727,16 3,3507,7 7,3988,3 5,4993,16 6,1945,4 ...
0
votes
0answers
14 views

Python Tensorflow: Cast string to int64 is not supported

I am adapting this tutorial to my model. It uses the feature_column method with Keras. I am trying to do multi-class classification with an MLP using the buckets and one-hot encodes from ...
1
vote
2answers
25 views

Recursively generate all k-digit numbers whose digit-sum is n

I was working on a problem where I'm finding all k-digit numbers whose digits sum up the given n. I found how to do this and approach it as Integer Partitioning problem, however I would like to be ...
0
votes
0answers
9 views

How to move file from one folder to another in share point using python script?

I using python to download file from share point and moving to archive folder. The same script working fine in windows and not working in linux. In linux it is Downloading but not moving to specific ...
0
votes
1answer
25 views

Using re.search multiple times inside for loop to extract different field values in python

I want to retrieve all percentage data as well as integer/float numbers with units from an input text, if it is present in the text. If both are not present together, I want to retrieve atleast the ...