I have a df that I’ve read from sql: I then try and get the average of the last 5 days and add it to a new column: Which gives me the following error: Any ideas what’s going wrong here? Previously this worked and now it’s throwing an error – and I can’t seem to figure out why Ans…
Tag: python
Python Dataframe For loop (if i.contains)
I need a for loop on a column specific. With this for loop, I will assign the value ‘Normal’ to a list if the column contains ‘Themes’. But I don’t know how to write it here. I would be glad if you help. Thanks in advance :) Dataset For loops that I try Answer You can use np.wher…
Is it possible with aiogram to know, who sent the message?
So the Telegram Bot can do different actions, depending on who activated the command. This concerns aiogram, a framework for Telegram Bot API Answer You could use a simple filtering system: Create a dict/database with user_id’s and their roles Get the role from that dict/db by id and do the action This …
How to return a string expression for order_by args in django queryset?
Let’s say I want to do this in the views of a Django project: I expect the order_by_query to be a string like “field1,-field2”. So I will write a function like: My questions are: what should I write inside the compile_ob function? what should I return as type? Answer You actually don’t…
cx_Oracle connection type hinting in python
I’m diving into type hints and type hinting some of my code as I think it is a good practice. I have a function that takes both sqlalchemy and cx_Oracle connection/session objects. I was able to figure out the hinting for sqlalchemy here. Poked around some docs trying to figure it out with cx_Oracle to …
How can I assign a variable from a string inside a json dictionary?
This is my get output on each asset im getting data back from I can access the dictionary values easily, but how doo i access the value of the array, i want to be able to add up each critical vulnerability this is the return, im trying to get critical, moderate, severe values from the vulnerabilities sub arra…
Code to display Django (Reverse) related table throws error
I’m quite new to Django and practicing Models section of Django by following its official tutorial. I also created a project of my own and try to apply similar concepts. This is my models.py; Now when I run below command in Python/Django shell it runs as expected with the related data. Below two also wo…
Issue with Constructor creation/File Referencing (AttributeError: ‘Sr830’ object has no attribute ‘resource_manager’)
I am relatively new to Python, so please bear with my lack of technical knowledge. I have a lock-in amplifier setup with a GPIB to USB cable that is plugged into my computer. I am able to read the instrument fine with Pyvisa. I am additionally using other driver classes (labdrivers) to write and read values t…
How to give each row of a MDDataTable a specific color working with kivymd?
I’m developing an app which fetches some numeric data from an api and manifests it in a MDDataTable(I’m using Kivymd). I need to give each row different color based on its numeric values. Is it doable in Kivymd and this specific class(MDDataTable)?If yes, how? I appreciate your answers. thanks. An…
Is there a way to filter widgets in a ScrollArea with a QLineEdit based on specific attributes?
I’m doing an app in PyQt through Qt Designer and I’ve populated a (container widget inside a) Scroll Area with a list of cards (custom widgets that contains informations). I’ve put outside of the scroll area a QLineEdit and I want to use this QLineEdit to filter the cards based on specific a…