Skip to content Skip to sidebar Skip to footer
Showing posts from November, 2023

Name 'actor' Is Not Defined

I have a problem with python programming, when I'm trying to write a game (introduced by the bo… Read more Name 'actor' Is Not Defined

Regex Taking Too Long In Python

I have used regex101 to test my regex and it works fine.What i am trying to is to detect these patt… Read more Regex Taking Too Long In Python

Python Gui Open A "new Page"

When I press a button, I want to open a new side. Not a new window, the window should be the same, … Read more Python Gui Open A "new Page"

Closing A File After Using Np.load (using Spyder)

I am loading a file: a= np.load('myfile.npz') and then doing things with a After a while I… Read more Closing A File After Using Np.load (using Spyder)

Python 3 Typeerror: Unsupported Operand Type(s) For ** Or Pow(): 'str' And 'int'

#Import the module from math import sqrt #Using while loop statement to make the program not finis… Read more Python 3 Typeerror: Unsupported Operand Type(s) For ** Or Pow(): 'str' And 'int'

Getting Typeerror When Trying To Concatenate 'str' And 'nonetype' Objects

I have the following code: import requests from bs4 import BeautifulSoup def hltvmatch_spid… Read more Getting Typeerror When Trying To Concatenate 'str' And 'nonetype' Objects

Python - Increasing Number From The Number That Is Stored In A Text File

accountNum = open('data/accountNum.txt','r') str_size = accountNum.read() size = in… Read more Python - Increasing Number From The Number That Is Stored In A Text File

Simple Http Server Does Not Work When Converted To Exe

I wrote a simple python http server to serve the files(folders) of the present working directory. i… Read more Simple Http Server Does Not Work When Converted To Exe

Get A Variable As Filename From Python Script And Use It In A Batch Script

I have a python script which gives the output as: The lastest filename of a directory. I want to us… Read more Get A Variable As Filename From Python Script And Use It In A Batch Script

Django Model Field With Secondary Field

I am trying to create a user sign up form in Django that allows for a primary field with an associa… Read more Django Model Field With Secondary Field

How Can I "hook Into" Python From C++ When It Executes A Function? My Goal Is To Profile

I'm implementing a profiler in an application and I'm a little flummoxed about how to imple… Read more How Can I "hook Into" Python From C++ When It Executes A Function? My Goal Is To Profile

Receive Multiple Send Commands Using Mpi4py

