Questions tagged [python-3.x]

For questions about Python programming that are specific to version 3+ of the language. Use the more generic [python] tag if your question is not version-specific.

0
votes
0answers
2 views

Python SQLite insert data into the first record

I want to add data to the first record in my SQLite Table. Now, when I add new data, it gets added into another record. So, I was wondering how I would be able to do this using python. Thanks in ...
0
votes
0answers
11 views

Am I doing this while loop correctly?

I am trying to plot the logarithm of twelve tone equal temperament on a scale of hertz. Is this while loop that breaks in the middle the best way to iterate all of the audible notes in the scale? ...
1
vote
0answers
8 views

Just want to know is it possible to reverse engineer feature list from a pkl file in sckit learn

Just want to know is it possible to reverse engineer feature list from a pkl file in sckit learn import pickle from sklearn.externals import joblib loaded_model = joblib.load("*.pkl") dir(...
0
votes
0answers
7 views

How to analyze dependency tree for conda

Is there a tool for analyzing Conda dependencies as we do have in Maven? ie: In Java projects (maven based) you say mvn dependency:tree and it shows all the dependencies (along with transitive ...
1
vote
0answers
21 views

Trying to run a file in python, but there is an error

I am making a login to run a program, but when I try to run the file at the end of the program it throws an error while True: login1 = input("Login:") login2 = input("Password:") ...
0
votes
0answers
5 views

Trying to add an image that functions like a button, but this error, image “pyimage2” doesn't exist, pops up

I already have a set of code that is similarly formatted as the one below, and that seems to work. But somehow, the image for this one isn't popping up. And they're in the same folder as the code. Def ...
1
vote
0answers
8 views

Updating existing rows Postgresql

I have a table of api calls grouped by hour, then by user, then by api key. I have many of these from different hosts, in pandas dataframes, and am wondering how to do the following. My rows look ...
1
vote
0answers
8 views

Use Scrapy to find duplicate images accross pages

I'm trying to use scrapy to find image URLs that are used more than once on a website across all pages. This is my spider: # -*- coding: utf-8 -*- from collections import defaultdict import scrapy ...
1
vote
0answers
7 views

How to retrieve page content from a list of website links using a for loop in python and lxml?

I am scraping data from a website and I have retrieved a list of URLs from which I will be getting the final data I need. How do I retrieve the html from this list of addresses using a loop? Using ...
0
votes
0answers
5 views

InvalidArgumentError: Inputs to operation of type EluGrad must have the same size and shape. Input 0: [1,20] != input 1: [32,20]

I have the following code which should be the minimum replicated example from keras.callbacks import ModelCheckpoint from keras.layers import advanced_activations from keras.models import Sequential ...
0
votes
0answers
11 views

Try/Except not working when fetching from SQLite database

I am bulding an app that extracts different attributes from an XML file in my iTunes library export. Since not every song has a genre, finding one per song will not always work. When the program ...
1
vote
0answers
12 views

Read File Using Pandas and Nested Dictionaries

I'm trying to print out the number of murders in each state within each decade. I'm reading the data from the file. However, I'm having trouble accessing the states in each decade and incrementing ...
1
vote
0answers
11 views

Installing ordinary differential equation package

Trouble installing odeint i tried from scipy.integrate import odeint and received this error message: 'from' is not recognized as an internal or external command, operable program or batch ...
1
vote
0answers
24 views

Failing to generate S=>Ba from python code given

Given S=>BaB, B=>b and null(B), the code is supposed to generate S=>BaB|aB|Ba|a and B=>b but it is not generating Ba i.e the output is S=>BaB|aB|a and B=>b which is not correct. The ...
1
vote
1answer
10 views

Recursively calling a second function inside a function

I have this code that counts up -3, -2, -1. I have also written another that counts down 3, 2, 1. If the condition is true for another after an input, the program should stop. For Example, The input i ...
2
votes
0answers
12 views

mpi4py: Spawning processes and parent not exiting, hangs execution on call to comm.Disconnect

I am testing a code that needs matrix multiplication, and I want to delegate this operation to another code that I modified from the examples in mpi4py for matrix multiplication. The code that spawns ...
1
vote
0answers
10 views

Elegant way to find indexes for lists within lists?

Pretty new to python. I'm trying to index items in CSV files by row/column. The only method I've found is implementing a for loop to search each row in the list. readCSV = [['', 'A', 'B', 'C', 'D'], ...
1
vote
2answers
20 views

How can I find the sum of multiple groups within a series?

I have a short series of ~60 values. What I need to do is find the largest sum of 24 consecutive values in the series. e.g. I would need to be able to find the sums of the groups [0:23],[1:24],[2:25]...
0
votes
0answers
10 views

How to make a generic id class in Python 3.7

Coming from a Java background, I know that for example an ID can be implemented as a generic like this: public class Id<T> { private String _id; private OId(String idString) { ...
1
vote
1answer
18 views

Receiving ValueError: x and y must be the same size for x and y values. Any help would be appreciated

Currently working a machine learning problem for predicting the weather. Here however I while I was running my code in Jupyter notebook I came across the above error and I am not sure where I am going ...
2
votes
1answer
21 views

Need to remove while loop

I have an animated gif running in a while loop forever but I just want the gif to run once. I have tried removing the while loop but then I got last_frame not define. import tkinter as tk def ...
2
votes
0answers
12 views

How to correctly use scipy.stats.lognorm?

I'm trying to learn Python through the lecture series at Quantopian and am having trouble understanding how to use scipy.stats.lognorm and the documentation. This are the excerpts: pdf(x, s, loc=0, ...
1
vote
0answers
18 views

ValueError: Expected 2D array, got 1D array instead: array=[0.31818181 0.40082645 0.49173555 … 0.14049587 0.14876033 0.15289256]

from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( data, target, test_size=0.25, random_state=0) from sklearn.model_selection import ...
1
vote
1answer
21 views

Counter library not keeping sorted when using the .keys() method

So for my project, I am trying to graph word frequencies from a dictionary. I am using Counter to get a sorted dictionary from a list of words. The problem is when I go to convert the dictionary back ...
2
votes
0answers
15 views

Python/Requests POST with multiple authentication tokens

I'm trying to do a single POST to multiple accounts. I have a list of the authentication tokens to each account but can't seem to get the program to cycle through the tokens to post each one. I've ...
1
vote
0answers
9 views

Multiple marks on a legend

I created a legend for some marks that I plotted in an image from satellite data. I can't figure out how to have multiple marks for the different places I'm ploting. import matplotlib.patches as ...
3
votes
3answers
47 views

Python reverse dictionary items order

Assume I have a dictionary: d = {3: 'three', 2: 'two', 1: 'one'} I want to rearrange the order of this dictionary so that the dictionary is: d = {1: 'one', 2: 'two', 3: 'three'} I was thinking ...
2
votes
0answers
22 views

How to separate output of xpath statement

I'm new to Python and Selenium and I scrapping information from website. Some items don't have proper div class to provide normal script functioning. I need to separate the output of xpath statement, ...
-3
votes
0answers
12 views

The error encountered was: dial tcp [::1]:5000: connectex: No connection could be made because the target machine actively refused it

I try to use twilio..but i got this error The error encountered was: dial tcp [::1]:5000: connectex: No connection could be made because the target machine actively refused it.
3
votes
0answers
22 views

Question on how to create a new column based on current df columns

I am trying to figure out how to create a new column for my df and cant seem to get it to work with what I have tried. I have tried using loans_df.insert("Debt_Ratio",["MonthlyDebt"*12/"Income"]) ...
2
votes
1answer
12 views

how do u replace part of a each “elements” of a dataframe column with something else

I want to change a columns of dates that have a defaulted value that is invalid in pandas date-time conversion. Say I have: index Date_posted Voted_on id .... 0 2002-10-00 ... ... 1 ...
2
votes
1answer
25 views

Weighted Grade book Project

Create a program that will calculate a student’s grade in a class that uses a weighted gradebook. A weighted system uses percentages to determine how much each assignment category is worth. For this ...
1
vote
0answers
10 views

Getting “raise JSONDecodeError(”Expecting value", s, err.value) from None json.decoder.JSONDecodeError

I'm getting the JSONDecodeError error when i try to run the below code. I am not sure how to fix it. I am trying to stream tweets. It works fine for few tweets and all of a sudden I get the error and ...
2
votes
2answers
20 views

Merge Series and DataFrame

I would like to merge a series with an index that is the same as a dataframe columns. I have tried pd.concat, but that doesnt work. I want samp_series = pd.Series([1,2], index=['a', 'b']) samp_df =...
0
votes
2answers
24 views

How to create a list for every list element of a list?

I am trying to use a previously made list of elements and create an individual list for each element of the previously made list. List1 = ['billy', 'dilly'] Code stuff now billy is a list dilly is a ...
1
vote
0answers
10 views

Error when checking input: expected input_32 to have 3 dimensions, but got array with shape (1000, 12)

i have the following problem. By implementing the following code def model(inp_size): inp = Input(shape=(inp_size, 1)) x1 = Dense(50, activation='elu')(inp) x1 = Dense(20, activation='...
0
votes
0answers
16 views

Different Bleu Score For same file

This evaluation file which use cumulative 4-gram bleu score is used in VQA-MED challange, to test the evaluation file output, I tend to evaluate a file containing the actual sentences with itself (i.e....
1
vote
1answer
16 views

trying to add data and query a mysql database using sqlobject and python 3

My code is raising an exception as shown below. I am pretty sure the problem is with my definition of the table relationship. I have tried multiple alternatives that give varying errors :-( I have ...
1
vote
0answers
8 views

How to classify a very large amount of text in python 3?

I have to classify very large amounts of text in over 10,000 categories. I will need expert advice because I am still a student. For now, I've turned the text into a tf-idf matrix and use multiple ...
1
vote
0answers
13 views

Tensorflow saving and restoring into a fresh session/graph

Suppose you make a tensorflow session, train a network with weights, and save the graph: import tensorflow as tf with tf.Session(graph=tf.Graph()).as_default() as sess: with sess.graph.as_default(...
2
votes
1answer
9 views

Django ImportError: cannot import name 'render_to_response' from 'django.shortcuts'

After upgrading to Django 3.0, I get the following error: ImportError: cannot import name 'render_to_response' from 'django.shortcuts' My view: from django.shortcuts import render_to_response from ...
0
votes
0answers
21 views

is there a format to assign multiple variables in a single line of code if it goes beyond the 88 character max length?

i want to assign multiple variables based on multiple fields on a single csv line. however, the variable names go far beyond the 88 character max length in black formatter. Is there a way to format it ...
1
vote
0answers
15 views

How can I get super detailed Django debug info?

I have a very difficult to diagnose Django problem in which sometimes the server locks up for a period of time many attempts to debug it have not succeeded. So I need to see at the most detailed ...
0
votes
1answer
12 views

Scrap from an empty class tag (HTML)

I want to scrap Directors and Actors from IMDB from a single webpage which lists top 50 films of 2018. The issue I have is that I have no idea how to scrap them as the class has no name. '''part of ...
-3
votes
0answers
31 views

Can't cleanup whitespace and \n chars in dict:keys

filling dictionaries in python3 that contains string like ' \n \n \n \n \n ' It's not possible for me to ...
0
votes
0answers
5 views

HTTPError: Unauthorized error while accessing internal site

I'm trying to download a csv file with the following url (changed for security) import wget url ='http://air.abcd.com/sys_re&CSV' wget.download(url, 'C:/Users/dbhadra/Desktop/test.csv') This ...
0
votes
0answers
10 views

How to Using end=' ' in server side

I'm making a client-server programs, that count a fibonacci. i put my input in client side and all my function on the server side. in my fibnoacci function on server side, i use end='' to read all ...
0
votes
1answer
23 views

Having a problem creating a multi-answer quiz in Python

I am doing my final project for my intro to Python class. The most we got to was how to use dictionaries(ch. 9 of our textbook). The goal of my project is to create a fun buzzfeed-like quiz where the ...
0
votes
1answer
20 views

parent child conditional statements scraping websites with python and selenium

I'm trying to scrape product reviews from a website using python3 and selenium chromedriver. Embedded in these reviews are company responses (remove these). These company responses are easily ...
0
votes
0answers
7 views

How to block WebKit2 context menu?

I am developping a small application. I want to hide/block the default context menu of the WebKit2 webview. When I used WebKit, I was able to hide/block the default context menu by using the ...

http://mssss.yulina-kosm.ru