i’m more of a backend web developer and this is for a friend of mine but i have this issue with turtle where her code wont run and i keep getting syntax errors saying certain things aren’t defined. Heres the code Answer If you use import turtle then you have to use turtle.penup(), turtle.setpositi…
Tag: python
Facing problem updating a column of a table, while the id and alias column remains same – sqlalchemy
Hi my table named ‘total’ looks like this, If I want to insert a new row with a new alias lets say alias = ‘lion’ and status = ‘gold’ it should create a new id and the table should look like this But if I keep the alias same as ‘lion’ and status = ‘silver&…
Ray has weird time consuming
I have a tiny Ray pipeline like this: I using time.sleep() for fake time consuming. As you can see, the HandDetector should running in a sub process, so the whole time should be 6s. But I got (you can have a try on your computer): Why there are 0.4s time more? Answer It looks like you posted the same question
how to save space training
I have written an intent classification program. This is first trained with training data and then tested with test data. The training process takes a few seconds. What is the best way to save such a training, so that it does not have to be trained again with every call? Is it enough to save train_X and train…
Sleep/block/wait unitil serial data is incoming
I have some live data which is streamed from a microcontroller via serial port to a Raspberry Pi (or for doing prototyping maybe to a PC) with Linux as OS. The data comes roughly every 100 ms. I want to process this data, after receiving (checking of correctness and doing some calculation with some python scr…
Tensorflow accuracy from model.predict does not match final epoch val_accuracy of model.fit
I am trying to match the accuracy of a model.predict call to the final val_accuracy of model.fit(). I am using tf dataset. The dataset setup for train_ds is similar. I prefetch both… Than I get the labels for the val_ds so I can use them later My model Compiles fine Seems to fit fine The last epoch outp…
How to have different point sizes in ScatterPlotly Graph Object based on the values of a tuple?
I am trying to plot a network graph which is created using networkx. The graph is initialized using a pandas data frame which looks like below: The python code used for this purpose looks like: I consider the graph as a collection of lines and points so I use the Plotly Graph Object like below to visualize th…
‘str’ object has no attribute ‘to_csv’
I’m trying to save some data that I collected on a csv file. And for that I’m using the following code, but I’m getting the error: ‘str’ object has no attribute ‘to_csv’ I am using this line df = pd.to_numeric(df, errors=’ignore’) to change Nonetype to num…
Replace text at specific position
I am trying to use the replace function to replace specific spans in a text. But it ends up replacing all same strings. prints ‘I played ** times and **4 ***** times’ replacing 13 in 134 too. Is there another way to replace this more accurately? Answer The following does what you want. It creates …
Python generics: user defined generic in a callable
I have the following setup: This works great, but I’ve tied my Callable to str and int, and I would want something even more generic like being able to define func as something like: where A and B can be whatever, so I can define and send a func like (a: Type[str]) -> Type[int]:… or (a: Type[fl…