hi I created a simple website to calculate the square of the number. below is the code calculate.html homepage.html python now I want to display input number in URL path. e.g. http://127.0.0.1:3000/square/10 so I’ve tried this but it didn’t work. What could I do? Answer You could get variables dir…
Tag: python
Plotting multiple dataframes in one chart
In the following code, in each iteration a dataframe is read from a dictionary and is plotted. My intention is see all plots in one chart, but I see multiple charts in separate windows. I see some tutorials about that, e.g. here, but it seems that they work when I want to call df.plot() with different columns…
Pipreqs not including all packages?
I currently have a conda environment tf_gpu and I pip installed pipreqs in it to auto generate requirements.txt Now, in my project folder, I have app.py with the imports : Also, predict uses pandas, scipy, numpy, pickle So, but the requirements.txt generated by pipreqs using pipreqs ./ inside the project fold…
Installed Pytorch 1.12 in the environment but detects version 1.10.0+cpu
Recently, I have installed pytorch 1.12.1 in the conda environment. After installation, I checked the version of pytorch using print(torch.__version__), it returns 1.10.0+cpu. I also checked the available packages in the environment. It shows pytorch version 1.12.1 as shown in figure below. I am unable to und…
How to make a custom gradient for a multiple output function?
I would like to know how to write a custom gradient for a function which have multiple outputs( or an array). For a simple example, I wrote the following code for y=tan( x @ w + b) with x shape is (2,3) and y shape is (2,2). To compare results, I calculated the operation by usual way and by the
Get source function of lambda expression with captured variable
Having a lambda function that uses a regex: I would like to retrieve the source function including its pattern for error reporting. The expected output would be something like: func = lambda x: re.fullmatch(“black.*”, x) Knowing of the inspect module and the function getsource, I managed to solve …
isin only returning first line from csv
I’m reading from a sqlite3 db into a df: Then I have a symbols.csv file which I want to use to filter the above df: Here’s how I’ve tried to do it: But for some reason I only get the first line returned from the csv: Where am I going wrong here? Answer You need convert csv file to Series,
EasyOCR Printing file details instead of text output only
I am trying to test out Easy OCR. Now when I run my code It outputs this Instead of just I want to get an simple output but it seems it also prints the image details and such. EDIT: Sorry I posted a wrong output. If anyone is wondering here’s the link of the photo Answer As it is explained
How to remove unnecessary “and” in inflect num to words python package
I’m using the python package inflect to convert numbers to words. I would like to know how I can have inflect convert the numbers the right way without unnecessary “and” in the end result. Here’s my code When I input “2021-10-10” as my Date of Birth(DOB), ans will become Th…
Subset dataframe based on integer in column name
I have a dataframe that has names such as these for its columns: In Python, how can I return a list of only the dataframe columns where the number after the first underscore is greater than 20? Answer We can use a list comprehension with basic string splitting logic: