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.
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 ...
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 ...
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 ...
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 ='...
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 ...
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 ...
asked 3 mins ago
peterphonic
78111 gold badge1313 silver badges3333 bronze badges
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')...
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 ...
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 ...
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 ...
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 ...
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 ...
asked 12 mins ago
Tycho
48311 gold badge55 silver badges99 bronze badges
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, ...
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/...
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 ...
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 ...
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 ...
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(...
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.
...
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....
asked 21 mins ago
Joel Parker
24311 gold badge22 silver badges1414 bronze badges
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]...
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 ...
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 ...
asked 24 mins ago
zinyosrim
1,01111 gold badge99 silver badges2323 bronze badges
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 = [...
asked 24 mins ago
Luigi Plinge
47.5k1818 gold badges9898 silver badges170170 bronze badges
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 ...
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....
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 ...
asked 26 mins ago
Kent Pawar
1,33822 gold badges1515 silver badges3232 bronze badges
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", &...
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 ...
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....
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 ...
asked 30 mins ago
ZKK
10311 silver badge66 bronze badges
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 ...
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....
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....
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
...
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 ...
asked 34 mins ago
Débora
5,0792121 gold badges8181 silver badges151151 bronze badges
print("Enter a number: ", end="")
try:
number = int(input())
except ValueError:
print("Value ERROR")
except NameError:
print("Name ERROR")
def ...
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 ...
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 ...
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 ...
asked 38 mins ago
rvinas
8,6062424 silver badges4343 bronze badges
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, ...
I have a dataframe similar to the following:
| Session | Leg | Talk Time Seconds | ... |
| ------- | --- | ----------------- | --- |
| 1 | 1 | 0 | ... |
| 1 | 2 | 40 ...
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 ...
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-...
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 ...
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 ...
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 ...
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 ...
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=...
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=...