Category "python"

Orthogonal distances between data and fitted curve in Python

I have a set of data points and a curve that is already fitted to the data. How can I calculate the orthogonal distances? I tried to use scipy.odr but I think i

2nd int-casting input-taking variables causes problem

I'm working in PyCharm. I haven't been programming for a few months and when I came back I saw a problem. There are 2 user-input-taking variables, input is conv

pandas datetime to unix timestamp seconds

From the official documentation of pandas.to_datetime we can say, unit : string, default ‘ns’ unit of the arg (D,s,ms,us,ns) denote the unit,

How do you call a variable that was returned at the end of a function?

I created this function and want to call the returned result but, I'm not sure how to get the variable back. If possible I'd also like a different message to po

how to edit a permutation

every number is a port. and the permutation gives me all possible routes but my starting port is always number 1,so out of all combinations i want the ones that

python rotating object disfunction

I have been working on my final project, where we are supposed to create a tank game in tkinter. I have done the movement, however i´ve been struggling wi

Send a fastAPI response without redirecting from HTML form post

I am creating an API using fastAPI, which receives a form from a HTML page, treats it (requiring a few moments) and returns a message saying this task is comple

Raspberry Pi as MQTT publisher and subscriber

I am trying to establish RPi as publisher and subscriber at the same time. I will do that in such way, that I will put subscriber.py and publisher.py as threads

How do I create an array from a grouping of row_number()?

I have code that uses row_number() partitioned by date. I would like to create an array that contains data grouped by the row_number that is partitioned by date

Convert 2D meshgrid into a 3D array in Python

I have coordinates (lat, lon) in a meshgrid, and data asociated with each "point". I want to export into a .csv and have each point asociated with the data i wa

functions running in loops and try/except does not work

I am a beginner in Python3 and was learning the basics during the last few weeks. I decided to use my knowledge and was trying to build a text-based game based

How to pass dataframe to pyspark parallel operation?

I'm trying to filter the data frame by values of salary then saving them as CSV files using pyspark. spark = SparkSession.builder.appName('SparkByExamples.com')

how to parse numpy array by line

Use cv2 to process PNG image, I want some areas to be transparent. change point [0, 0, 0, 255] to [0, 0, 0, 0]. for example, # a is ndarray(880, 1330, 4) a = [[

Screenshots in OpenGL using python

How do we take a screenshot of the OpenGL windows using python? Using jupyter, opengl and pygame. The code is: import pygame from pygame.locals import * from Op

Move HTML variable through views to python script in Django

While working in Django I am trying to take a variable from HTML input, pass it to views.py for some decision making, then pass it from views.py to a separate p

Python - Mrjob inlink count / MapReduce

I would like to count the number of times that a word appears in a line of my doc with MrJob and Mapreduce. I just succeed to count the number of time a song ap

How to customize Python domain in Sphinx?

I’d like to customize the Sphinx Python domain to recognize a custom field within a docstring for a method and generate custom HTML for it. For example, l

How to open gnuradio's preset editor for "Embedded Python Blocks" on Windows?

How to edit the python block of gnuradio on windows? I have python IDE installed like PyScripter, Anaconda But pressing 'use default' of 'open in editor' The fo

How can I save a dataframe into an excel sheet based on number of the worksheet (not a name)?

Here is my DF. data3 = {'DCF Years': ['1st', '2nd', '3rd','4th','5th'], 'DCF Amt': ['8.5', '6.5', '10.5', '4.5', '12.5']} df = pd.DataFrame (data3, columns

create confusion matrix (average) in python

How to make a confusion matrix with the average of the results obtained from a binary classifier for, for example, 20 training/testing iterations? These sets ca