I have the code below to calculate Euclidean Distance. however, my function does basically nothing. It gives no output and not even an error, it just runs and finishes. Answer Have you called the function? Output: For longer lists, you can also do this faster by summing a generator expression instead: Or you …
Tag: python
File not landing in new directory created by askdirectory in tkinter
Firstly, thanks Carl_M! I will try to ask this question with more simple code. Using tkinker- the user is asked to select the directory and new subfolder. That works. Then browse for an exel file that will be modified as a df and sent to the new subfolder. That sort of works (thanks to Carl), but file doesn&#…
Convert SQL Query to MongoDB syntax
I have a big problem with converting SQL queries to Mongo DB for Python. I have a question if you know better methods for transferring SQL queries to Mongo DB queries? I have two queries but I still have big problems with the syntax conversion to Mongo DB. Maybe there is someone here who can help me? Table I …
How to get a value in a column as an index
I assign the eligible index value to A column and then df.ffill() Now I want to use the value of A column as an index and assign the obtained value to the expcted column I try df[‘expected’]=df[‘price’][df[‘A’]] but it doesn’t work. input expected result table Answer …
Show how when values rise in one column, so does the values in another one
I’m working with a covid dataset for some python exercises I am working through to try learn. I’ve got it by doing the normal: import pandas as pd import numpy as np In this dataset there are 2 columns called BodyTemp and SpO2, what I am looking to try do is show how the results of the columns are…
Loop over regular expressions using Pandas str.extract
I want to extract numeric values from arbitrary strings in a column in my pandas dataframe. Two regexes that shall be looped over the column “watt” using str.extract. The str.extract function shall be applied to all NaN values. On the next iteration, non NaN values (=matches) shall be excluded fro…
Detail view is not displaying content of models
My detail View in Django, isn’t successfully displaying the content selected from the listviews. The following is my code. Models.py: urls.py: Views.py: Html list view: Html detail view: I hope my query made sense. I don’t receive any error on myside, its just not working as it should. Answer The …
A question regarding plots with matplotlib in python
i hope i can find someone among you who can help me to master the first steps with matplot. the following scenario is currently bothering me: I am using a custom trained YoloV5 model to apply object detection to a video. now i can detect n objects per frame, which i generate via screenshot from the video. The…
Get amount of objects saved in MongoDB using Pymongo
I’m trying to get amount of objects saved in MongoDB with but I’m getting an error I’m using Pymongo 2.0 Answer The find() function for pymongo returns a cursor object (not an array). Pymongo does include a count_documents function. Meaning the code should look like this: Edit: Updated to co…
How to match this part of the string with regex in Python without getting look-behind requires fixed-width pattern?
I want to extract the name from a create Table statement for example this: “CREATE OR REPLACE TEMPORARY TABLE IF NOT EXISTS author (” the name here is author. If you look into the official mariaDB documentation you will notice, that OR REPLACE, TEMPORARY and IF NOT EXISTS are optional parameters. …