I am using the following shell script to loop over 90 zip files & unarchive them on a Linux box hosted with Hostinger (Shared web hosting) The python script being called by the above shell script is below – Irrespective of whether I use the inbuilt unzip command or a python, it’s taking about …
Tag: python
Adding strings to a formatted string
I’m trying to add on to a string that is going into excel. But what’s actually going into my cell in my sheet is: The single quotes should be around the entire str(i), why is only the number getting the single quotes? Answer Not sure I understand the issue, but I also wasn’t able to reproduc…
How to calculate a Process Duration from a TimeSeries Dataset with Pandas
I have a huge dataset of various sensor data sorted chronologically (by timestamp) and by sensor type. I want to calculate the duration of a process in seconds by subtracting the first entry of a sensor from the last entry. This is to be done with python and pandas. Attached is an example for better understan…
getting “KeyError” while implementing Z-score on a dataset
I have been trying to implement z-score normalization to all of the numeric values present in combined_data with the following code: Here, combined_data is the combination of training and testing datasets as a dataframe and passed through one-hot encoding. I am seeing the following error: The dataset combined…
docker compose .env variables not set
I have the following docker-compose.yml: In my .env file I have the following: This is to start up a flask api, but what I get when I run the container with: docker compose –env-file .env up –build or docker-compose –env-file .env up –build is this: The api insists on starting on 127.0…
How to optimise function logic to avoid duplication – python
I have some code below, for a given name that matches pattern with 2 lower case letters (such as ‘aa’), the valid name can be V-aa or X-aa My question is: can I do something like: Answer From your description, I assume that verify_helper() is computationally expensive regardless of names being val…
Split a string from a textfile correctly
i have a file (“text.txt”) with several lines (~5000000 lines). I’m trying to split a line so that: becomes this two lines: so essentially i want to transform a single line into two lines and write it back to another file. All the lines that has to be split starts with the character “&…
Looking for the quickest way to find the value of a column given an index for all rows
I’m looking for a more efficient way to grab acertain value at a certain index for every row in a Pandas DataFrame than the one I have currently. Here’s the code I have so far. The .apply() function with the lambda syntax is super slow so would love a more optimised version. Let me know if you nee…
Gspread batch update traceback
I am having problems trying to prepopulate google sheets filter and then do a batch_update. I get correct execution, the table is imported, filters are created. When the batch update occurs, I get a traceback that I don’t understand. I thought that the traceback may have come from the way I coded the sh…
Not able to read the correct values from a binary file in python
I created and wrote double (data type) values into a binary file. The file does not contain any headers. It is just raw data written into the file using QDataStream in Qt. I am trying to read the values in a python (version 3.6.9) script, however, the data that is read in the python script is not corect. The …