Category "python"

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

Fit unequal data into Linear Regression Model

How do I fit two unproportional arrays to a regression model? Is it possible to resize/reshape one without loosing the data? I used the code from here but my tr

side_effect for "sys.argv" returns a tuple of 1,1 regardless of what I set it to when doing mock.patch

For some reason side_effect isn't having an effect when I try to change the first two instances of sys.argv to be anything they just default to 1,1. """testing"

When I try to use smtplib to send emails, I get an error

from email import message import smtplib sender_email = "[email protected]" rec_email = "[email protected]" password = "example" message1 = "test" server = sm

Linked list value double_up() method causing TypeError

I am trying to implement a linked list in python and trying to create a method that doubles the value of each element in the linked list. This method updates th

taking followers/unfollowers data from instagram and storing it into a csv after every day

I'm trying to get daily increases and decreases in followers and posts of a certain Instagram account (it is public), how do I get the data of followers and new

Wrtiting Functions For An Existing Wordle Program

I'm writing a simple wordle program in Python. I have to add functions to the already existing code I have, but I've been getting majorly stuck. I posted what I

export excel rows to individual json files in python

My excel file has 500 rows of data. I am trying to get 500 individual JSON files. Each file should have data only from 1 row. Thank you in advance. import json

how can I change the code from Iterrows operation to data frame operations

sample code, how can I change the code from Iterrows to df operations. can you pls help. Iterrows is taking longer time def renewed_penalty(row): row["Renew

Where does python get the local timezone from?

>>> import time >>> time.tzname ('GMT', 'BST') Where does Python get this information (the local timezone) from? Is there a syscall that retu

R reticulate specifying python executable to use

First, I'm working on a Windows machine. I would like to specify a specific version of python to use in RStudio. I would like RStudio to use python 3 in the Arc

How to search list of numbers in many files

I have 5 files containing numbers and need to search for a list of numbers and print the name of the file it has. i tried this code but don't work import os

Expanding Records Based On Date Range Pandas

I am attempting to expand the records in a data frame between two dates. Given the input file of single entry for each record, I want to expand it based on a gi