Category "python"

Asking the user for input until they give a valid response

I am writing a program that accepts user input. #note: Python 2.7 users should use `raw_input`, the equivalent of 3.X's `input` age = int(input("Please enter yo

How to web scrape the text under <i class>?

I'm trying to get the text "PDF file" under <i class="fa fa-file-pdf-o">. I'm using BeautifulSoup and tried the following, but it didn't work: from bs4 im

How to append data properly in the next line of an array?

def FunctionA(): ... ... ... sol #Here,sol is an array output = [] for i in sol: output.append(FunctionB(i)) print(output) print(output[0,:]) def Function

How to web scrape the text under <i class>?

I'm trying to get the text "PDF file" under <i class="fa fa-file-pdf-o">. I'm using BeautifulSoup and tried the following, but it didn't work: from bs4 im

Flask app routes not importing, all pages show 404. Passenger WSGI on DreamHost

I've got a Python Flask app that's working perfectly in my local environment, but when I try to get it to run on a DreamHost server all my pages turn up 404 err

pygame movement speed is not constant [duplicate]

I recently started with pygame and im trying to create movement but when I move my rectangle the speed changes at various times. it becomes sl

Function failing to update spacing after comma

I have a csv file that has inconsistent spacing after the comma, like this: 534323, 93495443,34234234, 3523423423, 2342342,236555, 6564354344 I have written a f

How can I let a while loop pause for a specified time (datetime)?

I would like to let a while loop run, the stuff thats happening inside takes about 2 seconds to complete (it varies a small amount), so if I use time.sleep(60 o

How can I let a while loop pause for a specified time (datetime)?

I would like to let a while loop run, the stuff thats happening inside takes about 2 seconds to complete (it varies a small amount), so if I use time.sleep(60 o

Python complex iterating through excel files to concatenate colnames that are not named equal

I have multiple xls files in a directory. each file dataframe headers are different but data type is same. 1.xls Location StreetAddress America Pvtld 80

Pandas: Values to columns and then group and merge by same Id [duplicate]

I have a dataframe like this df = DataFrame({'Id':[1,2,3,3,4,5,6,6,6], 'Type': ['T1','T1','T2','T3','T2','T1','T1','T2','T3'],

How to scroll down to last row with data?

I have an Excel file with many rows and it gets many entries daily. That's why I would like to scroll down the file to last row with data. To find the last row,

How I can connect each name in list using id concept (python)

I created a list of users page and user profile page and I want when click on any name in the list it should show that user profile page. in .html <table cla

Models in Tensorflow Federated get stucked at 0.1 accuracy

I'm trying train a federated model for the mnist dataset. I am using the code avaible at https://www.tensorflow.org/federated/tutorials/simulations for the setu

Antialiasing images in pyqtgraph ImageView

I am using PyQtGraph and am really enjoying it, but have hit upon an issue that may force me to move to something else. I am displaying medical images (CT/MRI e

How to authorize multiple Telethon accounts?

Good day. The question is: Conventionally, there are txt files, one contains api_id, the other api_hash. Whether it is possible to register somehow that the dat

How can I repeat a game over and over, for example guess game

I have seen many ideas about how to reply a game but none of them worked for me. import random list_number=["","","o"] random.shuffle(listing) def player_choice

creating dictionaries from values in pandas columns with repeating values

Considering this sample dataframe: location emp 0 fac_1 emp1 1 fac_2 emp2 2 fac_2 emp3 3 fac_3 emp4 4 fac_4 emp5 It can be recreated by

Consult chat reports using admin sdk google workspace

I'm new to integrations with the API SDK GOOGLE, and I need to consume the Workspace activity reports regarding the use of google Chat, I configured the followi

Dictionary difference similar to set difference

I have a dictionary and a list: dictionary = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6} remove = ['b', 'c', 'e'] I need to split "dictionary" into two dictiona