Category "python"

Best way to provide admin role from Django REST to ReactJS

The default django user model has a is_superuser field. I would like to use this field to conditionally render components in react, i.e. get something like this

How to directly save spectrogram image to specific pixel size

I am generating spectrograms and casting them to images for use in a CNN. How can I directly specify the pixel size of the spectrogram. This is what I have so

1TypeError: document must be an instance of dict, bson.son.SON, bson.raw_bson.RawBSONDocument, or a type that inherits from collections.MutableMapping

I am new at pymongo, but have a decent knowledge on mongoDB So basically I have a list of strings, then I converted it into a dictionary using key as integer, s

Is there any way to animate a preexisting slider in plotly?

r = np.linspace(-1,1,1000) intervr = 1/2 theta_const = np.arange(0,90+intervr,intervr) figr=go.Figure() for i in theta_const: xr,yr,zr = coords_r(r,i) f

Install grpcio via pip: "legacy-install-failure"

I want to install grpcio with pip(version 1.35). But I get this error: note: This error originates from a subprocess, and is likely not a problem with pip. erro

Can I return a single backslash in a JSON response in FastAPI? [duplicate]

Seems like a really simple question and it's not clear what the correct answer is here. We understand that backslashes are a special delimiter

Using exec to set button image in Python - is there a better way?

I'm writing a Python code for tkinter to set various images for four different buttons. I send to the method a list of four integers, 0-3, and it sets the image

Created Field(DateTimeField) auto_now_add=True is not working in Abstract Class in Django

class TimeStampMixin(models.Model): id = models.CharField(max_length=60,editable=False,primary_key=True,default=generate_unique_id) created = models.Dat

Replacing the Opencv with my changes used by opencv-python

I am Working on a project which uses opencv-python. Due to few specifications I had to make few code changes in the opencv code( Received from open source). Now

Unable to upload file with python request

I have a form i want to fill out that contains a file and a few fields. If i do a post with just the fields values enters it works but it doesnt if i include th

Add channels to / edit existing tdms files?

I have a naive question but did not manage to find a clear answer. I have some .tdms files with channels of data. I would like to add additionnal channel of dat

Polars: how to add a column with numerical?

in pandas: df['new'] = a where a is a numerical Series or just a number. while in polars we can add a char df.with_column( [ pl.all(), pl.lit('str'

Why do I keep getting this Attribute Error?

Every time I run my code it pops up the message saying "'ICU' object has no attribute '_name'. Did you mean: 'name'?" I can not figure out how to fix it. I've t

How can I convert a string to dictionary in a manner where I have to extract key and value from same string

I need to convert string to dictionary in a manner for example str1 = "00001000-0009efff : a 00100000-656b2fff : b" Output what I require is dict1 = {'a':['000

Python3 unicode strings with pyobjc

I'm converting a lot of python2 scripts that use pyobjc to python3, and having trouble getting them to work. The problem seems to relate to the Unicode changes

How to run an EXE program in the background and get the outuput in python

I want to run an exe program in the background Let's say the program is httpd.exe I can run it but when I want to get the outupt It get stuck becuase there is n

Choose the rows with special conditions in dataframe

I have a dataframe, I want to choose the rows which their average value for column val1 until val4 is greater than 1 and the number of zeros for the row is not

What's the best way to setup a google smtp server for noreply E-Mails sent from a Python application?

We are currently developing a python program that as part of its functionality sends noreply E-Mails to customers whenever something important happens. For test

Python how to automate to pass yes/no to the remote terminal

I have to run multiple show commands to network devices. by using netmiko connected via ssh to the device and executing multiple commands. some commands are bei

How do you perform an operation on a phrase *only* if it's outside backticks?

E.g. say you have the line: `Here's an example.` And another example. How could you change only the second "example" to uppercase? E.g: `Here's an example.` An