How can I modify the following code (adapted from http://materials.jeremybejarano.com/MPIwithPython… Read more Receive Multiple Send Commands Using Mpi4py

Converting Nested Lists To Dictionary

Hi please I try to make a dictionary out of the nested lists below and I get a TypeError. Please he… Read more Converting Nested Lists To Dictionary

How Do I Randomly Select Multiple Images From Folders And Then Layer Them As A Single Image In Python?

I'm trying to use python to create a composite .png of randomly selected and layered png's … Read more How Do I Randomly Select Multiple Images From Folders And Then Layer Them As A Single Image In Python?

Check Exact Match Of String With Brackets In Another String Python

There are many answers to a similar type of question to mine, but I'm not sure why this isn'… Read more Check Exact Match Of String With Brackets In Another String Python

Library Expects Symbol In Flat Namespace Although Compiled With Two-level Namespace

I load Python dynamically with dlopen and RTLD_LOCAL to avoid collisions with another library which… Read more Library Expects Symbol In Flat Namespace Although Compiled With Two-level Namespace

Use Python List Comprehension To Update Dictionary Value

I have a list of dictionaries and would like to update the value for key 'price' with 0 if … Read more Use Python List Comprehension To Update Dictionary Value

Django: Modifying Data With User Input Through Custom Template Tag?

Is it possible to modify data through custom template tag in Django? More specifically, I have a mo… Read more Django: Modifying Data With User Input Through Custom Template Tag?

Parseerror: Nested Forms

Python mechanize gives nested FORMs error for this code: url = 'http://bis.zju.edu.cn/psi/'… Read more Parseerror: Nested Forms

Python Name 'os' Is Not Defined

I am trying to run this python module from settings import PROJECT_ROOT DEBUG = True TEMPLATE_DEBU… Read more Python Name 'os' Is Not Defined

Returning The List Reversed

i have this question: Write a function reverse3(nums) that takes a list of ints of length 3 called … Read more Returning The List Reversed

Attribute Error No Attribute As Load_workbook

this is my code import openpyxl wb = openpyxl.load_workbook('alex.xlsx') ws = wb['Sh… Read more Attribute Error No Attribute As Load_workbook

Django Rest Framework Datatables Delete

Issue I would like to send a list of ID's to the Django Rest Framework API url (which is the re… Read more Django Rest Framework Datatables Delete

Why Does Dict(k=4, Z=2).update(dict(l=1)) Return None In Python?

Why does dict(k=4, z=2).update(dict(l=1)) return None? It seems as if it should return dict(k=4, z=… Read more Why Does Dict(k=4, Z=2).update(dict(l=1)) Return None In Python?

Python: Pip Tries To Install To /bin Directory

I installed python with brew install python which pip /usr/local/bin/pip my PYTHONPATH shows /usr/… Read more Python: Pip Tries To Install To /bin Directory

Filter Pandas Dataframe By List

I have a dataframe that has a row called 'Hybridization REF'. I would like to filter so tha… Read more Filter Pandas Dataframe By List

Matching 3 Or More Of The Same Character In Python

I'm trying to use regular expressions to find three or more of the same character in a string. … Read more Matching 3 Or More Of The Same Character In Python

Importing User Defined Modules In Python From A Directory

I'm trying to import a module I wrote in python that just prints out a list containing numbers.… Read more Importing User Defined Modules In Python From A Directory

Updating Label And Live Graph Dynamically Using Arduino Data In Tkinter

I've been working on a project that updates the label and plots it in a live graph that's c… Read more Updating Label And Live Graph Dynamically Using Arduino Data In Tkinter

Open A Image File Then Display It In New Window

I have a button in my GUI then after selecting a image file I want it to display in new window. Cod… Read more Open A Image File Then Display It In New Window

Numpy.bitwise_and.reduce Behaving Unexpectedly?

The ufunc.reduce for numpy.bitwise_and.reduce does not appear to behave properly... am I misusing i… Read more Numpy.bitwise_and.reduce Behaving Unexpectedly?

Annotate Many To Many Relation In Django

I have two models User and VideoData. These two models contain the details of each user and watched… Read more Annotate Many To Many Relation In Django

Matplotlib Plot Shows An Unnecessary Diagonal Line

So I'm trying to plot the approximation of an equation using Euler's method, and it works, … Read more Matplotlib Plot Shows An Unnecessary Diagonal Line

Json To Dataframe Conversion Issues

{'endDate': '2017-12-31', 'results': [{'data': [{'period':… Read more Json To Dataframe Conversion Issues

Adding,subtracting Datetime.time Columns Pandas

I have following dataframe flight_departure arrival_at_desination boarding total_flight_time … Read more Adding,subtracting Datetime.time Columns Pandas

Python Regex For Password Validation

I have the following requirement to validate the password with below context at least one digit at… Read more Python Regex For Password Validation

Robot Framework: Click Element Using Execute Javascript

I have a xpath selector xpath=//input[@id=image], I want to click on this element using the keyw… Read more Robot Framework: Click Element Using Execute Javascript

Show *only* Docstring In Sphinx Documentation?

Sphinx has a feature called automethod that extracts the documentation from a method's docstrin… Read more Show *only* Docstring In Sphinx Documentation?

Match One Table And Map Value To Other In Pandas Python

I have two pandas dataframes: df1: LT route_1 c2 PM/2 120 44 PM/52 110 49 PM/522 1… Read more Match One Table And Map Value To Other In Pandas Python

Python Re Match, Findall Or Search And Then Nlp (what To Do With It?)

I am starting to write code that would capture part of sentence 'types' and if they match a… Read more Python Re Match, Findall Or Search And Then Nlp (what To Do With It?)

What's Wrong With My Use Of Generator Expression?

I have the following code, in which I try to convert a string representation of ranges to a list of… Read more What's Wrong With My Use Of Generator Expression?

Count Number Of Rows For A Timestamp

I am working on the dataset https://pastebin.com/PEFUspiU I have to group it and count how many re… Read more Count Number Of Rows For A Timestamp

List Item Keeps Same Memory Address Following Sort/copy

Ive recently become confused about how lists work internally. This code tracks the memory address o… Read more List Item Keeps Same Memory Address Following Sort/copy

What Does Request.get.get Mean?

What does request.GET.get mean? I see something like this in Django page = request.GET.get('pag… Read more What Does Request.get.get Mean?

Linking To Audiolab In Python2.6 On Osx

I've been unable to get scikits.audiolab working on OS X. I've tried easy_install and buil… Read more Linking To Audiolab In Python2.6 On Osx

Getting Number Of Hours Between A Date-time Range In Python

So I'm trying to print the total hours in intervals between a start date and an end date in pyt… Read more Getting Number Of Hours Between A Date-time Range In Python

Error Using L-bfgs-b In Scipy

I get some puzzling result when using the 'L-BFGS-B' method in scipy.optimize.minimize: imp… Read more Error Using L-bfgs-b In Scipy

Speeding Up Pandas Code By Replacing Iterrows

I have a Dataframe like below +-----------+----------+-------+-------+-----+----------+-----------+… Read more Speeding Up Pandas Code By Replacing Iterrows

Extract All Files With Directory Path In Given Directory

I have a tar archive in which I have a directory which I need to extract in a given directory. For … Read more Extract All Files With Directory Path In Given Directory

Python Valueerror: Non-broadcastable Output Operand With Shape (124,1) Doesn't Match The Broadcast Shape (124,13)

I would like to normalize a training and test data set using MinMaxScaler in sklearn.preprocessing.… Read more Python Valueerror: Non-broadcastable Output Operand With Shape (124,1) Doesn't Match The Broadcast Shape (124,13)

Problem With Python Pandas Data Output To Excel In Date Format

Need guidance on how I can format a value to date format in Pandas before it prints out the value … Read more Problem With Python Pandas Data Output To Excel In Date Format

Printing Random 1-d Arrays In Python

This code gives 2D arrays but I need multiple 1-dimensional arrays with random numbers. a,b,c,d,e=[… Read more Printing Random 1-d Arrays In Python

Python-data Truncated And Spaces Are Added Between Data While Inserting Into Mssql

Upon inserting the data into the MS SQL Server DB, my values are getting truncated and single extra… Read more Python-data Truncated And Spaces Are Added Between Data While Inserting Into Mssql

Nan To Num Python

I have multiple array that for those I calculate a linear regression, but sometimes it gives me 0/0… Read more Nan To Num Python

Typeerror: 'int' Object Does Not Support Item Assignment Error

sig_txt: [45 67 83 32767 101 90 50] idx_rr:[101] // index after 32767 sig: [45 67 83 101 90 50] // … Read more Typeerror: 'int' Object Does Not Support Item Assignment Error

List Insertion In Python

Suppose I have two lists as follows:- a = [9,11,12,13] b = [0,5] Now, I want to create another li… Read more List Insertion In Python

Changing A Single Index Of A Series

I am trying to change just a particular index of a Series. The indices are Dates. cashflow_series i… Read more Changing A Single Index Of A Series

How To Install Pip From Whl File

I have a file called: pip-19.2.2-py2.py3-none-any.whl I unzipped this and this resulted in the fol… Read more How To Install Pip From Whl File

How To Limit Download Rate Of Http Requests In Requests Python Library?

Is it possible to limit the download rate of GET requests using the requests Python library? For in… Read more How To Limit Download Rate Of Http Requests In Requests Python Library?

Setting Values On A Subset Of Rows (indexing, Boolean Setting)

This is a followup to: What is correct syntax to swap column values for selected rows in a pandas d… Read more Setting Values On A Subset Of Rows (indexing, Boolean Setting)

Clear Line In The Python Idle Shell

Is there a keyboard shortcut to clear a line for the Python IDLE shell? I know Ctrl-K works if you … Read more Clear Line In The Python Idle Shell