Category "python"

Bloom Filters with the Kirsch Mitzenmacher optimization

I have recently started playing around with Bloom Filters, and I have a use case in which this calculator suggests to use 15 different and unrelated hash functi

Vaex copy columns between dataframes

I have a dataframe that I performed a filter on and then added some virtual columns. I wish to add those columns back in with the original data frame. Here is m

Trying to handle an error but cannot do it! Telegram

I have made a telegram bot using pyrogram to upload a large video and the the progress bar is shown, however the progress bar is repeatedly edited message with

How to view images from folder in flask web app?

I had this issue when I first started on most of the pictures, only one showed on my web page so I uploaded the pictures to a google drive and used each url. It

What is the python equivalent for names() function in R

I have a code in R, where in the data frame "inputdata" there are multiple columns, and we are replacing the word "new" with "old" in the entire data frame: nam

.py files in google colab

How can upload and run .py files in Google Colab? I can open the file as text and run it after copying, but I want to know if there is a way I can upload the .p

Flask SQLAlchemy: many to many relationship error

I am trying to set up many-to-many relationship in SQLAlchemy but I am getting the error: from shopapp import db db.create_all() sqlalchemy.exc.NoReferencedTab

How I can only print the visible cells (filtered) in a column with openpyxl

I am working with a excel sheet and want to print only the value of cells which are visible in a particular column. Below is the example, I'm expecting it to pr

Python API Call: JSON to Pandas DF

I'm working on pulling data from a public API and converting the response JSON file to a Pandas Dataframe. I've written the code to pull the data and gotten a s

ValueError: Data cardinality is ambiguous (x sizes: 60000 y sizes: 10000 Make sure all arrays contain the same number of samples.)

I'm using mnist dataset for my project on VsCode IDE. Following is the complete code. what is it that I'm doing wrong and how can I solve this error? # Import L

S3 appending random string in file name

I have a s3 folder with a csv file stored on it. I'm trying to download the last modified file. I'm using this script to get the last modified file: s3_client =

python: what is a best way to find paths with x length in 2d array?

Assume that I have an array like this [[0, 1, 0, 0], [1, 0, 2, 5], [0, 2, 0, 0], [0, 5, 0, 0]] each index is a node index so [0, 1, 0, 0] means node0 has a edge

How to mock a method inside a @singleton decorated class in python

The class itself calls in the init method a get_credentials method, which does I need to mock. Using unittest for mocking; from unittest import TestCase, mo

Is there a way to create a factor table for spline terms using GAMs in Python's h2o

I have fit a GAM model in h2o with several gam variables (P-splines) using the h2o.estimators.gam package. I'd like to get a table with the factor loading for e

Jacobian diagonal computation in JAX

I was wondering how we could use jax (https://github.com/google/jax) to compute a mapping of the derivative. That is to say : we have a vector and we want t

PyQT customizing specific ScrollBar

I would like to apply different colors to my scrollbars depending on their parent QListView, and I would like to do this from "higher level" than the QListView

Python/Pandas Add string to rows in a column that contain a character a specific number of times

I have a Pandas DataFrame(data) with a ['Duration'] column as 'object' type that has time durations in format: 'H:%M:%S' such as '1:47:54' with 7 characters, bu

Adding new dataframe colonms using information extracted from the url in the url column, but the url could be missing information

Given: A pandas dataframe that contains a user_url column among other columns. Expectation: New columns added to the original dataframe where the columns are co

Mimicking compile time interfaces in python

Summary This question first uses Java examples to demonstrate what I am trying to achieve, then shows Python equivalents where I attempt to replicate the compil

How do I remove hours and seconds from my DataFrame column in python? [duplicate]

I have a DataFrame : Age Gender Address Date 15 M 172 ST 2022-02-07 00:00:00 I Want to remove hh:mm:ss I tried: import datetime