Category "python"

Pandas group by one column and repeat the values of another column

I was trying to divide the month into two weeks. Basically for each month i am trying to create week numbers like 1,2,3,4 and repeat them. How to create the req

Adding new key values in a dictionary that was imported from an CSV file?

Sorry But I can't use pandas. I have a sample input csv file that looks like this: Alfa,Beta,Charlie,Delta,Echo,Foxtrot,Golf,Hotel,India,Juliett,Kilo A1,B1,C1,D

Where does transformers save microsoft/DialoGPT-small?

when I run the code from transformers import AutoModelForCausalLM, AutoTokenizer import torch SML=input("small,medium or large: ").lower()#I pick small model_na

Java Mybatis to Python SQL Alchemy - is there resultMap mybatis equivalent in SQLAlchemy python. which logically maps join queries removing duplicates

Say we have a select query like select a.col1,a.col2,a.col3,b.col1,b,col2,c.col1 from a, b, c where a.col1(+)=b.col2 and b.col3(+)=c.col2 In mybatis xml we hav

Append nanosecond to millisecond Python datetime object

I am trying to append nanoseconds to an already existing millisecond datetime pandas object. So, for instance, I already have 08:02:36.715647 which reports upti

converting a string to dot notation to access value in nested list in python

items={ "fruits": { "summerFruits": { "Mangoes":5, "melo

Tkinter window resize to fit content without touching

I have created an application that required to use the place() manager. I tried using pack() and grid() but after many tries and lots of effort it did not work

How to use variable declared inside function outside of it?

How do I use a variable that I declared inside a function outside one. Do I have to declare a function first and then use it? Using global doesn't work, so what

How to scrape links from dynamically loaded website (Fincaraiz) using Scrapy

I would like help on how to use Scrapy in Python to extract data from the following page https://fincaraiz.com.co/apartamentos/arriendos?ubicacion=cali I need t

Why is this jinja2 for loop not working in pyhtml code?

For example if I use a for loop like this it doesnt detect the line between the loop as pyhtml and gives out "Invalid Syntax" error. Is there some compatibility

Dataframe is Offset by -1 Days From Source Data

I am using a connector to query some tables in Dynamics 365 Business Central and when I view my dataframe all of my dates are offset by -1 days. I generated a l

Python - Fetch system data from remote host with psutil and paramiko

I'm currently working on a simple monitoring project. I want to have a dedicated monitoring server that checks several remote instances for cpu, memory and disk

Adding metrics on external services with aioprometheus

I'm trying to add metrics on external services with aioprometheus in an app built with FastAPI. Here is a simplified example of what I'm trying to achieve. Say

Shortest path Graph BFS python

Trying to return the int for shortest path in a graph, using BFS. The idea is to use a q, append into the q as [node,distance] and then when we traverse increas

PyQt6 QMediaPlayer and QAudioOutput not behaving as expected

I've been having an issue migrating to PyQt6 with QAudioOutput and QMediaPlayer where the QMediaPlayer object seems to not work with any QAudioOutput I make. If

The publishing code below is stalling on time.sleep() how can i change this behaviour + what would be a good way to implement a thread safe cach

For refreshing skills for a new job i have been trying to implement a very simple price publisher + client + mtm_cache. In the code below in publishing.py the c

Loop while basics in python 3

I am reading a python basics book and there is one function which I don't understand how it works. How is is possible that output looks like pow function even t

Issue with display()/collect() Large DataFrame In Pyspark

Getting The Following Issue In PySpark to perform display()/collect() operation on top of a generated dataframe. The df contains single column & Row (JSON d

Why do I get this error while calling predict in Keras?

I'm a newbie to Tensorflow, I've done many models but today when calling predict I get this error : ValueError: Exception encountered when calling layer "sequen

LABSE for bilingual sentence similarity

I am trying to run LABSE for bilingual similarity measurement. I am getting following error: AttributeError: 'tuple' object has no attribute 'pooler_output'