Skip to content
Advertisement

Tag: python

Multi-processing in Azure Databricks

I have been tasked lately, to ingest JSON responses onto Databricks Delta-lake. I have to hit the REST API endpoint URL 6500 times with different parameters and pull the responses. I have tried two modules, ThreadPool and Pool from the multiprocessing library, to make each execution a little quicker. ThreadPool: How to choose the number of threads for ThreadPool, when

play as many sounds as loop count in python

I want the alarm.play() function to repeat for the number of loops and ring 10 times as in the example, but it just keeps ringing once every time I try or change it. How can I fix this? And does it make more sense to use for instead of while ? Answer just stop the alarm at the end of

Import functions from another directory

I am running a python script (app.py) where I have to use two functions from another script (src.py), located inside another directory. The structure is the following: I am using, in app.py, the following lines: to access to the functions odd_all, even_all declared inside src.py. However, I get the error: ModuleNotFoundError: No module named ‘src’. How could I solve this

Replacing NaN values in timeseries Pandas dataframe with mean values

I have a dataframe that has 2 columns, date and values. I want to replace NaN values in the dataframe with mean values, but with specific condition. NaN values should be replaced with mean value of the values from the same period for the year that has that value (+/- 1 day). Value for 2021-02-04 should be: Because dates “2022-02-03”,

I can’t add cookies on python selenium webdriver

I’m trying to enter a page and then add cookies on it, but it returns an error and I don’t know why. I did it exactly like is written on the selenium docs, and here is the code i used: And it returns selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: missing ‘name’. I already thought that it could be the code trying to

when subsetting with and without .loc[ ] in python?

I was doing a Python exercises and I got the wrong answer (in red). I’m a bit confused about subsetting with and without loc[ ]. Please enlighten me. Thank you. Answer The df.loc[:, [‘alignment’, ‘character’]] itself is a dataframe. What you’re doing wrong is passing it inside df. I suggest you to look around at the related pandas documentation.

Advertisement