Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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, add the [python-2.7] or [python-3.x] tag. When using a Python variant or library (e.g. Jython, PyPy, Pandas, Numpy), please include it in the tags.

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

Python Format Specs examples

I'm trying to understand using the python Format Specs for formatting some values. It says that the format of format is: format(value[, format_spec]) And an example of this to format a number could ...
0
votes
0answers
6 views

Add extensions to contacts using Python and Microsoft Graph

I'm trying to add extensions to contacts using Microsoft Graph but I keep getting 500 errors back. I think it is something to do with the token but I just can't work it out. I've tried all methods ...
-1
votes
3answers
20 views

Why Join Function isn't working when I converted my list to string

I expected the output to be 123 using Join function but am not getting the desired result f=['1','2','3'] p=str(f) k=''.join(p) print(k) output: ['1', '2', '3']
0
votes
0answers
5 views

Customize a view handle POST and DELETE method in django rest framework

I created a View that can handle POST and DELETE method class MyView(APIView): def valid_method(self,data): method = self.request.method if method == 'POST': ...
-5
votes
0answers
16 views

Is there a website or software that can take input and output a specific string of formatted text? [on hold]

def unlock_doc (): u = input("caller/ requester?: ") a = input("Analyst Full Name?: ") s = input("Server?: ") db= input("database?: ") dn = input("document number?: ") v = input("version number?:...
0
votes
0answers
6 views

Scraping two pages at the same time : pandas error

I want to save movie reviews and movie's title from those two pages. https://movie.naver.com/movie/bi/mi/pointWriteFormList.nhn?code=~ https://movie.naver.com/movie/bi/mi/basic.nhn?code=~ And when I ...
1
vote
0answers
7 views

how to fix class-accuracy of my classifier

I am trying to see the accuracy of my image classifier for each class of my data. However, I am quite a beginner and I am trying to use the code provided by Pytorch tutorial on training a classifier. ...
-2
votes
1answer
20 views

how to take an input and put it in a list in a dictionary

How do I take an input and append it as a list in a dictionary. So far I've tried: add_fruit = dict((input('Enter fruit follow by prices:').split(','' ') for i in range(x))) fruits.update(...
-1
votes
1answer
16 views

Is it possible to create two ranges for a randint in Python?

I'm fairly new to Python and am trying to find a way to generate two separate, random numbers. I'm using a randint with a range of 0 - 100: (randint(0, 100)) Is there any way possible for a newbie ...
0
votes
0answers
5 views

Alternate to tkinter text box (inserting StringVar)?

I am very new to python (coding at all for that matter) and and this website. I am making a small Dice Roll program and I wish to display the results of each roll inside a text box (entry or label) ...
0
votes
1answer
10 views

Extracting and then combining Street Address and Apartment Numbers in pandas

I'm having a really challenging time coming up with the code needed to perform the below. There's a similar question with this but I can't figure out how to adapt the code to what my needs are ...
0
votes
0answers
10 views

Add contacts to Google Contacts using script: wrong format

Here's the code: import pandas as pd input_file = input("Ingresá el nombre del archivo Excel fuente con la extensión(.xlsx):") value = input("Ingresá tu provincia:") prefix = input("Ingresá el ...
0
votes
2answers
15 views

For a pandas DataFrame column, convert a list of lists into a list of tuples

I have the following pandas DataFrame: import numpy as np import pandas as pd df1 = pd.DataFrame({'A': [1, 2, 3, 4, 47, 27], 'B': [5, 6, 7, 8, 21, 40], 'C': [9, 10, 11, 12, 45, 33], 'D': [3, 4,...
0
votes
0answers
12 views

Python rock, paper, scissors, adding counter (scoreboard), 5 tries excluding tries

I have my code, it runs pretty great. But I am stuck at two things. I need to add two things to get it to be correct. 1) It can only have 5 tries, thus the output should be Computer Win = 5 Player ...
0
votes
0answers
7 views

Pandas Correlation - Handling 0s on both columns

Situation: I'm working with a large dataframe, around 100 columns and around 2 million rows. The goal is to find the correlation between each column. But the dataset has a lot of 0 values in each row, ...
0
votes
0answers
11 views

How to communicate multiple images using ZeroMQ in C++?

I want to implement the program that can communicate multiple images via ZeroMQ. I can display multiple images on C++ by using OpenCV but I cannot display on Python somehow although the compiler didn'...
1
vote
0answers
14 views

How to optimize percentage check and cols drop in large pyspark dataframe?

I have a sample pandas dataframe like as shown below. But my real data is 40 million rows and 5200 columns df = pd.DataFrame({ 'subject_id':[1,1,1,1,2,2,2,2,3,3,4,4,4,4,4], 'readings' : ['READ_1','...
0
votes
1answer
18 views

Write a while loop that prints from 1 to user_num, increasing by 1 each time. Sample output with input: 4 1 2 3 4

ive tried multiple different ways but all are infinite loops or recursions, i = 1 user_num = int(input()) while user_num > 1: print(user_num - (user_num - 1))
1
vote
1answer
9 views

How to find these check box elements in Selenium

I can't locate the check boxes on this site in Selenium I have tried: Xpath, ID, Type, Actionkeys, Text and partial text. I've been able to send keys (user and password) and locate the user / pass ...
0
votes
1answer
19 views

Requests post json with python

my problem is when i'm run the response.url from the browser I have the write answer that I'm looking for: https://www.google.com.ar/?code=TG-MYCODE but when I do the requests.post from python and try ...
1
vote
1answer
25 views

Call a method in a class many times and the variable stays consistent

Writing a hangman program for Python and want a variable (self.masked_word) to stay consistent as I call the method many times... For instance if the secret word is 'hello' and I play: game.guess('...
0
votes
0answers
19 views

how to combine dataframes having unequal lengths

we have the daily predictions for the data as shown in figure. We also have the mean hourly ratio (0-23 hours). Hr ratio 0 0.044287 1 0.035343 2 0.029911 3 0.024714 4 0.020802 5 0.018621 How can ...
0
votes
0answers
6 views

How to pass a function from view.py to html

views.py def detect_full_text(tweet): if 'retweeted_status' in tweet.*_json*: analysis_tweet = tweet._json['retweeted_status']['full_text'] else: analysis_tweet = tweet.full_text return (...
2
votes
2answers
20 views

How to code result of word search to count number of occurence of word

new to programming here and trying to work through an online course with minimal assistance. I believe my code is 99% correct but the result is not doing what I need it to. I am trying to count the ...
-1
votes
0answers
8 views

How to find the corner of a contour?

I have those two images. I want to find the corner of each binary image. I've tried the cv2.boundingRect to find the corners, but it's not accurate. How can I find them accurately?
0
votes
0answers
9 views

Using LXML To Return Title Text

I am working on a school project and I am using LXML and it's .xpath function to try to get the titles for the top videos on a youtube search that you can pick. My problem is when it is iterating ...
1
vote
1answer
26 views

How to split sublists of single list in python using split function?

I have a single list and there is multiple sublists so the question is how to split them using split. I can do it using for loop and I think it is a little longer process. Here is the python code ...
0
votes
0answers
18 views

How to extract text from website when clicking on something does not affect the link?

I want to extract the addresses mentioned in this link. In the link, if we go to the "Directory" tab, then "Select a Territory", then "Select a City", and then click on one of the branch names that ...
-1
votes
1answer
26 views

Writing neat branching conditions

Problem I have 5 boolean variables is_A through is_E and their combinations correspond to different downstream operations. However, currently I need to write a 32 conditionals that look like if xxx: ...
0
votes
0answers
11 views

SendMessage winapi Python

I think it's easy, i found some winapi example but i don't understand how they work. I want send a message on a "process", like 'notepad.exe' how can i? Ex: i press number '1' script send & write ...
0
votes
1answer
20 views

Python requests irritatingly slow

I made a program to find available /id/ on Steam using requests, but it takes a very long time. If anybody knows any way to make requests faster, please inform me of this. w = open("not taken.txt", "...
0
votes
0answers
6 views

Using a selenium wrapper called “splinter” to interact with browsers and running into an error

Getting a "Message: 'chromedriver' executable needs to be in PATH." error. Here is the code so far: from splinter import Browser browser = Browser('chrome') browser.visit('http://mail.com') Anyone ...
-2
votes
0answers
14 views

Selecting top row in a sorted dataset with given conditions

For the below dataset I want to select the top row given condition matches. col1 col2 col3 1 3 test1 1 4 test1 1 5 test1 1 6 test1 for the above dummy data i want ...
1
vote
2answers
25 views

How can I add a combination of digits to each word in file?

I neeed to append/add a combination of 2 digits to each word in a text file. For example, word test try I want it to be word22 test35 try65 but the text file contains hundreds of words that should ...
0
votes
0answers
13 views

Using python threads to access a lot of data

I have a lot of panda data frames. I am geting information from them and then returnig some informations. Because the function i am using takes a lot of time, around 5s per loop and i am making a lot ...
0
votes
0answers
6 views

How do you do calculations using various variables in a toplevel window?

I'm creating a calculator app for my company which will be used for the calculation of certain parameters.Since there are various parameters with their respective formulas,I decided to create toplevel ...
0
votes
0answers
12 views

Azure Databricks with Python scripts

I am new to Python. Need help with Azure databricks. Scenario: Currently I am working on a project which uses HDInsight cluster to submit spark jobs and they use Python script with classes and ...
1
vote
0answers
11 views

What keyword arguments does setuptools.setup() accept?

What is the full list of keyword arguments that the setuptools.setup() function accepts? (Please include a description of what each argument means, if possible.) I have looked all over the web and I ...
0
votes
0answers
36 views

ValueError: invalid literal for float()

I am trying to read lightware rangefinder SF11 through serial but using Raspberry, and I am not familiar with Python, but I tried this: import time import serial print('Code is Running.') # Make a ...
0
votes
0answers
6 views

How to determine the arrangement of the polynomial when displaying it with latex?

I am not sure if it is an issue with my python code or with the latex but it keeps rearranging my equation in the output. Code: ddx = '\\frac{{d}}{{dx}}' f = (a * x ** m) + (b * x ** n) + d df = ...
0
votes
1answer
30 views

Solving Shrodinger's equation for a particle in a harmonic potential well

Hello (this is my first time posting in stack overflow), I am trying the calculate the first 3 energy levels of a particle in a harmonic potential using the shooter method The code is adapted from a ...
-1
votes
0answers
19 views

Best python code to loop through Twitters followers using Tweepy

I am struggling to work out the best way to interate through my followers in Twitter using the Tweepy API. I have tried the following but it doesnt return all my followers. Any help would be much ...
0
votes
0answers
14 views

python3 pip fails to install jupyter on windows 10

I want to install jupyter on Win 10. I have been using python on linux, but this is my first time on Win 10. when I execute python -m pip install jupyter on administrator, I got errors like this: ...
0
votes
0answers
6 views

Regex to match only book('knjiga') with specific name('naslov')

I have a simple xml: <?xml version="1.0" encoding="utf-8" ?> <book_list> <book rbr="1" > <title> Yacc </title> <author> Filip Maric </author&...
0
votes
0answers
6 views

Why cann't i not access media

I seem do not understand what i am doing wrong. I have done research online to see if there is any changes, but yet none. Bellow is what i did settings.py STATIC_URL = '/static/' STATIC_ROOT=[ os....
0
votes
1answer
15 views

Re-sample df to microsecond - Pandas

I am trying to re-sample timestamps in a df to display every 0.1 seconds. It is re-sampling but I'm losing the data relative to those timestamps. d = ({ 'Time' : ['2010-07-27 09:25:31.1','2010-...
0
votes
0answers
7 views

Using GridSearchCV to find the best performing combination of groups for a specific Estimator, which Scikit Learn tools are available?

Assuming I have data that looks like this: | group_id | x1 | x2 | y | |----------+----+----+---| | 1 | 0 | 0 | 1 | | 1 | 0 | 0 | 2 | | 2 | 0 | 0 | 3 | | 2 | 0 | 0 |...
0
votes
2answers
22 views

Change starting column header and read the next row while reading multiple files

I will like the 'name' row to be the starting column header for all the files. After column header is done, I want the data to start after the it. I have 3 files (+ more) and the columns are in ...
0
votes
1answer
11 views

Highlight words in a docx file and display in which line they appear and how many times in each, read 2 docx in python

My python program should read 2 files one file with the words to search and another file which is were the program should look up for the words. I already found how to open one file, but cannot make ...
0
votes
1answer
21 views

Why some websites are not automatable using Selenium chrome

I tried automating https://myaccount.payoneer.com/MainPage/SetAccount.aspx web page but couldn't figure out why website is not navigating to next page. My script is opening page -> Entering user and ...