Were rewarding the question askers & reputations are being recalculated! Read more.

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

clustering in k-menas and how to use legend

I`m doing clustering for 27 houses that are consuming electricity for 2 years and I used the legend function to give a color to each house but what is happening is each cluster has a color and they r ...
0
votes
0answers
11 views

sort a list of TarInfo

i have a tar file but his members are not in the right order. import tarfile tar = tarfile.open("test.tar") tar_members = tar.getmembers()[1:] for elem in tar_members: print(elem) tar.close(...
0
votes
0answers
25 views

check for elements, if atleast 3 matches, then True

I'm working an a problem, where I need to get 4 input from the user, and if atleast 3 matches, then the output is True. The only problem is I can only use logical operators(or, and, not, nor, nand, ...
0
votes
1answer
22 views

Counter() function in for loop looks odd

I have a list of sequences to be found in the sequencing data. So I run a for loop to find the match sequences in a dataset, and used Counter() to get the maximum sequences. But I found the Counter() ...
0
votes
3answers
40 views

Python - Insert an element to a list only if some specific element exists in the list

I have a list of strings 'a' and I want to compare my list to a specific string 'b' and if that string is found in some of the elements of the list, I want to insert another element in the list 'a' ...
0
votes
1answer
17 views

Investigate “Bad System Call” on shutil calls with Python3.6 on Solaris

We moved from Python3.3 to Python3.6 on our Solaris environment and I now get this error on our Solaris setups: $uname -a ...
0
votes
0answers
8 views

Could not find the input entity for <telethon.tl.types.PeerUser object at

I am getting the error ValueError: Could not find the input entity for . Please read https://docs.telethon.dev/en/latest/concepts/entities.html to find out more details.. This error comes from client....
-1
votes
1answer
36 views

Changing the values like a switch-case?

I am trying to get the value of "a" like a switch-case. There are only two values for "a" which is either 0 or 18. Let's take 18 as the intial value, when the length of the name is less than or equal ...
0
votes
0answers
6 views

tkinter - How do I keep the Add Keyword button disabled until TRUE has been returned for all three Entry fields?

Please be gentle! I have well over 40 years of mainframe programming experience with CICS COBOL, Cool:Gen, Access VBA, DL/I, IDMS, DB2, Oracle, and SQL Server but I am a complete novice with Python, ...
21
votes
9answers
56k views

Printing an int list in a single line python3

I'm new to python and I'm trying to scan multiple numbers separated by spaces (let's assume '1 2 3' as an example) in a single line and add it to a list of int. I did it by using: #gets the string ...
0
votes
1answer
13 views

How to click on next page by using xpath

from selenium import webdriver from bs4 import BeautifulSoup as bs import time url = 'http://dciindia.gov.in/DentistsSearch.aspx?Reg_Type=D&RegUnder=0&IDRId=&IDRName=&CourseId=0&...
0
votes
0answers
13 views

Vague Mid Term question, can I improve this?

While attempting to study for my upcoming midterm, I was given a practice question "Very Similar" to the exam. The question is : 4.) Complexity. The vehicle is a complex machine. The system needs to ...
0
votes
0answers
15 views

Is there a function in python that can download Microsoft Forms excel sheet?

I created a Microsoft Form survey using google chrome, where I sent the link to different individuals to complete the survey, now I would like to see all the responses from individuals that have ...
0
votes
0answers
12 views

Splitting in python by using while loop

df = df.sample(frac=1) # randomly reorder the whole dataframe n_rows = len(df) train_idx = n_rows // 2 test_idx = train_idx + n_rows // 4 train = df.iloc[:train_idx, :] test = df.iloc[train_idx: ...
0
votes
1answer
15 views

Supressing the output when fitting a Keras model

I have designed a NN with Keras and the code after defining the model are the following: model.compile(optimizer= 'Adam',loss='mean_squared_error') ##callbacks cb_checkpoint = ModelCheckpoint("model....
0
votes
1answer
15 views

how do i move on to next page while there is no next button only numberings are available?

how to move on to the next page as there is no next button or something like that , they providing only numberings. from selenium import webdriver from bs4 import BeautifulSoup as bs import time url ...
0
votes
0answers
9 views

Nginx + uWSGI + django NoModuleFoundError: No module named 'saleor'

Python 3.6.8 to create venv uwsgi installed in venv and is properly symlinked and using the correct python version nginx installed system wide just trying to get the most basic uwsgi --ini myinifile....
0
votes
0answers
29 views

Task from python mid exam, list in dictionary, dictionary in list

so this was the last task in python middle exam at my university(first course) and I could not figure out how to complete it. So, there was a dictionary of wagons, seat names and availability of them(...
1
vote
0answers
38 views
+50

Python mock multiple queries in a function using pytest_mock

I am writing unit test case for a function which has multiple sql queries in it.I am using psycopg2 module and trying to mock the cursor. app.py import psycopg2 def my_function(): # all ...
0
votes
1answer
19 views

How to increase instance variable in class method in Python

I am stuck in this question (part two). The question is as follows: Create a class called AppleBasket who's constructor accepts two inputs: a string representing a color, and a number representing a ...
-1
votes
2answers
38 views

division of binary numbers by 2 and 8

I need to chceck if some binary numbers are divisible by 2 or 8 and tell how many there is. I now that binary number is divisible by 2 when the last digit is 0 and by 8 when last 3 are 0, so this is ...
0
votes
1answer
21 views

how to change python script into a server

I am currently working on a project where this project requires a server to be connected to the Android project. I am confused how to make the python script that gonna be a server here the following ...
0
votes
1answer
19 views

Can't Install Python Pandas in 3.6.6

I am Mac user and trying to install Pandas in Python 3.6.6. to use in IDLE / VS Code to do my work. Hasans-MacBook-Pro:~ hasan-macbookpro$ python3 --version Python 3.6.6 Hasans-MacBook-Pro:~ hasan-...
0
votes
0answers
11 views

Python3 shorten absolute windows unc path without using pywin

I am not able to copy files with too long paths because of windows' limitation (I can't upgrade to a newer Windows 10 version). I work with absolute UNC pathes and not able to change these ...
0
votes
0answers
9 views

page rank algorithm in pyspark ( only 1st element is getting computed)

Question:There are 100 nodes (n = 100) in the small graph and 1000 nodes (n = 1000) in the full graph, and m = 8192 edges, 1000 of which form a directed cycle (through all the nodes) which ensures ...
1
vote
0answers
27 views

SSL Error (bad handshake) with valid certificate | Elasticsearch & Python

I am passing data to Elasticsearch (ES) through a Python script. First, I secured ES with a self-signed certificate and everything works as expected. Then, I switched to a more trusted certificate (...
0
votes
0answers
18 views

How to solve __array_function__ internals source error?

I'have a problem and can't figure out where the bug is. While running mt script I get as error : Could not load source '<array_function internals>': Source unavailable. The point of my ...
0
votes
0answers
30 views

how to collect data from continuous set of urls

I am trying to retrieve words from online dictionary for scraping. Words are from a range of URLs (from "https://dic.example.com/word/view.do?wordid=ekw000000100" to "http://dic.example.com/word/...
7
votes
4answers
9k views

How do I import a module from a different folder in Python?

I have a project which I want to structure like this: myproject __init__.py api __init__.py api.py backend __init__.py backend.py models __init__.py some_model.py Now,...
0
votes
2answers
16 views

is it possible to get element from tuple of named tuples by key?

i defined this named tuple _validation_message = namedtuple("_validation_message", "validation msg") and use it as a value inside a regular tuple like this: _messages = ( ...
0
votes
1answer
25 views

Loop untill random name matches my spesified name [Python]

I am trying to let the computer choose randomly between the letters until it matches my name. Each time it fails to match, it prints the wrong name and continue automatically until it matches the ...
0
votes
1answer
21 views

Django CustomUser Function

I created a CustomUser as follows, however, I am not able to use the CustomUser functions in Views as I get the error message "get_first_name() missing 1 required positional argument: 'self'" when I ...
2
votes
0answers
22 views

Finding a modified image - image forensics

I have a couple of standard ways of detecting a modified image such as Luminance gradient Copy move detection Metadata Extraction Histogram analysis ELA(Error level analysis) Quantization matrix ...
1
vote
0answers
21 views

How to use a shared library e.g web3 in C python API in mutiple sub interpreters

I am working with C Python API and using sub interpreters to make threads. I want to use python web3 library in sub interpreters but web3 is a thread safe library. How I can use it in all threads. If ...
0
votes
2answers
13 views

Python that takes a string and displays that string centered within line_width characters

Hello guys for example; def right_justify( in_str): print("+" * 5,in_str.rjust(11),"+"*5) right_justify("Hello") my function prints out; and why prints out like this? +++++ Hello ++++...
0
votes
2answers
23 views

convert date to week and count the dependencies from different columns of a dataframe

I have a dataframe like this: date Company Email 2019-10-07 abc [email protected] 2019-10-07 def [email protected] 2019-10-07 abc [email protected] 2019-10-08 ...
0
votes
0answers
12 views

How to use REQ and REP in pyzmq with asyncio?

I'm trying to implement asynchronous client and server using pyzmq and asyncio in python3.5. I've used the asyncio libraries provided by zmq. Below is my code for client(requester.py) and server(...
0
votes
1answer
21 views

Getting the list of list of combinations value from itertools [duplicate]

How can i obtain the list of list of combinations combi=list() for i in range(1,4): combi.append(list(itertools.combinations([1,2,3],i))) print(combi) Results [[(1,), (2,), (3,)], [(1, 2), (...
1
vote
2answers
1k views

BubbleSort with recursion in Python3 - Returning “None”

I created a small function to do BubbleSort (just learning how to code) in Python 3 and I can't find the issue. Here is the code. It's returning "None" for some reason. Could someone please take a ...
1
vote
3answers
43 views

How to read integer values from a textfile and count the of occurrence of each value in pyspark

i would like to read the from a text file shown below, loop through each individual digit and determine which digit occurs the maximum number of times. How can I go about it in pyspark. Here is the ...
0
votes
0answers
46 views

How do i remove a lists last index depending on chosen input in python 3x?

Lets say i have two list which is set up like this: deckList = [deckOne, deckTwo, DeckThree, DeckFour, deckFive, deckSix, deckSeven, deckEight] deckNames = ['A','B','C','D','E','F','G','H'] The "...
0
votes
0answers
10 views

Extra blank lines in csv file when directing from stdout

When the output of this program is redirected into a csv file there is a blank line between the two lines of output. The other solution I found on S.O involved changing the way that the output file ...
-3
votes
0answers
26 views

how to add multiple dict inside a list in python 3 with same key?

Having multiple dict within a list like given below, how would I perform grouping followed by sum of amounts from persons who has the email id as condition (same email address). { "...
0
votes
0answers
15 views

How to change the color of the highest value in Barplot [duplicate]

My Graph This is my Code values = df1['date_year'].value_counts().sort_values(ascending=False) labels = values.index plt.figure(figsize=(15,8)) bar = sns.barplot(x=labels, y=values, color='navy') ...
0
votes
1answer
24 views

Getting value error of “The truth value of a Series is ambiguous..” while checking for equality between sub-strings in a string

I'm trying to check if a specific "Route" string starts and ends with the same sub-string but I'm getting an error of "ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a....
0
votes
2answers
40 views

Create a dictionary using the row number in a csv file [Python]

I have a CSV file containing survey data on 60 participants. The first column is the participant's number, and for each number corresponds all the data collected from that participants. It looks ...
-1
votes
0answers
19 views

Extract Patterns from text in Python [on hold]

I want to fetch phrases from the text which follows some pattern as well as I have to sentiment Analysis of those phrases . For Example: 1) Adjective followed by one or more noun . 2) Adverb followed ...
0
votes
1answer
22 views

Prediction with linear regression is very inaccurate

This is the csv that im using https://gist.github.com/netj/8836201 currently, im trying to predict the variety which is categorical data with linear regression but somehow the prediction is very very ...
-3
votes
0answers
20 views

Printing subscript decimel and percent sign in python

In python3, is there any way to print subscript decimel and percent sign? e.g. E0.1%(subscript 0.1%)
0
votes
0answers
16 views

get fitted model object for each cross validation split

Is there a function that can give all the fitted model objects for each cross validation split. In sklearn library, GridSearchCV keeps only the scores and the best model, cross_validate returns only ...