How can I rewrite this so that it does not repeat?
Stack Overflow » Python
by Bobolinger87
1m ago
I'm looking for suggestions on how I could rewrite this so that the code isn't repeating. It's suppose to separate the float(digits) from the string(alphabetical characters) within a dictionary's value, and subtract or add a user's numerical input to the float. Afterwards, it rejoins the digits and the letters, converts them back into a string and stores the value. An example of what it should do is take "19.0: chicken" from the dictionary, split it, add 3 from the user's input, and return "22.0 chicken" to the dictionary. if modify_options == "1": quantity_value = float(re.findall(r"[0-9 ..read more
Visit website
How to create AWS EC2 instance using Boto3 for a specific account?
Stack Overflow » Python
by rare77
1m ago
I currently have a regular/non-organization AWS account and I create EC2 instances via Boto3 using code like this: ec2 = boto3.resource('ec2', region_name = region) instances = ec2.create_instances(...) I may need to change my account to an organization and create sub-accounts so I can use different credit cards to fund different accounts. However, I am concerned how much my existing Boto3 scripts will need to change. Looking at the reference page for create_instances(): https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2/service-resource/create_instances.html I d ..read more
Visit website
Gnuradio block for drop and pass samples by tag
Stack Overflow » Python
by Enrique Carrasco
1m ago
I'm trying to make a gnuradio Python block that passes samples after tags and then drops samples until the tag appears again. I can't find a method to drop samples within the gnuradio block. Are there any way to achieve this? I tried modifing the basic block, but I still need a way to drop samples. This post give some clue, but I need a small example to understand. Dropping samples with tagged streams ..read more
Visit website
How do I add a string to my itertools combinations script that will be sorted with my iterator but itertools won't generate all the combinations?
Stack Overflow » Python
by Thomas Higgens
1m ago
I want to add a string that will be sorted with itertools but itertools won't generate all the combinations of the string as the first 42 characters of my 70 character combinations string using itertools. Itertools normally sorts the string by the lowest number which is 0 and it goes up by 1 in the for loop when it's being generated. I have my own mapping that sets the character c to 0 so I want to be able to add a string which is all cs 42 times to an itertools combination so that it will be generated first since it's the lowest number. My code so far is: import itertools import random impor ..read more
Visit website
Why is my fine tuned model being saved as a safetensors file?
Stack Overflow » Python
by inter galactic
1m ago
since im fairly new to this im trying to understand things slowly but this one thing has confused me a lot, is there a way to save the file to .h5 format or to convert it to tflite ? is the model good for mobile applications ? i havent figured it out ,and i really don't know what to do with this safetensor file that seems to only hold the model and no weights i have fine tuned a vit model on a dataset so i wanted to save it, which i did using trainer.save_model(model_dir) i am using this particular model from huggingface model = ViTForImageClassification.from_pretrained('google/vit-base-patch ..read more
Visit website
Creating a software killswitch in order to stop a loop that is running too fast to stop from IDE in Micropython
Stack Overflow » Python
by Cosmin Cristea
1m ago
I am having some trouble with a code that I've written in MicroPython, for a Raspberry Pi Pico. I don't have any hardware killswitch installed, so I want to do that from a software implementation since I can't press the STOP button from Thonny, as the loop is running way too fast. The only way I can stop the program is by disconnecting the Raspberry from my computer, then disconnecting the gyroscope then plugging it again. And since I have to tune some parameters, this action takes a lot of time. Do you think you could help me with a simple killswitch that can kill my program by pressing a key ..read more
Visit website
Python DataFrame.info Output Doesn't Reflect Dropped Rows
Stack Overflow » Python
by Jess Stuart
1h ago
I have a dataset with 2111 rows in it. When I drop the 27 duplicate rows the DataFrame.info output still shows the rows numbered from 0 to 2110, but reports 2085 rows. Is there a refresh command associated with DataFrame metadata I need to call? Original unpreprocessed DataFrame.info output: !!!!!!!!!!!!!!!!!! Size and shape and info before preprocess 40109 (2111, 19) <bound method DataFrame.info of id Gender Age Height Weight ... TUE CALC MTRANS NObeyesdad BMI 0 1 female 21 1.6200 64 ... 3 t ..read more
Visit website
How to install python modules for all users automatically
Stack Overflow » Python
by user3696153
1h ago
I have a large windows LAB environment we are refreshing windows boxes (N=30 machines) a) We need Python preinstalled on these machines for all users. b) We also require a large number of Python packages pre-installed for all users. Things like: PySerial, CrcMod, PyUnit, and a specific version of PyQT and a few others. We normally install these via PIP. The goal here is that all machines have these pre-installed when they are deployed for use. In the past each person does this manually and the result where painful and very 'hap-hazard' What I really need is a means to have our IT group do this ..read more
Visit website
Scipy sosfilt array shape
Stack Overflow » Python
by lambcutlet
1h ago
I'm trying to plot a filter response in two ways, plot against time and the second plot against frequency. My aim is to plot cascaded filters, filter1 & filter2 for now. The plot against frequency is where I'm stuck. sosfreqz is expecting the sos array to have a (n_sections, 6) shape. Could some kind person help?, I'm unsure how to fix this, haven't found a solution online yet. I had it working in a (b, a) format but sos is apparently numerically more accurate. import numpy as np from scipy.signal import butter, lfilter, freqs, sosfilt, sosfiltfilt, convolve, sosfreqz import matplotlib.py ..read more
Visit website
How do I update my code to have login and signup on the same page in django?
Stack Overflow » Python
by Mitchel Elusanmi
3h ago
I want to have the login and sign up form on the same page, I also want to signup and login depending on which button was clicked. Here is my registration page enter image description here enter image description here and here is my views.py def register_view(request): if request.method == "POST": form = UserRegisterForm(request.POST or None) if form.is_valid(): new_user = form.save() username = form.cleaned_data.get("username") messages.success(request, f"Hey {username}, Your account was created successfuly") new_user = aut ..read more
Visit website

Follow Stack Overflow » Python on FeedSpot

Continue with Google
Continue with Apple
OR