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. Use the [python-2.x] tags for Python 2 questions.

-1
votes
0answers
7 views

Lambda functions Pyhton 3

I got the following code: two_to_one = lambda g: (lambda y: g(y, y)) one_to_two = lambda f: (lambda x, y: f(x)+f(y)) h=one_to_two(two_to_one (lambda x, y: x*y)) print (h(3, 2)) #prints 13 However, I ...
0
votes
0answers
7 views

Created a temp XML file for unit tests python

So i have a test where it searched for a specific location for xml files. It then uses a function to combine the content of all of them in to one file. I am trying to use the python tempfile module in ...
0
votes
0answers
21 views

Python: Delete multiple variables if they exist

First, I import between one and 25 files named file_1, ..., file_25; if I import seven, it can be file_1 till file_7, but also any of the other files. Next, I merge them to one. I do this by files =...
0
votes
0answers
10 views

don't know how to access datetime stored in varchar column using python flask

i dont know how to access datetime string stored in varchar type column my flask method is as below from where i am executing mysql query @app.route("/canopus_cycle", methods=['GET','POST']) @...
2
votes
0answers
21 views

Read YAML file as list

I have a YAML file that goes as (just an example): a: b: 1 a: b: 2 c: 1 a: b: 3 I want to read this file, and do some stuff with bs and cs. The problem is that I can't read ...
0
votes
3answers
12 views

How can I check If there is a specified value in a dict?

I'm setting up a script, and I need to know If there is a specified value in my dictionary. dict = {"1" : [1, 2, 3], "2" : [4, 5, 6]} How can I print: 'dict analyzed' If there is 5 in a list? The ...
0
votes
1answer
14 views

how to detect already saved link in a text file

so i made this really simple program that saves the links i give it to a text file and i want it to tell me if i try to save a link that's already there but it won't! what am i doing wrong? import os ...
0
votes
0answers
7 views

How to create multiple pages and keyboard on each pages?

i'm create a GUI program with multiple pages. this code can move from one pages to another pages. but in this case, i can not insert QLineEdit using this keyboard. i was try to figured the solve for ...
-1
votes
0answers
5 views

How to print out commands that we send using netmiko's send_command()

Let's say i'm sending the below command to a switch / platform that doesn't support it. "flowcontrol send desired" Is there a way i can print it out without having to manual type the command in the ...
0
votes
0answers
6 views

How i can get new TOR ip every requests in multiprocessing threads?

I try to use TOR proxy for scraping and everything works fine in one thread, but this is slow. I try to do something simple: def get_new_ip(): with Controller.from_port(port = 9051) as controller:...
0
votes
1answer
21 views

Changing the display name of a file

How can I change the display name of a file using Python? Details: Using Mac OS X Mojave Python 3.7 To be precise, I want to hide the file extension of a file so that textfile.txt is seen as ...
0
votes
0answers
22 views

Formatting a SQL query

I have as an input a string that is a SQL query. I need to get all tables that the query uses (like FROM table or table1 INNER JOIN table2). But the query does not respect any standard. So my question ...
0
votes
1answer
25 views

Pandas Dataframe: How to split one column into multiple one-hot-encoded columns

I have a text file like this: 444537110 3 11112111022002200022022111121222002... The final field in the input file is 50k characters in length and is only ever 0,1 or 2. I ...
0
votes
1answer
11 views

How to fit a huge distance matrix into a memory?

I have a huge distance matrix of size aroud 590000 * 590000 (data type of each element is float16). Will it fit in Memory for clustering algorithm ?? If not could anyone give an idea of using it in ...
-2
votes
0answers
28 views

Write the value of the array at the end of the row in the csv [on hold]

I'm not quite sure I'm using the right logic when writing to a file. Please tell me how to implement this operation With selenium I get certain data and write them to an array, and the values of this ...
1
vote
0answers
16 views

Can I use trilateration technique to identify BLE coordinates?

I have used non linear regression model to convert the rssi values as distance and I have three coordinates and distances of anchor nodes. Using this three anchor nodes, Can I use trilateration ...
-2
votes
2answers
25 views

remove list value when list is in dict

