I am trying to generate a dictionary automatically with a for loop (i < numero_usuarios), the keys are taken from a list with names, and the values are randomly generated with a random.randint(1, 10), the problem is that it does not always generate the amount I want. For instance, I want to create 10 users…
nested list content does not preserve when appending to a main list
I’m working on a basic program allows me to navigate in a two dimensions grid (for now 3X3), using a function specified with the initial point and all the steps moved on each axis, returning the end point. I want to raise an error if a specific point has been already visited, and I’m trying to do …
convert timestamp to date in custom commands
i am creating custom commands in django. i have a problem with conversion timestamp to date by methods like fromtimestamp. i have such error: line 13, in handle timest_conv = datetime.fromtimestamp(timest) OSError: [Errno 22] Invalid argument this is my class with handle Answer The timestamp is expressed in m…
Module ‘project_name’ has no attribute ‘celery’
I’m trying to set up a background task using celery and rabbitmq on django but I’m getting an error saying that my project has no attribute celery. I’m using PyCharm and installed celery through that. I’m new to celery but I’ve read a lot of articles similar to this issue (Attrib…
Pandas data frame how to make a scatter plot for clustering a list of values into a set of groups
I have this pandas df with 2 columns and I want to create a plot that clusters the drugs into their target, so there will be 7 clusters (7 targets) , I am not sure how to do it.. This is the df: Answer You can plot scatterplot with seaborn like below: (Because you say in the comments of other
Longest Increasing Subsequence using recursion and cache
i’ve been trying to implement a cache in my recursive LIS function so it doesn’t calculate the same value twice. I would really aprecciate if someone can give me a hint of what im getting wrong. This is the recursive function that returns the LIS array that works fine: This is the same function bu…
How to do test of equality of coefficient for 2SLS in Statsmodels or Linearmodels?
So if I ran an experiment with multiple treatment groups and a control, I would analyse the results using Statsmodel ols to see if any of the treatment group were statistically different from the control group: y ~ C(treatment_group, Treatment(‘Control’) I would then run results.t_test_pairwise() …
How to Post JSON to Durable Azure Function (Python)?
I would like to call Durable Azure Functions from Azure Data Factory. I would like to post json to Functions and get status when Function processing have completed. My ultimate goals is to successfully run Functions which takes 10min without timeout. I have already successfully executed Azure Function Activit…
Python – Exception Handling
Till I know, Python exception handling includes four types of keyword (try, except, finally, Raise) + else. But I read some articles that say throw, catch keyword in Python. Really, Python has this keyword. I read these two official documentation for Exception Handling. But they did not mention that Errors an…
Scrapy Python can‘t extract links with more stable xpath
I‘m Building a scraper for this website. I‘m using Python and scrapy Shell to extract the data that I want: xpath would be: //a[@class=“sb-card sb-card-company site-1×1 with-hover]/@href“ Using response.xpath(‘//a[@class=“sb-card sb-card-company site-1×1 with-hover]/@href“‘ returns [] I tried using …