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…
Tag: python
How to put importance coefficients to features before kmeans?
Lets say I have the given dataframe And I would like to find clusters in these rows. To do so, I want to use Kmeans. However, I would like to find clusters by giving more importance to [feature_1, feature_2] than to the other features in the dataframe. Lets say an importance coefficient of 0.5 for [feature_1,…
What should I use to enter data to my database on Django? Django admin or SQL code?
I am a newbie in programming, but now I connected my project with PostgreSQL. I learned the way to enter by SQL code and also found out that we can actually enter /adming (by creating the superuser and add data there). So which one is widely used in webdev? Answer It will depend completely on your application…
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…
How to get the average of average of a column of list of lists as string data type?
I have a dataframe with a column like this: It shows the probability of one word in one sentence in one paragraph, the number of words and sentences is random. I would like to get another column average_prob that is the average of the average of each row. so basically 0.225 and 0.25 here. The data type of col…
Write a dictionary which has a list as values into a csv while preserving the list order, my code does this but not separating the values in the rows
I have a dictionary which contains two values as the values of the key (a series of averages in the 50% and 100% order), I want to write them to a csv which will have 3 columns – the key, the 50% average, and the 80% average. Code which writes the dict but there is no separator Desired output csv
How can I change the hinted return type of a function depending on the value of a parameter
I have a function where it usually returns an object that it searches for and performs some other actions. It raises an exception if it fails to find a match. Frequently, I don’t care if it finds a match or not, but not frequently enough that I’d consider removing the exception entirely. As such, …
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(“…