Questions tagged [python]

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

0
votes
0answers
3 views

How to build a text generator model(transformer) from scratch?

I could not find a tutorial or guide on how to implement one. All I found was fine-tuning pre-trained models and the closest thing I got to is this guide but it is about building a transformer-based ...
0
votes
0answers
3 views

Django/python handle TCP IP Connections with 3rd party server

I need a way to set up a permanent tcp/ip connection to an external server. Since I don't have much experience in web development, I would like to inquire how to build this setup. until recently we ...
0
votes
0answers
6 views

The code for submitting an answer from a Scrollbar in tkinter doesn't work

So,I tried printing the selection of a scrollbar onto the console,and it does not generate what i wanted it to. When I select for example the 3rd index in the list box it doesnt return 3,but "(2,)...
1
vote
0answers
5 views

How do I get mobile status for discord bot by directly modifying IDENTIFY packet?

Apparently, discord bots can have mobile status as opposed to the desktop (online) status that one gets by default. After a bit of digging I found out that such a status is achieved by modifying the ...
0
votes
0answers
5 views

An Equivalent Built-in method for Orthogonal Matching Pursuit in Matlab?

I know there is a method of orthogonal matching pursuit implemented in sklearn.linear_model https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.OrthogonalMatchingPursuit.html. But I ...
1
vote
0answers
7 views

Python, Dask: Parallel Computing For Loop With No Last Function

trying to parallelize the reading the content of 16 gzip files with script: import gzip import glob from dask import delayed from dask.distributed import Client, LocalCluster @delayed def ...
0
votes
0answers
9 views

How to insert models with ManyToOne relationship using Rest framework Django

i'm learning Django rest framework and i'm looking to implement the following if it's possible, for example if it is the first time a get a parking ticket i would like to create an account for that ...
-1
votes
0answers
6 views

1)can I use tf.function in tensorflow 1x or 2) is tf.function compatible with tensorflow 1x?

I'm currently using an app based on tensorflow package, however there exists a choice gap between version 1 and version 2, or rather, you have to choose one from two of them. And I'm about to use tf....
-1
votes
0answers
12 views

How to calculate AUC with some data points in Python

Here are some data: x = ([1, 2, 6, 12]) y = ([15.7, 13.8, 8.3, 3.2]) I want to calculate the area under the curve (from 0 to \infty) since y is declining exponentially, I have got it by curve-fitting ...
0
votes
0answers
4 views

Can `python-socketio` register a socket level handler for a connected socket?

I'm currently migrating a node-js implemented server to be python implemented. In node-js, I can write like this: const { Server } = require('socket.io'); const io = new Server(); ... io.on('...
0
votes
2answers
10 views

How to add a column containing the occcurence of every element in pandas?

Given a DataFrame such as import pandas as pd df = pd.DataFrame({'a': [700, 700, 600, 600, 600]} How can I extend it with a column containing the occurrence for each row? Such that it ends up as ...
0
votes
0answers
7 views

For Selenium, how would I send a multi-line command through the console of the browser through selenium

I'm using selenium on python right now and I was wondering how to execute multi line commands to the console I am doing this command: script = "alert('Test Alert')" driver.execute_script(...
0
votes
0answers
16 views

Python: convert dictionary from swiplserver

I am using swiplserver for using prolog queries in python. Within that queries I get dictionaries of this kind: to_translate = {'A': 'p', 'B': '_', 'C': 'q', 'Z': {'→E': {'args': [['p', {'args': ['p', ...
0
votes
0answers
8 views

Pytrends Iteration Through Multiple Keywords

Trying to iterate a list from pytrends but getting search volume numbers and concatenating a message. Problem is the output is iterating through the keyword but the data only reflects the first word. ...
1
vote
2answers
19 views

Random number distribution that generates bool values according to a Bernoulli distribution in Python

In C++, this can be achieved by: std::default_random_engine generator; std::bernoulli_distribution distribution(0.5); int count=0; // count number of trues for (int i=0; i<100000; ++i) if (...

15 30 50 per page
1
2 3 4 5
125226