Questions tagged [python]

Python is a multi-paradigm, dynamically typed, multipurpose programming language. It is designed to be quick to learn, understand, and use, and enforce a clean and uniform syntax. Please note that Python 2 is officially out of support as of 01-01-2020. Still, for version-specific Python questions, add the [python-2.7] or [python-3.x] tag. When using a Python variant or library (e.g. Jython, PyPy, Pandas, Numpy), please include it in the tags.

Filter by
Sorted by
Tagged with
0
votes
0answers
3 views

Graphene: “Expected a value of type XXX but received: …”

I'm using graphene-django to build my API. I have a DjangoObjectType named StoreType which represents the model Store. This model has a MultiSelectField named opening_days that indicates what days in ...
0
votes
0answers
3 views

PyInstaller: How to fix “Missing Module” errors?

I want to build a standalone executable application from my python script(s) so that other users can run it without having to install Python and it's packages. I used pyinstaller --onefile GUI.py to ...
0
votes
0answers
3 views

Python BeautifulSoup4 Parsing: Hidden html elements on Yahoo Finance

I am analyzing the balance sheet of Amazon on Yahoo Finance. It contains nested rows, and I cannot extract all of them. The sheet looks like this: I used BeautifulSoup4 and the Selenium web driver to ...
0
votes
0answers
10 views

Variable not passing as an Arg [python]

I am trying to automate a functions based on what input is received but I'm getting an error when I try to pass the input as and arg for a function. Heres an example of what Im trying to do var ='...
-3
votes
0answers
11 views

How I can extract data from complex PDF file which involves multiple tables using python. I tried using camelot, tabula, pypdf2, nothing worked

https://psref.lenovo.com/Product/ThinkPad/ThinkPad_P1_2nd_Gen Here is the link to the PDF file. I also tried converting the file to excel, then extract. But it leads to complex tabular structure with ...
0
votes
0answers
6 views

how to resolve Python regex error “error bad escape \m at position 37”, when passing from 3.5.4 to 3.6.8

I have a python piece of code that was working on 3.5.4 but now is broken on 3.6.8. It looks like related to how regex are managed by python. Found some thread, but I don't understand how to fix my ...
0
votes
0answers
10 views

How to convert for results into a list-Python