I have a dict, like below, and I want to remove the value '---'. {'I1': ['卤味零食', '蔬菜干'], 'I2': ['Three Squirrels/三只松鼠', '良品铺子', '---', '---']} How can I do that in one line?
0
votes
0answers
15 views

How to make flask work with TCP and UDP using socket

Im using python3 and docker container(the server) with flask that runs on 0.0.0.0:5000->5000/tcp , 0.0.0.0:5000->5000/udp, the application sends live stream between client -- > to server. I ...
0
votes
1answer
7 views

Unable to access system site packages inside virtualenv

import tensorrt Works globally, but creating virtual environment mkvirtualenv -p /usr/bin/python3 --system-site-packages test inside virtualenv import tensorrt No module named 'tensorrt'
-2
votes
0answers
26 views

How to make dataframe from list that contain multiple values?

I have a list like this. I want to store them into a dataframe using: dfObj = pd.DataFrame(att) dfObj.to_csv('attribute.csv') But turns out the result in csv that I get is: This is is the link of ...
0
votes
0answers
34 views

Is there any way of using dataframe created in different python script on another script?

I know that functions can be imported from one script to another but is there anyway of doing same with DataFrame or other variables.
1
vote
2answers
35 views

Can we filter data on the basis of specific words?

I am making a web application which reads data from an Excel file. The data set I have has a columns which has data of categories and sub-categories of books such as 'Fiction.Romantic', 'Fiction....
0
votes
2answers
12 views

pytest assert_called_with doesn't work with Django management commands

