Category "python"

Python error TypeError: list indices must be integers or slices, not tuple

def convert(data): new_data = [] for id_users in range(1, nb_users + 1): id_movies = data[:,1][data[:,0] == id_users] id_ratings = data[:,2][data[:,0]

I don't understand how nodes work in a linked list [closed]

I have a basic understanding of usage of nodes, like node = node.next, and self.head, and things like node.next = self.head self.head = new_no

Flask SQLAlchemy Foreign Key Relationships

I'm having a lot of trouble getting my head around foreign keys and relationships in SQLAlchemy. I have two tables in my database. The first one is Request and

Packaging a Python script and the modules it needs

I developed a Python script that uses some libs (Pandas, Numpy, bs4, etc.). The problem is that the customer environment is shared, so I cannot install these li

Remove element from a list based on condition in pandas dataframe

a= {'A' : [1, 2,3,4], 'B' : ['FOOTBALL','BASKETBALL','HANDBALL','VOLLEYBALL'], 'C' : [[5,10,15,40],[1,4],[20,10,40],[10,40]] } How can I remove the element 40

Discord.py commands not running

** ** UPDATE: SOLVED Hi, So im making a bot with the code below in python and i cant figure out why the commands arent working in discord. the only one that wor

Asking the user for input until they give a valid response

I am writing a program that accepts user input. #note: Python 2.7 users should use `raw_input`, the equivalent of 3.X's `input` age = int(input("Please enter yo

Perform sklearn DBSCAN on PySpark dataframe column

I have a Spark dataframe that looks like this: +-----+----------+--------+-----+ |key1 |date |variable|value| +-----+----------+--------+-----+ | A49|2022

Upload file from html when block public access is true

I am using django-s3direct to file upload https://github.com/bradleyg/django-s3direct Using IAM role setting because I upload the file from the server on ECS co

How can I speed up the aiohttp parser bs4?

The task is to get data from the site. I have 800 URLs to request. But it takes a long time .I use aiohttp. At this stage, I have received links, by clicking on

Find Binary in a dir of text files Python or Bash

I have a series of log files that are all text. If a certain error happens it results in binary being inserted in the text. I want a Python or Bash script that

Applying own functions

I am trying to apply my own function. Below you can see the data and function. import pandas as pd import numpy as np data_test = { 'sales_201

cv2 magesearch pyautogui need better way to loop thu functions

im looking for a better way to write this code each function searches for the image using cv2 and pyautogui through python-image search. the code works well but

Why is my linked list size function not working as intended?

I used the following code to define my linked list, nodes and a few functions. class node: def __init__(self,node_data): self.__data=node_data

find max value in a list of sets for an element at index 1 of sets

I have a list like this: dummy_list = [(8, 'N'), (4, 'Y'), (1, 'N'), (1, 'Y'), (3, 'N'), (4, 'Y'), (3, 'N'), (2, 'Y'), (1, 'N'), (2, 'Y'), (1, 'N')]

How to get value from dependent combobox tkinter python?

I'm able to select both the combo box successfully but to print the second dropdown box value, I got lost. Could somebody explain how to print the Table value f

How can I speed up the routing process in OSMNX?

Say I have two taxi orders with Origin1、Destination1 and Origin2、Destination2(O1,O2,D1,D2). I want to calculate the possibility of ridesharing, so

Within a pandas DF, how can I snag last two parts of a list as a single string for conditional output?

I'm doing some modification to a CSV via pandas. For one of the situations, I want to use parse a URL into a list, grab the last two items of that list, and out

Django Form processing files

So I have the following code: # the view class UpdateDateView(LoginRequiredMixin, UpdateView): model = Date form_class = DateForm template_name = '

StringVar.get() doesn't seem to be entirely working (Tkinter)

The relevant code is this: import tkinter as tk from tkinter import ttk import quiz global menu_root def get_question(): question_input = question_respons