I am trying to put my results into a list. Here is my code: from ise import ERS l = ise.get_endpoints(groupID=my_group_id)['response'] Here is my output: [('AA:BB:CD', 'cvr5667'), ('AA:BB:CC', '8888')...
0
votes
0answers
5 views

Previous form data being applied to Form for editing in django

I have a way for users to edit comments they posted in Django but now Im trying to implement a feature where when users go to edit their comments the previous comment is displayed in the form. This ...
0
votes
0answers
8 views

Webscraping different URLs - limit

I have coded a web scraper for auto trader but for some reason when iterating through urls I can only ever get a maximum length of 1300 for my dataframe. There are 13 results per page so is there some ...
0
votes
0answers
6 views

How to import session variables in Flask from routes in to another file script?

Please help me to pass variables from @app.route in to an another (server) python file. I try to make a method but it gives me an error: "Outside of the text context". I want to collect the ...
1
vote
1answer
27 views

How to count how many times a entity appears with another entity

I have the following Dataframe: df = pd.DataFrame([[1, 2], [1, 3], [4, 6], [4, 7]], columns=['group_id', 'student_id']) Each student_id can appear multiple times in different group_ids with others ...
0
votes
0answers
5 views

Processing video (or screenshots) of a video game map into a single large PNG map

Here's some footage of the game in question: https://www.youtube.com/watch?v=bzDmy1Y1X1s I want to make a full scale PNG map of the entire world to use with the Google Maps API. Is there any ...
0
votes
0answers
5 views

PyQt5 need append elements from dict to list [the list then is transformed in pandasdataframe]

Hello Friends im with a little problem when I want to insert values in a xls file from a PyQt Program the code is below: import sys import pandas as pd from PyQt5.QtWidgets import QApplication, ...
-1
votes
0answers
8 views

How to Scrape Reddit comments from all threads in a subreddit?

So I am working on a project where I need to scrape comments from ALL/MULTIPLE threads in a subreddit. I can do it like this... submission = reddit.submission(url="https://www.reddit.com/r/...
0
votes
0answers
8 views

How to animate two lines at once with Matplotlib.animation.FuncAnimation class in python?

I am currently trying to animate my numerical algorithms for the 3-body-problem. It all works fine when I animate a single trajectory, but I am not able to do the same for two or three at the same ...
0
votes
0answers
15 views

None in creating many instances of a class python [duplicate]

so I am trying to create many instances of the same class in python and store them in a list and use them as necessary. This is due to the fact that in the eventual script I will use this in I need a ...
0
votes
0answers
14 views

how can i show the variable names in x-axis not the value

my code about create Frequency distribution table and representation this to histogram and is working for me but the problem that i find is the x-axis not variable is value and this photo for the ...
0
votes
1answer
4 views

Discord.py | How can I make the bot tag the owner of the guild on joining the guild?

My code: @commands.Cog.listener() async def on_guild_join(self, guild): general = find(lambda x: x.name == "general", guild.text_channels) if general and general.permissions_for(...
0
votes
0answers
4 views

Marshmallow - Add parameter to include children entities

I have a database model called Store with relationship with Products. Have also defined a StoreSchema that is working just fine. I can retrieve a Store and its Products when using the dump method. ...
0
votes
0answers
18 views

Python 3 conditional statement comparing byte array strings

Python 3 forces me to send a string literal as a byte array. Shown in code below: cmdSer=serial.Serial('/dev/ttyUSB3', 115200) cmdSer.write('AT+CGREG?\r'.encode()) while True: response = cmdSer....
0
votes
2answers
33 views

Python: find all combinations of elements in list to reach a certain value

so here's my problem; i'm given a list, for example; [2,5,8] and a value 'c', for example ; 33. So, because the length of the list is 3, i have to return a list of tuples(i,j,k) for which iw[0] + jw[1]...
0
votes
2answers
17 views

geturl() in python urllib library not working

I'm using the urllib to build a simple web scraper and need to know if a url redirects after being opened with the urlopen method. I'm calling the geturl() method on the response object but getting ...
0
votes
0answers
10 views

Python code generated by Insomnia GraphQL client reacts not as expected

I've an issue with the python code generated by Insomnia with submitting GraphQL queries to Shopify with Umlauts. When using the Insomnia client the query is executed as expected When using the ...
-4
votes
1answer
37 views

Passing arguments to function in Python

In a simplified example, say I have class Car: def __init__(self, operation): ... def change_wheels(car, wheel_type): ... def repair_brakes(car, brake_pads, brake_fluid): ... car_list = [...
0
votes
0answers
16 views

Function returning correct values individually but wrongly in a full on project

The below function returns wrong target values when run as part of my trading application. But when run separately in a different file, it gives correct value. the function takes an order id, the ...
0
votes
0answers
9 views

django endpoint not returning all fields specified in serializer

This is Source Def: class SourceDefinition(models.Model): source = models.ForeignKey(Source, on_delete=models.DO_NOTHING) special_id = models.IntegerField(default=0) ad_group = models....
0
votes
0answers
7 views

Hive SQLs fail in PyHive, works in HUE

All queries work fine in HUE for all the tables including table_1 But in PyHive, all queries always fail just for table table_1 with the below error Even SQLs referencing a column without a space or ...
0
votes
1answer
33 views

Ones removed. Not evident as to why?

Im trying to learn how to code and i think ive almost got it but it seems that some "1's" get removed and i cant seem to figure out why. Can anybody help? test_data = ["1912", &...
3
votes
2answers
13 views

Cloud builds failing for super simple Flask app no matter what I do

So, I wanted to try GCloud since you can deploy serverless stuff pretty easily. I've made simple Flask app to test it out, this is the entire code for the app: from flask import ( Flask ) from ...
1
vote
0answers
10 views

Placing List of Instances into Dataframe but One Attribute is another List of Dictionaries

I've been scouring past answers for the past couple hours and I'm still stuck. I have two classes: class Profile: def __init__(self, department_id, profile_id, items=None): self....
-1
votes
0answers
7 views

How to solve the ContainDS Desktop Container Import Error HTTP code 500

I have downloaded both ContainDS and Docker for Windows Desktop. And I have selected Streamlit as the environment. After launching both and export the .containds file, I want to use ContainDS to ...
0
votes
0answers
17 views

Read all files from a directory, then read lines based upon a matching string and print them all

I am sure I am doing some silly mistake here, but not able to move forwards after lots of tries. I have several txt files in a directory and I want to read them one by one, then I am looking for one ...
1
vote
2answers
37 views

I followed all the steps in a video, and still I got an AttributeError [closed]

Here is the code with the error. import sqlite3 as lite # functionality goes here class DatabaseManage(object): def __init__(self): global con try: con = lite....
0
votes
0answers
14 views

How to modify number of images faster in nested folders?

I wrote a method that reads all images in nested dataset to resize them, but I think using nested loop takes too much time. Is there any better idea for iterating folders? any idea will be appreciated....
0
votes
2answers
15 views

How to handle simultaneous requests in Django?

I have a standard function-based view in Django which receives some parameters via POST after the user has clicked a button, computes something and then returns a template with context. @csrf_exempt ...
1
vote
0answers
14 views

Keras continuous training with DB

I am new to Keras and still looking for ways for continuous training the model. Since my dataset is very large to store in memory, I am supposed to store in a DB (NoSql DB- MongoDb or HBase) and train ...
-1
votes
0answers
16 views

This 100% Working code in PyCharm , errors in Powershell.→ Identical code. Why??? Do i miss something?

print("Enter a number: ", end="") try: number = int(input()) except ValueError: print("Value ERROR") except NameError: print("Name ERROR") def ...
0
votes
0answers
4 views

update inner lists in mongodb with python(pymongo)

update inner lists in MongoDB using python(pymongo) x : [ {a:[1,2,3],b:1}, {a:[4,5,6],b:2} ] required to update each of "a" based on "b". At this moment my ...
0
votes
1answer
11 views

drawing an image for a set number of frames pygame

How would I make an image stay on the screen for a set number of frames in pygame? I am trying to make Simon. I need a square to light up for a certain number of time and then return to its original ...
0
votes
0answers
6 views

Different edge widths when saving networkx graph as pdf

Problem: I would like to save a networkx plot in vectorised format (e.g. as pdf), but this does not preserve the expected edge widths. Example: Consider the following snippet: import networkx import ...
0
votes
0answers
15 views

Does order matter when using Recursive backtracking

I have the following function: def see_row_combs(row, blocks): for cell in range(len(row)): if row[cell] == -1: for color in (0, 1): if is_valid(row, blocks, ...
0
votes
1answer
24 views

How can I reference other rows in a Pandas dataframe apply

I have a dataframe similar to the following: | Session | Leg | Talk Time Seconds | ... | | ------- | --- | ----------------- | --- | | 1 | 1 | 0 | ... | | 1 | 2 | 40 ...
-2
votes
0answers
13 views

Async Django view

I am curious about if I can use Async views for returning dynamic objects for my list view which has filtering. So view will update the list of objects shown in HTML without page refresh when user ...
0
votes
1answer
12 views

ImportError: cannot import name 'AutoModelWithLMHead' from 'transformers'

This is literally all the code that I am trying to run: from transformers import AutoModelWithLMHead, AutoTokenizer import torch tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-...
1
vote
1answer
19 views

Problem in creating delete button in django

I am trying to build delete button and currently stuck. I am new to django and need help. Thank You This is my models.py:- from django.db import models from django.contrib.auth import ...
-5
votes
0answers
23 views

Enter web page input through Python [closed]

I would like to enter a text in an input field on a public website (which I have not created or maintain). Example: I would like to search for a series on Netflix (in the browser) and need to be able ...
0
votes
0answers
12 views

How compare field of two different models in Django

One of the main goals of project is control users done visits to customers. Available Customers, Employees and Appointment models. Make appointment to Customer and assign it to Employee on any future ...
1
vote
1answer
13 views

Python GUI call function repeatedly and have button Presses

I'm having this issue where my GUI program calls another class repeatedly (say 5 times a second), it calls class.Process(). I also have buttons that call class.Process() and the gentlemen who gave me ...
0
votes
0answers
9 views

How to justify text alignment to right in tkinter.?When the variable v=='hai' the bot's reply wants to be from right side

how to justify text alignment to right from tkinter import * #from time import * root=Tk() #root.geometry('2000x800') ABC=Frame(root,bg='#1f5629',bd=20, relief=RIDGE) ABC.grid() def sent(): v=...
0
votes
0answers
9 views

Find an element inside a PySimpleGui's Frame by a key

How to find an element inside a PySimpleGui's Frame by a key without hardcoding it via .Rows[0]? import PySimpleGUI as sg layout = [ [sg.Frame(layout=[ [sg.Text('Field:'), sg.Text('', key=...

1
2 3 4 5
29965