Django management command: my_custom_command.py from django.core.management.base import BaseCommand from services.external import ExternalApi class Command(BaseCommand): def handle(self, *args, ...
1
vote
1answer
12 views

How to add a forth bar on a group barchart using matplotlib and seaborn in Python?

I am trying to create a group barchart to show the accuracy, precision, recall and f1 scores achieved by different machine learning classifiers. The group bar chart works ok when I use three bars per ...
0
votes
1answer
19 views

Scrollbars covers data

My treeview data last row is covered by the bottom scrollbar I googled everywhere, no answers found root = tk.Tk() tree = ttk.Treeview(root) scrollbar_horizontal = ttk.Scrollbar(tree, orient='...
0
votes
0answers
11 views

driver.set_page_load_timeout freezes the driver

I have problems with a script that worked until last week (and I have not updated anything). I am using selenium with python on a website that is really slow for some reason, and the information I ...
0
votes
0answers
15 views

Feature scaling converts different columns on a same scale

Scaling converts different columns with different values alike example Standard Scaler but when building a model out of it, the values which were different earlier are converted to same values with ...
-1
votes
1answer
29 views

strptime failing to parse given a correct format

I've written down the formatting that strptime should use to parse my string into datetime, but it kept on failing without a clear reason as to why. I have a date/time string that I wanted to parse: '...
2
votes
0answers
21 views

inputs[0][3] == (1 + coords + classes)*anchors in function 'getMemoryShapes'

I have trained YOLOv2 model on my custom dataset(Single class - Battery). Changed filters to 30, classses to 1 and max_batches to 2000 in the cfg file. I get the final weights and when I try to ...
0
votes
1answer
11 views

err: truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I'm trying to implement a maxnet NN, and I got that error while I was trying to define my activation function, how can I get rid of this error? import numpy as np def AF (Self): if x&...
0
votes
0answers
7 views

How to convert SSL certificates PEM <--> PKCS#12/PFX and PEM <--> PKCS#7/P7B using cryptography module

I would like to do some SSL certificate conversions using python, specifically between: PEM <--> PFX PEM <--> P7B I already have a solution for PEM <--> DER. Namely: from ...
-1
votes
0answers
6 views

How to send data via URL

I want to print Hello name in the web page, where the name will be given through the URL. import tornado.ioloop import tornado.web import time import wordcount class MainHandler(tornado.web....
0
votes
0answers
31 views

Search the index of different characters

I am new to Python and I am trying to get the index of the first instance of a character given a list of characters I tried this: first_char = line.index('&') second_char = ...
0
votes
1answer
11 views

Looking for a way to extract matching audio timestamp within another audio

I have a basic code of checking audio similarity between any 2 audio files. I am using chromaprint and pyacousitic library for checking similarity of 2 audio and its giving me a score of 50-100 range ...
0
votes
1answer
8 views

Python Threading “TypeError: _testmethod() takes 2 positional arguments but 12 were given”

I am running a Thread for a class method and am confused by the necessary syntax. Running code example: from threading import Thread class TestClass: def _testmethod(self, argument): ...
2
votes
0answers
20 views

How to create a inter process communication between javascript process and python process running on same hardware machine

How to implement Inter-Process Communication between javascript process and the python process running on nodejs on the same hardware. I am having a hardware device which runs on nodejs. I have to ...
5
votes
3answers
65 views

How to use regex to identify posts by different people on a forum?

Im trying to use regex to identify posts by different students. The posts are always of the form: "U3951583\n Hi there my name is Harry. Check out http://www.harryresume.com. That's my website. \...
0
votes
1answer
16 views

Convert .csv into .json using python

I am trying to convert csv into json file using python3. I keep getting this error, FileNotFound, when the csv file exists in the directory. Please help me fix the issue. Below is the code i tried. ...
0
votes
0answers
13 views

How can I include a Count in my Django Rest Framework Pagination to count the total number of rows?

I have written a code in Python using Django Rest Framework to fetch data from database(MySql) and view it in browser using Pagination(PageNumberPagination).It is working fine but the problem is the "...
1
vote
0answers
8 views

Python Jira: Get version release date by version name

I've below code to read fix version name: from jira import JIRA jira_options = {'server': 'URL'} jira = JIRA(basic_auth=('username', 'pwd'), options = {'server': 'username'}) fix_version = ...
0
votes
0answers
10 views

How to use the screen manager without .kv file

I have tried to create the multiple screen(i.e tried to use Screen manager) without the use of .kv file i.e all in .py file.But i am unable to create it . please help me out . I had tried to make it ...
0
votes
1answer
6 views

How to fix “Django celery is getting task and start processing but not completing the full job”

I am working with MaskRCNN popular instance segementation problem using tensorflow and keras. I am also using django restframework to process. While celery recieve the task it starts processing and ...
0
votes
1answer
17 views

Problem with initiating form fields as instance variables in form classes

Not able to have a instance variable of WTForm fields as instance variables This is to have multiple number (flexible) of field which can be cascaded to increase number of fields. The program is ...
0
votes
1answer
33 views

Is there a way to grab a variable inside a function inside a class from an imported file? [duplicate]

Total noob here. There are two python files in this example. The first is cloned from github, the second is my own. The first is called city_data.py. Mine is called analyze.py. Within the city_data.py ...
0
votes
0answers
17 views

how to know the excel column or whole file contains only numbers in python

I have been trying to know if an excel file contains only integers or only alphabets by importing it through pandas in python I tried isinstance and isnumeric and isalpha but didn't work I am able to ...
1
vote
1answer
23 views

Modify column data based on other column in pandas

Im new to python and pandas I have a csv with data which im able to read and extract data using pandas as shown below data = pd.read_csv("train.csv") I have many columns below is the columns in ...
0
votes
1answer
11 views

Redirecting after login in django rest framework

I am trying to redirect to a particular url after the user logs in. I am using django rest framework's built-in user authentication. I have tried the following code: In urls.py, I have the following: ...
-5
votes
0answers
15 views

Using return value of one function into another function [on hold]

Write two functions, one called addit and one called mult. addit takes one number as an input and adds 5. mult takes one number as an input, and multiplies that input by whatever is returned by addit.
0
votes
1answer
10 views

Scaling data using MinMaxScaler causing unhashable type error

I’m trying to scale my data with a MinMaxScaler. I’m using sklearn. When I try to fit and transform the dataframe, I’m getting the error message below. I would post some code but it’s identical to ...
0
votes
0answers
15 views

How to select best weight from a set of intermediate weights

Let us say I have trained a cat-classifier and I have generated around 20 intermediate weights(saving weights for every 10 epochs). Now how do I select the best weights which gives the best accuracy ...