Category "python-3.x"

Summing row values after a groupby but based on a dictionary condition?

I am trying to figure out how to add row entries of the numeric columns(supply,demand) . I am at a complete loss. My initial thoughts are to do this with a dic

Catching SyntaxError from ast.literal_eval

I have the following code to evaluate some configuration values stored in a file: from ast import literal_eval for key, value in dict_read_from_file.items():

Sum of list values in a df, new column, values are objects

I have a df made of values from a dictionary. I can get rid of [], ',' and split it all in different cols (one col per number). But can't make the transfer to f

Select subset of test cases from all possible combinations

Let's say I'm writing a lifespan prediction calculator that takes in ~40 inputs: sex = ['Male', 'Female'] smoking_status = [True, False] ... Eventually, there

How to create new dictionaries from nested dictionary?

I have a nested dictionary. How do I access them and get the result as follows: dict_lbl = { "lbl1":{"name":"label1","item1":"Accounts", "item2":"kannagu"

Django ManyToMany validation in model layer

I have model with manytomany field and the task is to make an validation in model layer. When i run this code, this error occurs: ValueError at /admin/main/boss

Plot Python surface with non-square data

I ran a series of simulations and want to create a response surface of the performance based off my two parameters, tol and eta. The issue I'm having is actuall

XA transactions for ActiveMQ in python

We want to have a distributed transaction publishing between two ActiveMQ brokers. The ActiveMQ documentation states they support XA transactions. Our code base

pytorch_lightning.utilities.exceptions.MisconfigurationException when training in pytorch lightning

I am training a sample model with dummy data then i got this error. I have gave everything properly but still i am getting this error: No `configure_optimizers(

NameError! I am following Django tutorial in part 5 when try to run test, getting error

[enter image description here][1] [1]: https://i.stack.imgur.com/2wDSL.png NameError! I am following Django tutorial in part 5 when try to run test, getting e

Listing files and folder in Sharepoint with Office365-REST-Python-Client responds : 404 not found error

I am trying to list files from a folder. It works with folder name with spaces but doesn't work when folder name contains '#'. I am getting below error office36

Using fstring with nested quotation marks for a xpath - triple quotes didn't work

/!\ The problem here is a f-string problem; I know how to click the "onclick" element in another ways, but I want to understand why it doesnt work THAT way /!\

How to handle the variable size json file in python to create DataFrame using pandas

I am trying to build a DataFrame using pandas but I am not able to handle the case when I have the variable size of JSON chunks I am getting. eg: 1st chunk: {'a

The results of python's work should be written to a text file, python 3

I have a problem and I don't know how to solve it. There is a code in which I get the result of the found registry (its output) to the terminal. But, I need to

Django context processors available globally to templates in ALL apps

I am new to Django/Python, and am trying to figure out the best way to have global constants in my project that are available to templates in ALL APPS in the pr

Telethon Is Not sending The Code to Sign up With New Number using send_code_request

ph = input("Enter Phone Number: ") async def sign_up(): try: x = await bot.send_code_request(ph, force_sms=True) print(x)

Pyspark how to join common columns values to a list value

i am trying to join columns values to a list of values df1= name | department| state | id| -----+-----------+-------+---+ James|Sales |NY |101 Maria|F

Pandas to read a excel file from s3 and apply some operation and write the file in same location

i am using pandas to read an excel file from s3 and i will be doing some operation in one of the column and write the new version in same location. Basically ne

list values into entry widgets

I am trying to put list values into entry widgets, keep getting brackets and quotes. lista = ['abc', 'def', 'ghi'] # These are normally strings, but can be inte

Why doesn't this simple multiprocessing function work?

I am just learning about multiprocessing in python. And when I am trying to run the code I receive these problems. Code from multiprocessing import Process, cpu