Skip to content

Tag: python

how do i remove rows from numpy array based on date?

i have a number of arrays with the following format: how do i remove the rows where the datetime > 2021-05-06 09:20 and < 2021-05-06 09:40 ? I have tried with np.delete: and np.where: but always get the error: SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for…

Python: Run a code after return something

This is an ApiView from my django project: As you see, if client.is_busy is not True, I’m making it True in here. But in this situation, I need to client.is_busy = False after 30 seconds. If I do it under client.save() code, it delays to response. How can I do it? Answer You should consider using timer …

Pandas: Find difference in rows with same index in any column

Sample dataframe: If you see here, the rows with common index have atleast one difference amongst them. For ex: Rows with index 0, have difference in column_name. Rows with index 5, have difference in max_length. Rows with index 6, have differences in both data_type and default. Rows with index 8, have differ…

Run scrapy splash as a script

I am trying to run a scrapy script with splash, as I want to scrape a javascript based webpage, but with no results. When I execute this script with python command, I get this error: crochet._eventloop.TimeoutError. In addition the print statement in parse method never printed, so I consider something is wron…

count the files in directory and loop one by one

I have some different format files in a one directory, but i want to read only .txt file and print the based on the count , Example: (one.txt,two.txt,three.txt,four.txt,one.xlsx,two.xlsx) here i want to count the .txt files and read all .txt file one by one , here the count is 4 read file one.txt print(&#8220…