Skip to content

Python: how to delete space in column of lists?

I have a dataframe like this: Some records in the column ‘1_5000_pi025’ has the space between ‘ and number, for example: Space between ‘ and 73221_902642_M-34-57-A-c-3-2.tif. I was trying few solution but didn’t work. How can I delete space from every record in the column ‘…

Python how to download a file from s3 and then reuse

how can I download a file from s3 and then reuse instead of keeping downloading it everytime when the endpoint is called? Answer Based on the comments. Since the files are large (16GB) and need to be read and updated often, instead of S3, an EFS filesystem could be used for their storage: Amazon Elastic File …

Factory for contextvar default value

Setting a dictionary as ContextVar default: …kinda works, as the dictionary will be available as default, but it always references the same instance, instead of generating a new one for each context. Do contextvars somehow support factories (for dicts, lists, and alike), as in: Or do I just have to do i…

Run python script from C# via command prompt

I’m developing a Winform application. I want to run python script from c# via command prompt (i’m using System.Diagnostics.Process class) I have a function to run python script that need to pass a python script file name. It works correctly until I print a string that contain unicode character. My…

JSON adding unnecessary Curly Braces

I am creating a Discord bot using Discord.py. I have created a command that will update an external JSON file with a user-specified value. While testing the command I noticed that certain words, such as tes, will add an unnecessary curly brace at the end of the JSON file. This problem only occurs with certain…

Jupyter-notebook failed to import python packages

I was trying to use numpy in Jupyter Notebook in a Python3 virtual environment, but the encountered an error. In terminal, I did: And on the Jupyter page, I created a new notebook and executed the followings And the resulting output is this: The package is already installed but still cannot be found…? I…