Quantcast
Channel: Active questions tagged python - Stack Overflow
Browsing all 23390 articles
Browse latest View live

How do I filter a list of dicts with a list of strings in Python? [duplicate]

I have a list of dicts which I would like to filter with another list, but am having trouble with the filter() functionlist_of_dicts = [{'name': 'Bob'},{'name': 'Alice'},{'name':'Jenny'}]list_2 =...

View Article


Python ffill/bfill but across rows instead of columns

I have a dataframe with columns of data where most is populated but some entries are NaN.I have many columns of data values with a collection of descriptive columns as well. Data sample looks like...

View Article


Rangebreak Error Solved, i read the answer on stack overflow

import pandas as pdimport datetime as dt# !pip install yfinanceimport yfinance as yfimport plotly.graph_objects as goimport numpy as np# Initial data & get dataframe start = dt.date(2023, 4, 15)end...

View Article

Function approximation using VQCs in Pennylane, Python

I am trying to write a python script which takes sample data outputs from a target function (in my case a sin(x) function) and fits / approximates that function using gradient descent and Variational...

View Article

Python tkinter root close

As an interim to my full application, I'm closing the window with buttons at different places in the file. Now originally, it works fine: I can close the application from both location within the file....

View Article


How do I put a variable in a path

I'm trying to store a path in a variable. see belowtarget = r"C:\Users\User\CodeProjects\WebSafer"However, I need it to be dynamic. Not hardcoded to my username, so I get the login username by...

View Article

Pyinstaller skipping pipeline package dependencies for spaCy

I recently wrote a Python script that uses spaCy, which works as intended when run directly from Pycharm. I wanted to create an executable version of this to distribute to the rest of my team for ease...

View Article

GLTF creation for web-ar experience

I would like to create some gltfs to use in web-xr like examples here:https://immersive-web.github.io/webxr-samples/but I can't seem to save them correctly - is there guidance on what the gltfs need?...

View Article


Best practices for connecting MongoDB using Motor in FastAPI

I have a question: What are the best practices for connecting to a database in FastAPI?To provide some context, I want to write code to connect to a MongoDB database using Motor. My idea is to create a...

View Article


How to make rectangular images using Matplotlib as some functions are not...

I'm trying to make rectangular annotations on images, but I'm unable to put annotation as I'm running into attribute errors as some modules are not recognized, the file directory has images in .jpeg,...

View Article

How do I correctly include data folders into an APK with Buildozer?...

I have made a relatively simple app with Kivy and the root directory contains an "audio" folder with two subfolders in it, each containing a few .wav files. The app runs fine on my desktop but once...

View Article

RuntimeError: permute(sparse_coo): number of dimensions in the tensor input...

I am working on Image Segmentation using UNet model.I am facing the following error in the dataloader part.RuntimeError: permute(sparse_coo): number of dimensions in the tensor input does not match the...

View Article

Can scipy.optimize Find Optimal Input Values When Multiple Products are...

I'd like to find the optimal values for Input A for Product 1 and for Input A for Product 2 with the aim to maximize Total Output and subject to a given constraint. I've tried using Python's Scipy...

View Article


pytorch matrix multiplication accuracy depends on tensor size

I have the following code where I multiply tensor X by a matrix C. Depending on the size of X and whether C is attached to the computation graph, I get different results when I compare batched...

View Article

Python Turtle : Handling two successive screens for two successive...

I'm new to Python and trying out Turtle through Tutorials. This question turned out to be verbose, my bad.I have designed 2 Games handled by 2 Functions (in a separate module) which are called from...

View Article


Python Lex Yacc : Regular Expression Error

I am trying PLY for sentence validation. I take a simple grammar rule.Sentence -> nouns verbsnouns -> r'[A-Za-z]'verbs -> is|are|am|.. When I just set verbs to is|am or am i.e. I keep my...

View Article

Data doesn't show on template - django

I have a chat app but it seems that i have a few mistakes which i don't know what is.Users can not see their chat history and their messages in the app.When Users write their messages on a specific...

View Article


Can't pip install pystan on Mac

When I try to pip install pystan I get the following error: error: subprocess-exited-with-error× Preparing metadata (pyproject.toml) did not run successfully.│ exit code: 1╰─> [1 lines of output]...

View Article

Second test is returning first tests response (function bleeding)

If I run the following code with pytest test.py I get the output {'status': 'success', 'data': 'Dave'}. Why is that?from unittest.mock import patch, MagicMockclass MessageHandler: def...

View Article

Set symbol to discrete map with plotly scattermapbox - python

Is it possible to set a discrete symbol map for plotly scattermapbox. color and color_discrete_map can be used to assign a certain color but can the same approach be used to assign a specific symbol...

View Article
Browsing all 23390 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>