Category "python"

How can I refresh the data in the background of a running flask app?

I have a simple flask app that queries a database to write a csv then pyplot to create a chart out of that. I would like to refresh the data in the background e

Python pandas read_fwf strips white space

I am facing an issue using the read_fwf command from the Python library pandas, same as described in this unresolved question I want to read an ascii file conta

How to upload a file to the file.io website using Python

I am trying to send a POST request to the file.io website to upload a file from my Python script and I want to get the link for that file. Here is my code: impo

HTML shows Flask-SQLAlchemy syntax?

When trying to display replies of users on my page it displays them with SQL syntax, like so: ('reply',) I've tried str() when returning from my route. html: &l

Multiprocessing Pool implementation

I'm doing some intense computation and I'd like to speed up the process using all the computational power available (8 cores on my PC). I'm doing some calculati

Is it possible to write to Command Prompt with python?

Im opening Command Prompt with os.startfile('C:\\WINDOWS\\system32\\cmd.exe') and after opening the program id like to write the python file for it to run C:\U

Cann't install django with error 'Non-zero exit code (2)'

When i create new django project in pycharm i have error enter image description here Help me please

What is the purpose of sort_index of a Dataclass in Python?

I am learning about Dataclasses but I am confused on the purpose of sort_index and how it actually works. I can't seem to find any valuable information on it. T

Why am I unable to authenticate via Tweepy?

Newbie coder having issues authenticating via tweepy. below is the code. import tweepy access_token="" access_token_secret="" api_key="" api_secret_key="" auth

FastAPI psycopg2 error when creating database for tests

I'm trying to test my database in my FastAPI app. from fastapi.testclient import TestClient from sqlalchemy import create_engine from sqlalchemy.orm import sess

Diff two yaml files using python

How can I do diff of two YAML files and generate base on this comparison new file? For example: users: - login: user1 first_name: MyUser1 last_name: MyUser1

The specified device is not open or is not recognized by MCI

I was programming a game using Python and a sound effect needed to be played, so I used the playsound module: from playsound import playsound playsound("Typing

Converting a pandas dataframe to multi-index and changing values

I have the following dataframe: d = [{'AX':['Rec=1','POSi=2'], 'AVF1':[], 'HI':['Rec=343', 'POSi=4'], 'version_1':[]}, {'AX':[], 'AVF1':['Rec=4', 'POSi=454'],

Django cache real-time data with DRF filtering and sorting

I'm building a web app to manage a fleet of moving vehicles. Each vehicle has a set of fixed data (like their license plate), and another set of data that gets

Keyboard input with timeout?

How would you prompt the user for some input but timing out after N seconds? Google is pointing to a mail thread about it at http://mail.python.org/pipermail/p

How to run mypyc in Spyder?

How does one install/run mypyc on Anaconda/Spyder? The documentation (https://mypyc.readthedocs.io/en/latest/index.html#) does not address this.

FieldError at /teacher/8/. Cannot resolve keyword 'teacher' into field. Choices are: classroom, faculty, faculty_id, id, name

I reach the error in my django project when I was trying to display my view. The problem seems like related to the Course model but i honestly dont know where t

Collect coins from the map in Pygame

I'm trying to make a pygame game but I'm having a problem. I want when a character collects a coin, the score will change by one and the coin will disappear. I

How to share datafram from multiprocess to main process?

Here's the 2nd version coding I'm using now( it's from Booboo), it takes about 17mins to return query result, and data could be transfer to patrent process. fro

How to iterate over references in a python loop ( for x in range() )

I have a bunch of references for different filenames at the start of my code: _file1_="filename1" _file2_="filename2" _file3_="filename3" _filew1_="anothername