content
stringlengths
85
101k
title
stringlengths
0
150
question
stringlengths
15
48k
answers
list
answers_scores
list
non_answers
list
non_answers_scores
list
tags
list
name
stringlengths
35
137
Q: How solve: "ValueError: The truth value of a Series is ambiguous." with no operators errors? I'm categorizing a df, and trying to save the category in a column, but i am recienving this error: ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item() a.any() or a.all(). Here's the cod...
How solve: "ValueError: The truth value of a Series is ambiguous." with no operators errors?
I'm categorizing a df, and trying to save the category in a column, but i am recienving this error: ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item() a.any() or a.all(). Here's the code: import pandas as pd import numpy as np df=pd.read_csv(r'C:\Users\gabri\Downloads\credit_scori...
[ "within your assign_status function, make reference to the row instead of the df\nCredits: @Naveed\n:)\n" ]
[ 1 ]
[]
[]
[ "apply", "database", "pandas", "python", "series" ]
stackoverflow_0074254396_apply_database_pandas_python_series.txt
Q: Can't convert non-rectangular Python sequence to Tensor with tf.data.Dataset.from_tensor_slices I want to create Tensorflow dataset using tf.data.Dataset.from_tensor_slices but I got this error: Can't convert non-rectangular Python sequence to Tensor. To simplify the issue, I took the following example which is si...
Can't convert non-rectangular Python sequence to Tensor with tf.data.Dataset.from_tensor_slices
I want to create Tensorflow dataset using tf.data.Dataset.from_tensor_slices but I got this error: Can't convert non-rectangular Python sequence to Tensor. To simplify the issue, I took the following example which is similar to my data: import tensorflow as tf data = ['A', 'B'] label = [ ['a1', 'a2', 'a3'] , ['b1'...
[ "This should work,\ndataset = tf.data.Dataset.from_tensor_slices((data , tf.ragged.constant(label)))\n\nfor data in dataset.as_numpy_iterator():\n print(data)\n\n#outputs\n(b'A', array([b'a1', b'a2', b'a3'], dtype=object))\n(b'B', array([b'b1', b'b2', b'b3', b'b4'], dtype=object))\n\n" ]
[ 1 ]
[]
[]
[ "dataset", "python", "tensorflow" ]
stackoverflow_0074253789_dataset_python_tensorflow.txt
Q: Pandas how to avoid SettingWithCopyWarning that possibly make pandas confuse values? I am making a bot that for now downloads price data from one of the brokers every X period of time. I have realised that for some reason values are switched between Close/High/low/open price columns, and that is possibly due to th...
Pandas how to avoid SettingWithCopyWarning that possibly make pandas confuse values?
I am making a bot that for now downloads price data from one of the brokers every X period of time. I have realised that for some reason values are switched between Close/High/low/open price columns, and that is possibly due to the SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFra...
[ "Using loops with Pandas is very not recommended as it's not efficient. Pandas support vectorized operations, meaning you could calculate something for the whole columns once without looping through the rows.\nRegarding the warning, this is because you are selecting a copy of a section of the dataframe and manipula...
[ 1 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074254435_pandas_python.txt
Q: Postgres: psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type boolean I'm running the following query in Postgres: INSERT INTO "attack_paths_attackpathprevscan" ("createdAt","account_id","org_id","event_id","action_id","assets") VALUES (('2022-10-30 08:51:13.934641')::timestam...
Postgres: psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type boolean
I'm running the following query in Postgres: INSERT INTO "attack_paths_attackpathprevscan" ("createdAt","account_id","org_id","event_id","action_id","assets") VALUES (('2022-10-30 08:51:13.934641')::timestamp, ('cd802832-c0e8-4376-a1f7-730836cb0885'::uuid)::uuid, ('e5f8eaff-54f0-4...
[ "\nYou left out the part where you are actually doing this in psycopg2.\n\nPostgres arrays cannot have mixed types , so the ...true,true,... is creating the error. You will have to change to something like ...'true','true',... or ...'t','t',...\n\n\nAs demonstration:\nselect ARRAY['ap1-node1', true];\nERROR: in...
[ 1 ]
[]
[]
[ "postgresql", "psycopg2", "python" ]
stackoverflow_0074251820_postgresql_psycopg2_python.txt
Q: what is wrong with this python code implementation Below is the code for establishing multiple TCP sockets in python. But it does not work. What could be wrong? Exception in thread Thread-1 (clientthread): Traceback (most recent call last): File "C:\Users\kishore\AppData\Local\Programs\Python\Python311\Lib\thr...
what is wrong with this python code implementation
Below is the code for establishing multiple TCP sockets in python. But it does not work. What could be wrong? Exception in thread Thread-1 (clientthread): Traceback (most recent call last): File "C:\Users\kishore\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 1038, in _bootstrap_inner self.run() li...
[ "You just passed the wrong argument to the thread to give to the function.\nYou passed args=(1,) instead of args=(conn,):\nthreading.Thread(target=clientthread,args=(conn,)).start()\n\n" ]
[ 0 ]
[]
[]
[ "python", "server" ]
stackoverflow_0074254203_python_server.txt
Q: Unsupported array index type when using numba I would like to use numba to expedite my code (see MWE below). However, I face NumbaTypeError: unsupported array index type. What would be the problem & solution? import numpy as np import numba as nb a = np.array([4, 5, 6, 7, 8, 9], dtype=np.int16) b = np.array([ 2, ...
Unsupported array index type when using numba
I would like to use numba to expedite my code (see MWE below). However, I face NumbaTypeError: unsupported array index type. What would be the problem & solution? import numpy as np import numba as nb a = np.array([4, 5, 6, 7, 8, 9], dtype=np.int16) b = np.array([ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,...
[ "Although numba supports reshape function, I removed this function and modified the MWE code as follows:\nimport numpy as np\nimport numba as nb\n\na = np.array([4, 5, 6, 7, 8, 9], dtype=np.int16)\nb = np.array([ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], dtype=np.int16)\nc = np.zeros((...
[ 0 ]
[]
[]
[ "numba", "numpy", "python" ]
stackoverflow_0074241678_numba_numpy_python.txt
Q: Fibonacci sequence numbers to list with an optional start parameter I am trying to create a function which will take a number n as its parameter and returns the first n elements of a fibonacci sequence in a list. But, I also want to include an optimal parameter 'start' (a pair of numbers, which specifies the first...
Fibonacci sequence numbers to list with an optional start parameter
I am trying to create a function which will take a number n as its parameter and returns the first n elements of a fibonacci sequence in a list. But, I also want to include an optimal parameter 'start' (a pair of numbers, which specifies the first two elements of a generalised Fibonacci sequence. Any ideas how to inclu...
[ "Because You pass start as a tuple you need to convert this to a list and assign it to sequence.\ndef fibonacci(n, start = (0, 1)):\n sequence = list(start)\n\n for i in range(3,n+1):\n next_num = sequence[-1] + sequence[-2]\n sequence.append(next_num)\n \n return sequence\n\nprint(fibonac...
[ 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0074254389_python.txt
Q: How to compare more than one dataframe and return less than or equal I have two data frames that i would like to compare either less than or equal to a certain number. For example, i would like df1 to find -10 or + 10 in df2 and return the Ids and range from both data frames. df1 df2 Result A: Try: x = df1.me...
How to compare more than one dataframe and return less than or equal
I have two data frames that i would like to compare either less than or equal to a certain number. For example, i would like df1 to find -10 or + 10 in df2 and return the Ids and range from both data frames. df1 df2 Result
[ "Try:\nx = df1.merge(df2, how=\"cross\")\nx[\"Range\"] = x.ID_y - x.ID_x\nx = x[x.Range.abs() <= 10]\n\nprint(x)\n\nPrints:\n ID_x ID_y Range\n4 98 89 -9\n5 98 100 2\n9 98 92 -6\n15 92 82 -10\n16 92 89 -3\n17 92 100 8\n21 92 92 0\n25 8...
[ 3 ]
[]
[]
[ "dataframe", "jupyter_notebook", "list", "python" ]
stackoverflow_0074254343_dataframe_jupyter_notebook_list_python.txt
Q: Pandas, count common occurences with reference when reference changes on each row I Have a table, here's an example: df=pd.DataFrame({"ID":[1,2,3,4,5,6,7,8,9,10,11,12],'RefID':[2,2,2,2,2,2,2,8,8,8,8,8],"Options":[["A","B","C","D","E"] , ["A","B","C","D","E"] , ["A","B","C","D","E"] , ["D","B","C"] , ["A","B","D","...
Pandas, count common occurences with reference when reference changes on each row
I Have a table, here's an example: df=pd.DataFrame({"ID":[1,2,3,4,5,6,7,8,9,10,11,12],'RefID':[2,2,2,2,2,2,2,8,8,8,8,8],"Options":[["A","B","C","D","E"] , ["A","B","C","D","E"] , ["A","B","C","D","E"] , ["D","B","C"] , ["A","B","D","F","G"] , ["D","A","C","G"] , ["G","C","D","A","P"] , ["D","B","C"] , ["A","B","D","F",...
[ "There is a better way: first create a mapping dictionary by setting ID as index and selecting Options column then iterate over the pairs of id and refid and yank the corresponding options using dict lookup and use set intersection to get common elements\nd = df.set_index('ID')['Options']\ndf['count'] = [len(set(d[...
[ 0 ]
[]
[]
[ "dataframe", "numpy", "pandas", "python" ]
stackoverflow_0074254505_dataframe_numpy_pandas_python.txt
Q: n*n array which has 2 times every random values To randomly generate a n*n array of assorted characters such that there are exactly two of each character in PYTHON import random import numpy as np from string import punctuation set(punctuation) S = 5 char = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n',...
n*n array which has 2 times every random values
To randomly generate a n*n array of assorted characters such that there are exactly two of each character in PYTHON import random import numpy as np from string import punctuation set(punctuation) S = 5 char = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',\ ...
[ "You can create a list of every element that can still be used, like this:\ndef create_array(n):\n available = char + Digits + symbols\n print(random.choices(available))\n x = np.empty((n, n), dtype=object)\n if(n<=100):\n for i in range(n): \n for j in range(n): \n k = ...
[ 0 ]
[]
[]
[ "arrays", "matrix", "multidimensional_array", "python", "random" ]
stackoverflow_0074254373_arrays_matrix_multidimensional_array_python_random.txt
Q: How to install pipenv on Windows? I need to install pipenv on Windows and I use this tutorial. However I get an error. I use Python 3.9.13 and pip 22.3. I installed pipenv with this command pip install pipenv, then I have to do this: but I didn`t get it. So I passed it and entered this command pipenv -h. Finaly ...
How to install pipenv on Windows?
I need to install pipenv on Windows and I use this tutorial. However I get an error. I use Python 3.9.13 and pip 22.3. I installed pipenv with this command pip install pipenv, then I have to do this: but I didn`t get it. So I passed it and entered this command pipenv -h. Finaly I got this error: Could you help me pl...
[ "You must add the Scripts directory to PATH environment variable as in the example below:\n\n" ]
[ 0 ]
[]
[]
[ "pipenv", "pipenv_install", "python" ]
stackoverflow_0074254642_pipenv_pipenv_install_python.txt
Q: Could not find a version that satisfies the requirement tensorflow-gpu<1.11.0,>=1.3.0 when I try to use mask-rcnn to train my datasets, and then I set environment first, and the tensorflow-gpu's version can't satisfy my need, and it showed like that ,how to fix it, thanks. I want to know how to find a satisfied v...
Could not find a version that satisfies the requirement tensorflow-gpu<1.11.0,>=1.3.0
when I try to use mask-rcnn to train my datasets, and then I set environment first, and the tensorflow-gpu's version can't satisfy my need, and it showed like that ,how to fix it, thanks. I want to know how to find a satisfied version for training.
[ "Try to install tensor flow-gpu specifying a version with pip or condo\n" ]
[ 0 ]
[]
[]
[ "mask_rcnn", "python", "tensorflow" ]
stackoverflow_0074254663_mask_rcnn_python_tensorflow.txt
Q: Using 'yield' (i.e. generator) and 'return' together in a Python function I tried to create a simple Python function where the result is generator or normal output depending on a condition. But the function did not work. it seems the presence of the keyword 'yield' in the function leads the function to return a ge...
Using 'yield' (i.e. generator) and 'return' together in a Python function
I tried to create a simple Python function where the result is generator or normal output depending on a condition. But the function did not work. it seems the presence of the keyword 'yield' in the function leads the function to return a generator in all cases. Below is a simple function that demonstrate what I tried ...
[ "You are right in your assumption, having 'yield' anywhere in your method makes a generator, even if it's under an 'if'.\nNot that there are many reasons to do it, but if you want to achieve what you asked you can do it like this\ndef square_gen(numbers):\n if len(numbers) > 3:\n\n def gen():\n ...
[ 4 ]
[]
[]
[ "generator", "loops", "python" ]
stackoverflow_0074254709_generator_loops_python.txt
Q: Automatically update Jira ticket / create new Jira ticket based on Excel file - using python script I would like to update/create everything in Excel file, but want to update/create Jira tickets automatically, using Python. 1.) Use the information from excel file and create tickets automatically in JIRA. 2.) Updat...
Automatically update Jira ticket / create new Jira ticket based on Excel file - using python script
I would like to update/create everything in Excel file, but want to update/create Jira tickets automatically, using Python. 1.) Use the information from excel file and create tickets automatically in JIRA. 2.) Update an existing Jira ticket automatically with changes in the Excel file. Could you maybe give me some help...
[ "Welcome to Stack Overflow\nMaintaining Jira issues and creating them through Excel is a great idea, however there are many moving parts to it, and it won't be easy to be developed as python script as it is more like a small project.\nIf you are looking for quick and easy solution check this out:\nExcel 365 Connect...
[ 0, 0 ]
[]
[]
[ "excel", "jira", "python", "python_jira" ]
stackoverflow_0074053884_excel_jira_python_python_jira.txt
Q: Loading choices from utils.py results in unexpected error: TypeError: 'CharField' object is not iterable in Django I have a models.py file in Django, and it was working perfectly. I have an extensive model named Media, and since it contains quite some Fields with elaborate choices in nested tuples, I decided to mo...
Loading choices from utils.py results in unexpected error: TypeError: 'CharField' object is not iterable in Django
I have a models.py file in Django, and it was working perfectly. I have an extensive model named Media, and since it contains quite some Fields with elaborate choices in nested tuples, I decided to move these nested tuples to an utils.py file located in the same app. I found that it is working for all columns in my Med...
[ "I think the over-engineer is the problem, and probablly the choices can't be dinamically defined, or at least is not kosher\nwhy not use this:\nutils.py:\n UMBRELLA = (\n (\"DH\", \"DH\"),\n (\"SE\", \"SE\"),\n (\"PA\", \"PA\"),\n (\"PF\", \"PF\"))\n\nmodels.py:\nfrom database.utils import *\n\nclas...
[ 2 ]
[]
[]
[ "django", "django_forms", "django_migrations", "django_models", "python" ]
stackoverflow_0074254527_django_django_forms_django_migrations_django_models_python.txt
Q: Collecting Sheet Names from a Folder of Excel Workbooks I have a folder of numerous .xslx files on my desktop and I am trying to iterate through them one by one to collect the respective sheet names automatically from each workbook. import openpyxl import glob # specifying the path to csv files path = "C:/Users/...
Collecting Sheet Names from a Folder of Excel Workbooks
I have a folder of numerous .xslx files on my desktop and I am trying to iterate through them one by one to collect the respective sheet names automatically from each workbook. import openpyxl import glob # specifying the path to csv files path = "C:/Users/X/Desktop/Test" # csv files in the path files = glob.glo...
[ "Try:\nsheet_names = []\n\nfor x in files:\n sheet_names.append(openpyxl.load_workbook(x).sheetnames)\n\nOr, using a list comprehension:\nsheet_names = [openpyxl.load_workbook(x).sheetnames for x in files]\n\n\nUpdate:\nIf you encounter an error message like:\nBadZipFile: File is not a zip file\n\nThis probably ...
[ 2, 0 ]
[]
[]
[ "glob", "openpyxl", "pandas", "python" ]
stackoverflow_0074254615_glob_openpyxl_pandas_python.txt
Q: KeyError: "[''] not in index" - pandas boxplot Here is what my pandas.dataframe looks like: Own contribution assessment 1 Own contribution assessment 2 Own contribution assessment 3 0 40.0 40.0 40 1 50.0 40.0 40 2 75.0 75.0 75 3 33.0 33.0 33 4 25.0 25.0 25 When I do...
KeyError: "[''] not in index" - pandas boxplot
Here is what my pandas.dataframe looks like: Own contribution assessment 1 Own contribution assessment 2 Own contribution assessment 3 0 40.0 40.0 40 1 50.0 40.0 40 2 75.0 75.0 75 3 33.0 33.0 33 4 25.0 25.0 25 When I do: df.boxplot( column=["Own contribution asse...
[ "Converting the column to float solved it somehow.\n" ]
[ 0 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074254285_pandas_python.txt
Q: Why I can't get the same json results when opening browser and using requests python? I am trying to scrape the web https://jendela360.com/apartemen/jakarta-barat and found the api for supplying the json file https://api.jendela360.com/api/site/apartment-search?price=0&sort=popular&page=1&aptId=&radius=5&latitude=...
Why I can't get the same json results when opening browser and using requests python?
I am trying to scrape the web https://jendela360.com/apartemen/jakarta-barat and found the api for supplying the json file https://api.jendela360.com/api/site/apartment-search?price=0&sort=popular&page=1&aptId=&radius=5&latitude=0&longitude=0&filter_type=area&area=jakarta-barat&rowsPerPage=100 . When I opened the api i...
[ "This should work as expected, no need to pass any extra header specially the accept and accept-encoding, as per your response you need to set headers application/json\nimport requests\n\nlocation='jakarta-barat'\nurl = f\"https://api.jendela360.com/api/site/apartment-search?price=0&sort=popular&page=1&aptId=&radiu...
[ 1 ]
[]
[]
[ "python", "python_requests" ]
stackoverflow_0074254323_python_python_requests.txt
Q: When should we use asyncio.get_running_loop() vs asyncio.get_event_loop()? I have seen running a blocking code using loop = asyncio.get_running_loop() await loop.run_in_executor(None, blockingfunc) And loop = asyncio.get_event_loop() await loop.run_in_executor(None, blockingfunc) When should we use asyncio.get_r...
When should we use asyncio.get_running_loop() vs asyncio.get_event_loop()?
I have seen running a blocking code using loop = asyncio.get_running_loop() await loop.run_in_executor(None, blockingfunc) And loop = asyncio.get_event_loop() await loop.run_in_executor(None, blockingfunc) When should we use asyncio.get_running_loop() vs asyncio.get_event_loop()?
[ "In accordance with the official documentation, both the get_running_loop and get_event_loop are used to actually get an active loop, with the difference that the latter get_event_loop has more complex behaviour, thus get_running_loop can be used widely in the applications, where the existance of the loop is not qu...
[ 5, 1 ]
[]
[]
[ "python", "python_asyncio" ]
stackoverflow_0065206110_python_python_asyncio.txt
Q: Jira-Python - Specify API version? Using Jira-Python, how do you specify the API versioning that the issues= command sends? i.e., https:///rest/api/2/search? vs. /api/latest/search ... A: @Tony, the version is hardcoded into the imported library. If I were looking for the API call I would use a breakpoint in yo...
Jira-Python - Specify API version?
Using Jira-Python, how do you specify the API versioning that the issues= command sends? i.e., https:///rest/api/2/search? vs. /api/latest/search ...
[ "@Tony, the version is hardcoded into the imported library. If I were looking for the API call I would use a breakpoint in your script, debug it and step into the methods to find where the version is defined.\nHope this helps.\n" ]
[ 0 ]
[]
[]
[ "jira_rest_api", "python", "python_jira" ]
stackoverflow_0073979435_jira_rest_api_python_python_jira.txt
Q: Scrapy: skip classless span with css selectors <div class="classA"> <span class="classB">hello</span> <span aria-hidden="true">world</span> <span>I want this text</span> </div> I want to get the text in the 3rd span using CSS selectors. My problem is that I don't know how to skip the second span as it do...
Scrapy: skip classless span with css selectors
<div class="classA"> <span class="classB">hello</span> <span aria-hidden="true">world</span> <span>I want this text</span> </div> I want to get the text in the 3rd span using CSS selectors. My problem is that I don't know how to skip the second span as it doesn't have a class. Maybe we could use the aria-hidd...
[ "If you are always trying to select the 3rd span tag then you can use the nth-child() selector.\nresponse.css('div > span:nth-child(3)').get()\n\n" ]
[ 1 ]
[]
[]
[ "css_selectors", "python", "scrapy" ]
stackoverflow_0074254530_css_selectors_python_scrapy.txt
Q: Visual Studio Code - How to set (missing) Python kernel - Jupyter Notebook Background I am on macOS 12.6.1 I installed pyenv via homebrew I installed 3.10.7 via pyenv pyenv install 3.10.7 I set 3.10.7 to global with pyenv global 3.10.7 I have installed ipykernel with `pip install ipykernel' My .zshrc file contain...
Visual Studio Code - How to set (missing) Python kernel - Jupyter Notebook
Background I am on macOS 12.6.1 I installed pyenv via homebrew I installed 3.10.7 via pyenv pyenv install 3.10.7 I set 3.10.7 to global with pyenv global 3.10.7 I have installed ipykernel with `pip install ipykernel' My .zshrc file contains the following: export PYENV_ROOT="$HOME/.pyenv" command -v pyenv >/dev/null |...
[ "I've managed to get Python 3.10.7 to become available in the kernel option. What I did was:\n\nFile -> Open folder -> Desktop\nMade a new python file, test.py, which contained some python code:\n\na = 4\nb = 2\nc = a + b\nprint(c)\n\n\nRan the python file, made sure that output (c) was printed.\nThen cmd + shift +...
[ 0 ]
[]
[]
[ "jupyter_notebook", "macos", "pyenv", "python", "visual_studio_code" ]
stackoverflow_0074252566_jupyter_notebook_macos_pyenv_python_visual_studio_code.txt
Q: Importing Python libraries with hyphen in the name I create a Python library. It requires a Git repository and a name. I name it my-library and also inside the package folder my-package. How should I: install library my-library after I upload it to PyPI? import the package my-package after I install the library? ...
Importing Python libraries with hyphen in the name
I create a Python library. It requires a Git repository and a name. I name it my-library and also inside the package folder my-package. How should I: install library my-library after I upload it to PyPI? import the package my-package after I install the library?
[ "You can name and install it from PyPi as \"my-package\" but you have to import it as \"my_package\"\n" ]
[ 1 ]
[]
[]
[ "pypi", "python", "python_import", "python_packaging" ]
stackoverflow_0074254704_pypi_python_python_import_python_packaging.txt
Q: Scraping HTML site in h3 tags import requests from bs4 import BeautifulSoup url = 'http://www.columbia.edu/~fdc/sample.html' response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') items = soup.findAll('h3') print(items) I get this conclusion: [<h3 id="contents">CONTENTS</h3>, <h3 id="bas...
Scraping HTML site in h3 tags
import requests from bs4 import BeautifulSoup url = 'http://www.columbia.edu/~fdc/sample.html' response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') items = soup.findAll('h3') print(items) I get this conclusion: [<h3 id="contents">CONTENTS</h3>, <h3 id="basics">1. Creating a Web Page</h3>, <...
[ "If you are looking for a list of the text inside the h3 tags you can iterate over all the h3 tags and only save the text.\nimport requests\nfrom bs4 import BeautifulSoup\n\nurl = 'http://www.columbia.edu/~fdc/sample.html'\nresponse = requests.get(url)\nsoup = BeautifulSoup(response.text, 'html.parser')\nitems = [h...
[ 0 ]
[]
[]
[ "python", "web_scraping" ]
stackoverflow_0074254899_python_web_scraping.txt
Q: a single line python code for getting the second list of file name if any of first list string match I have two lists, I want to get the file name in the second list if any of the first list strings match in the second list. I want to get a file name with the single-line code if the string matches. list_1 = ['KNei...
a single line python code for getting the second list of file name if any of first list string match
I have two lists, I want to get the file name in the second list if any of the first list strings match in the second list. I want to get a file name with the single-line code if the string matches. list_1 = ['KNeighborsClassifier', 'ExtraTreesClassifier', 'LGBMClassifier', ...
[ "One liner to print matched elements:\nprint(*[s for string_name in list_1 for s in list_2 if string_name in s], sep='\\n')\n\nOr store to a list:\nfile_name = [s for string_name in list_1 for s in list_2 if string_name in s]\nprint(file_name)\n\n# ['KNeighborsClassifier.pkl', 'ExtraTreesClassifier.pkl', 'LGBMClass...
[ 0 ]
[]
[]
[ "python" ]
stackoverflow_0074254400_python.txt
Q: How do I add weights for edges, when I specified multiple edges, not just 1 specific edge? Networkx For the following code: import networkx as nx import matplotlib.pyplot as plt G = nx.DiGraph() #Set 1 G.add_edges_from([('A','B'),('A','C'),('C','B')]) #Set 2 G.add_edges_from([('D','A'),('D','B'),('D','C')]) #Set...
How do I add weights for edges, when I specified multiple edges, not just 1 specific edge? Networkx
For the following code: import networkx as nx import matplotlib.pyplot as plt G = nx.DiGraph() #Set 1 G.add_edges_from([('A','B'),('A','C'),('C','B')]) #Set 2 G.add_edges_from([('D','A'),('D','B'),('D','C')]) #Set 3 G.add_edges_from([('E','D'),('E','B'),('E','C')]) pos = nx.spring_layout(G) nx.draw_networkx_nodes(G...
[ "When adding the edges one can specify a dictionary containing arbitrary edge properties:\nfrom networkx import DiGraph\nG = DiGraph()\nG.add_edges_from([('A','B', {'weight': 0.1}),('A','C', {'weight': 0.2})])\nprint(G.edges(data=True))\n# [('A', 'B', {'weight': 0.1}), ('A', 'C', {'weight': 0.2})]\n\nAlternatively,...
[ 2 ]
[]
[]
[ "algorithm", "edges", "graph", "networkx", "python" ]
stackoverflow_0074254406_algorithm_edges_graph_networkx_python.txt
Q: Paramiko SSHClient.connect returns False I am trying to open an SSH connection to the router with Python, after many tries with no outputs whatsoever I figured out that when I print a True/False comparison statement for the SSHClient.connect I always get False, I tried many things but nothing worked out! The Pytho...
Paramiko SSHClient.connect returns False
I am trying to open an SSH connection to the router with Python, after many tries with no outputs whatsoever I figured out that when I print a True/False comparison statement for the SSHClient.connect I always get False, I tried many things but nothing worked out! The Python script I wrote is very common yet the result...
[ "The SSHClient.connect does not return anything. It only raises an exception on error. As your call did not raise any exception, the connection was successful.\n\nNot returning anything in Python means the method \"returns\" None.\nNone != True, so that's why your code prints \"not connected\".\n" ]
[ 1 ]
[]
[]
[ "networking", "paramiko", "python", "ssh" ]
stackoverflow_0074252982_networking_paramiko_python_ssh.txt
Q: How do I make my selenium script return all elements instead of only ONE? new to python and have started with small web scraping projects. And I have now tries to scrape this url. I want to collect the information in the blue and white boxes. More specifically, the price (536,25) and the name of the provider (Chea...
How do I make my selenium script return all elements instead of only ONE?
new to python and have started with small web scraping projects. And I have now tries to scrape this url. I want to collect the information in the blue and white boxes. More specifically, the price (536,25) and the name of the provider (Cheap Energy AB), and I would like to collect the top 3, like in the picture below....
[ "There are several problems with your code.\n\nFirst of all this XPath //*[@id=\"main\"]/div[3]/div[3]/div[2]/ul/li[1]/div[2]/div is matching 1 element only so your lists is actually getting 1 element.\nYou have to improve locators.\nAnd add the delay. Only when elements you want to put in lists are visible you sho...
[ 1 ]
[]
[]
[ "python", "selenium", "selenium_chromedriver", "selenium_webdriver", "web_scraping" ]
stackoverflow_0074254929_python_selenium_selenium_chromedriver_selenium_webdriver_web_scraping.txt
Q: PropertyHolder' object has no attribute in JIRA API I am trying to export all comments in excel from issues of a Jira project using python. I have used following Comments_list.append(issue.fields.comment.comments) for comment in Comments_list: ws.cell(row=comments_row, column=comments_column).value = comment...
PropertyHolder' object has no attribute in JIRA API
I am trying to export all comments in excel from issues of a Jira project using python. I have used following Comments_list.append(issue.fields.comment.comments) for comment in Comments_list: ws.cell(row=comments_row, column=comments_column).value = comment.body comments_row += 1 However, I am getting error ...
[ "I don't think comments are listed like that. Looking at the return from a single story in the screenshot: \nIn strict Json it would be issue[\"fields\"][\"comment\"][\"comments\"][0][\"body\"][\"content\"][0][\"content\"][0][\"text]\nIf you know your data set and can guarantee all comments will be single line text...
[ 0 ]
[]
[]
[ "jira_rest_api", "python", "python_jira" ]
stackoverflow_0073289019_jira_rest_api_python_python_jira.txt
Q: How to make an numpy array of 0 and 1 based on a probability array? I know that using Python's random.choices I can do this: import random array_probabilities = [0.5 for _ in range(4)] print(array_probabilities) # [0.5, 0.5, 0.5, 0.5] a = [random.choices([0, 1], weights=[1 - probability, probability])[0] for pr...
How to make an numpy array of 0 and 1 based on a probability array?
I know that using Python's random.choices I can do this: import random array_probabilities = [0.5 for _ in range(4)] print(array_probabilities) # [0.5, 0.5, 0.5, 0.5] a = [random.choices([0, 1], weights=[1 - probability, probability])[0] for probability in array_probabilities] print(a) # [1, 1, 1, 0] How to make ...
[ "One option:\nout = (np.random.random(size=len(array_probabilities)) > array_probabilities).astype(int)\n\nExample output:\narray([0, 1, 0, 1])\n\n", "Your question got me wondering so I wrote a basic function to compare their timings. And it seems you are right! Timings change but only a little. Here you can see...
[ 1, 1, 0 ]
[]
[]
[ "arrays", "numpy", "numpy_ndarray", "python", "python_3.x" ]
stackoverflow_0074254123_arrays_numpy_numpy_ndarray_python_python_3.x.txt
Q: Python Msql Unread result found I got this error while trying to get variable from a DataBase in MySql 0x000002A MySQL Connection Error! MySql error is provided when version/value we're trying to get from database is not a number output when trying to print value Program is trying to get from database: None I tri...
Python Msql Unread result found
I got this error while trying to get variable from a DataBase in MySql 0x000002A MySQL Connection Error! MySql error is provided when version/value we're trying to get from database is not a number output when trying to print value Program is trying to get from database: None I tried to get variable named: "gameVersio...
[ "My code to connect at MySQL is :\nconnection = mysql.connector.connect(\n host=\"localhost\",\n user=\"root\",\n password=\"root\",\n port=\"8889\",\n database=\"registration\",\n auth_plugin=\"mysql_native_password\"\n)\n\nc = connection.cursor()\n\nMake sure you are connected to Mamp, Xampp, Wa...
[ 0, 0 ]
[]
[]
[ "mysql", "mysql_python", "python" ]
stackoverflow_0074247069_mysql_mysql_python_python.txt
Q: How can i make a python script automatically enter a password? So I am trying to write a script to automatically log into a server. For the server I am using SHH. import os os.system("ssh root@address") So when you enter the command manually you then get asked to enter the password and I don't know how to make t...
How can i make a python script automatically enter a password?
So I am trying to write a script to automatically log into a server. For the server I am using SHH. import os os.system("ssh root@address") So when you enter the command manually you then get asked to enter the password and I don't know how to make the script enter the password. Can someone help me out here? I tried ...
[ "There are multiple ways to do so. I wouldn't hardcode your password into the script for the sake of security but as long as you are sure only you are using the script it should be fine. This sample code is not trying to make it secure. I am just answering your question based on the constrains you gave.\nIf you ins...
[ 1 ]
[]
[]
[ "python" ]
stackoverflow_0074255083_python.txt
Q: Download/Get Data from .ods file on a website (using Python) I have a Website with the url = https://www.statistik.at/statistiken/volkswirtschaft-und-oeffentliche-finanzen/preise-und-preisindizes/verbraucherpreisindex-vpi/hvpi On this website there is a link with url = "https://view.officeapps.live.com/op/view.asp...
Download/Get Data from .ods file on a website (using Python)
I have a Website with the url = https://www.statistik.at/statistiken/volkswirtschaft-und-oeffentliche-finanzen/preise-und-preisindizes/verbraucherpreisindex-vpi/hvpi On this website there is a link with url = "https://view.officeapps.live.com/op/view.aspx?src=https%3A%2F%2Fwww.statistik.at%2Ffileadmin%2Fpages%2F214%2F2...
[ "You need to install odfpy:\npip install odfpy\n\nThen you can use pandas read_excel function, to read this file:\nimport pandas as pd\nimport requests\n\nurl = 'https://www.statistik.at/fileadmin/pages/214/2_Verbraucherpreisindizes_ab_1990.ods'\nfile_name = 'F2_Verbraucherpreisindizes_ab_1990.ods'\nwith open(file_...
[ 0, 0 ]
[]
[]
[ "python", "web_scraping" ]
stackoverflow_0073543792_python_web_scraping.txt
Q: Unhandled color format: '' " while using xlsxwriter pandas I am trying to highlight cells when a certain criteria is met but if not, I don't want to add any color. If I try with space, I get the aforementioned error. I can't use white as the cell linings in excel vanish. Code: def highlight_cells(val): color =...
Unhandled color format: '' " while using xlsxwriter pandas
I am trying to highlight cells when a certain criteria is met but if not, I don't want to add any color. If I try with space, I get the aforementioned error. I can't use white as the cell linings in excel vanish. Code: def highlight_cells(val): color = 'yellow' if val==5.1 else " " return 'background-color: {}'...
[ "I think the problem is it's expecting a color and you're not giving it a valid color. If you return nothing instead, does this work?\ndef highlight_cells(val):\n if val == 5.1: return 'background-color: yellow'\n\n" ]
[ 0 ]
[]
[]
[ "pandas", "pandas_styles", "python", "xlsxwriter" ]
stackoverflow_0074255015_pandas_pandas_styles_python_xlsxwriter.txt
Q: How to separate each group of five stars by a vertical line? I'm a new one at the world of Python programming. I've just, unfortunately, stuck on this, I think, simple exercise. So what I should do is to modify the stars(n) function to print n stars, with each group of five stars separated by a vertical line. I ha...
How to separate each group of five stars by a vertical line?
I'm a new one at the world of Python programming. I've just, unfortunately, stuck on this, I think, simple exercise. So what I should do is to modify the stars(n) function to print n stars, with each group of five stars separated by a vertical line. I have code like this, but I really don't know what to do with it. def...
[ "Trickier than expected...\ndef stars(n):\n solution = ''\n for i in range(n):\n if i % 5 == 0 and i != 0:\n solution += '|'\n solution += '*'\n\n if n % 5 == 0:\n solution += '|'\n\n return solution\n\nprint(stars(7))\nprint(stars(15))\n\n", "The problem is in the cond...
[ 1, 1, 0 ]
[]
[]
[ "design_patterns", "function", "python", "python_3.x" ]
stackoverflow_0074254618_design_patterns_function_python_python_3.x.txt
Q: Python Function as Macro's? I'm in the process of converting some code from SAS to Python and was needing some tips on how to build a function that will effectively act as a macro would in SAS and run instances of the same code for a set of variables (dataframes) I pass into the function as an argument/parameters....
Python Function as Macro's?
I'm in the process of converting some code from SAS to Python and was needing some tips on how to build a function that will effectively act as a macro would in SAS and run instances of the same code for a set of variables (dataframes) I pass into the function as an argument/parameters. In the example I have a datafram...
[ "Yes, that's a very good use of Python functions. However, it looks like a good candidate for .groupby() and .agg(), which would look something like this:\ncountry_extract.groupby([\"country_code\",\"country_sub_type\"]).agg(sumGDP=('GDP','sum'))\n\nUpdate: You could also save yourself some typing by doing somethin...
[ 1 ]
[]
[]
[ "dataframe", "function", "macros", "pandas", "python" ]
stackoverflow_0074254957_dataframe_function_macros_pandas_python.txt
Q: Why isn't there a bucket sort library(or is there?) I've been studying algorithm, and just came across this bucket sort. Although it can only be used for few cases, it just looks too efficient to be not implemented in standard library, since it can sort a list in O(n) time. so my question is, why isn't there a giv...
Why isn't there a bucket sort library(or is there?)
I've been studying algorithm, and just came across this bucket sort. Although it can only be used for few cases, it just looks too efficient to be not implemented in standard library, since it can sort a list in O(n) time. so my question is, why isn't there a given library that supports bucket sort, or any other counti...
[ "Java has a static method Arrays.sort that could in principle be implemented as a radix sort for the overloads that accept integer types (https://docs.oracle.com/javase/10/docs/api/java/util/Arrays.html#sort(int[])). They chose to implement with quicksort. There's no justification given, but I imagine 1. Radix sort...
[ 1, 1, 0 ]
[]
[]
[ "algorithm", "c++", "java", "python", "sorting" ]
stackoverflow_0049958256_algorithm_c++_java_python_sorting.txt
Q: Hi, New to coding and cant seem to find the solution for this error (Python) text = ["this","is","text"] print(f"hello and {text, end=","}") Input In [58] print(f"hello and {text, end=","}") ^ SyntaxError: f-string: expecting '}' I am trying to remove brackets and commas whi...
Hi, New to coding and cant seem to find the solution for this error (Python)
text = ["this","is","text"] print(f"hello and {text, end=","}") Input In [58] print(f"hello and {text, end=","}") ^ SyntaxError: f-string: expecting '}' I am trying to remove brackets and commas while using an f string ........................
[ "It appears you are trying to print the contents of the list after the hardcoded string. So your code is first printing \"hello and\" and then the string representation of the list 'text'. In order to print the elements of the list using an f string you can do:\ntext = ['this','is','text']\nprint(f\"hello and {' '....
[ 0 ]
[]
[]
[ "new_operator", "python", "syntax" ]
stackoverflow_0074255185_new_operator_python_syntax.txt
Q: Installing playwright in Docker image fails I've built a small fastapi app that scrapes some data from various sites and returnes it. whan I'm running it locally it works well, but when I try to run it as a Docker image the build fails with the error: #8 3.356 ERROR: Could not find a version that satisfies the req...
Installing playwright in Docker image fails
I've built a small fastapi app that scrapes some data from various sites and returnes it. whan I'm running it locally it works well, but when I try to run it as a Docker image the build fails with the error: #8 3.356 ERROR: Could not find a version that satisfies the requirement playwright==1.27.1 (from versions: none)...
[ "The issue is the docker image you have selected (alpine) architecture tags dont match any that playwright supports.\npython:3.9:alpine\n/code/src # pip debug --verbose | grep \"py3-\"\nWARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since th...
[ 1 ]
[]
[]
[ "docker", "playwright", "playwright_python", "python" ]
stackoverflow_0074254853_docker_playwright_playwright_python_python.txt
Q: Tkinter scrollbar for frame My objective is to add a vertical scroll bar to a frame which has several labels in it. The scroll bar should automatically enabled as soon as the labels inside the frame exceed the height of the frame. After searching through, I found this useful post. Based on that post I understand t...
Tkinter scrollbar for frame
My objective is to add a vertical scroll bar to a frame which has several labels in it. The scroll bar should automatically enabled as soon as the labels inside the frame exceed the height of the frame. After searching through, I found this useful post. Based on that post I understand that in order to achieve what i wa...
[ "Here's example code adapted from the VerticalScrolledFrame page on the now defunct Tkinter Wiki that's been modified to run on Python 2.7 and 3+.\ntry: # Python 2\n import tkinter as tk\n import tkinter.ttk as ttk\n from tkinter.constants import *\nexcept ImportError: # Python 2\n import Tkinter as t...
[ 56, 36, 18, 2, 2, 0 ]
[]
[]
[ "frame", "python", "scrollbar", "tkinter" ]
stackoverflow_0016188420_frame_python_scrollbar_tkinter.txt
Q: How can I use a seed inside a loop to get the same random samples everytime the code is ran? I want to generate data using random numbers and then generate random samples with replacement using the generated data. The problem is that using random.seed(10) only fixes the initial random numbers for the generated dat...
How can I use a seed inside a loop to get the same random samples everytime the code is ran?
I want to generate data using random numbers and then generate random samples with replacement using the generated data. The problem is that using random.seed(10) only fixes the initial random numbers for the generated data but it does not fix the random samples generated inside the loop, everytime I run the code I get...
[ "your random.choices(data, k=215) is from python builtin random library which has a different seed than the one inside numpy.random, so seeding numpy isn't enough.\nthe correct solution here is to use numpy np.random.choice here as you are already using numpy.\nimport numpy as np\n\nnp.random.seed(10)\n\ndata = np....
[ 3, 2 ]
[]
[]
[ "loops", "numpy", "python", "random", "seed" ]
stackoverflow_0074255173_loops_numpy_python_random_seed.txt
Q: Python turtle.Screen() not working properly on new Mac. Google has failed me I recently got a new computer (Mac 14" Monterey OS) and reinstalled Python, PyCharm, etc. Everything seems to work okay except when running turtle Screen(). The code finishes with exit code 0 (no errors) but when the launcher pops up its ...
Python turtle.Screen() not working properly on new Mac. Google has failed me
I recently got a new computer (Mac 14" Monterey OS) and reinstalled Python, PyCharm, etc. Everything seems to work okay except when running turtle Screen(). The code finishes with exit code 0 (no errors) but when the launcher pops up its just a tiny black screen that flickers. Doesn't even display the title correctly a...
[ "Check your python interpreter version.\nI have the same issue when it uses python3.8, after upgrading to 3.9. It works perfectly.\n\n", "You need to install Python yourself instead of relying on the Python provided by macOS. I downloaded latest macOS 64-bit universal2 installer from https://www.python.org/downlo...
[ 0, 0 ]
[]
[]
[ "python", "turtle_graphics" ]
stackoverflow_0071180824_python_turtle_graphics.txt
Q: Using numpy.delete() or any other function to delete from a list of lists/arrays I have the following list, let's call it R: [(array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), array([100, 101, 102])), (array([[10, 11, 12], [13, 14, 15], [16, 17, 18]]), array([103, 104, 105]))] I ...
Using numpy.delete() or any other function to delete from a list of lists/arrays
I have the following list, let's call it R: [(array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), array([100, 101, 102])), (array([[10, 11, 12], [13, 14, 15], [16, 17, 18]]), array([103, 104, 105]))] I want to be able to delete columns of R in a for loop, based on an index i. For example...
[ "You can use np.delete with col==2 and axis=-1.\n# if your 'list' be like below as you say in the question :\nprint(lst)\n# [\n# array([[1, 2, 3],\n# [4, 5, 6],\n# [7, 8, 9]]), \n# array([100, 101, 102]), \n# array([[10, 11, 12],\n# [13, 14, 15],\n# [16, 17, 1...
[ 2 ]
[]
[]
[ "arrays", "list", "multidimensional_array", "numpy", "python" ]
stackoverflow_0074255300_arrays_list_multidimensional_array_numpy_python.txt
Q: AttributeError: module 'email.message' has no attribute 'lower' I am getting this error AttributeError: module 'email.message' has no attribute 'lower' on my browser after performing action. There is no attribute lower() in my code. Please help me with this. Thank You. I have following imports in my code pandas, m...
AttributeError: module 'email.message' has no attribute 'lower'
I am getting this error AttributeError: module 'email.message' has no attribute 'lower' on my browser after performing action. There is no attribute lower() in my code. Please help me with this. Thank You. I have following imports in my code pandas, matplotlib, email.message and flask df = pd.read_csv('spam.csv',encodi...
[ "It seems you're passing an email object to CountVectorizer() which first lowercases the text (see documentation) before tokenizing it.\nTo fix your error, you should pass the text/message and not the email object\n" ]
[ 1 ]
[]
[]
[ "flask", "python" ]
stackoverflow_0074252561_flask_python.txt
Q: Someone help me in this error TypeError at /contact 'method' object is not subscriptable Views.py # Create your views here. def home(request): return render(request, 'home.html') def about(request): return render(request, 'about.html') def project(request): return render(request, 'project.html') def...
Someone help me in this error TypeError at /contact 'method' object is not subscriptable
Views.py # Create your views here. def home(request): return render(request, 'home.html') def about(request): return render(request, 'about.html') def project(request): return render(request, 'project.html') def contact(request): if request.method=='POST': name=request.POST.get['name'] email...
[ "It should be get() not get[] and also it's a good practice to return HttpResponseRedirect after dealing with POST data, the tip is not specific to Django, it's a good web practice in general, so the view should be:\ndef contact(request):\n if request.method=='POST':\n name=request.POST.get('name')\n ...
[ 1 ]
[]
[]
[ "django", "django_forms", "django_request", "django_views", "python" ]
stackoverflow_0074255338_django_django_forms_django_request_django_views_python.txt
Q: How can i stop larger file uploads failing in my Flask app I am trying to upload videos to my Flask app but I am getting errors every time i try to upload larger files When making this request curl --location --request POST 'http://192.168.1.217:5000/api/fileservice/0.1/files/upload_file' \ --form 'mime_type="vide...
How can i stop larger file uploads failing in my Flask app
I am trying to upload videos to my Flask app but I am getting errors every time i try to upload larger files When making this request curl --location --request POST 'http://192.168.1.217:5000/api/fileservice/0.1/files/upload_file' \ --form 'mime_type="video/mp4"' \ --form 'uuid="12345"' \ --form 'file=@"/home/sean/Vide...
[ "I wasn't to familiar with 308 redirects before, but this seemed to be the actual cause of the issue.\nThe original reuqest was made to http://192.168.1.217:5000/api/fileservice/0.1/files/upload_file\nIt resulted in a 308 with a Location header set to http://192.168.1.217:5000/api/fileservice/0.1/files/upload_file/...
[ 0 ]
[]
[]
[ "epipe", "flask", "python", "video" ]
stackoverflow_0074253487_epipe_flask_python_video.txt
Q: Connecting to jira cloud using python I am trying to connect jira cloud using REST API. This is my Python code for it: pip install jira from jira import JIRA jiraOptions = {'server': "https:url"} user = 'emailid' apikey = 'api token' server = 'https:url' options = { 'server': server } After this when I exe...
Connecting to jira cloud using python
I am trying to connect jira cloud using REST API. This is my Python code for it: pip install jira from jira import JIRA jiraOptions = {'server': "https:url"} user = 'emailid' apikey = 'api token' server = 'https:url' options = { 'server': server } After this when I execute this line I get a connection error jir...
[ "Hey @Bobby I ran into some similar problems. I created this repo to use straight Python and the API to get most things done - https://github.com/dren79/JiraScripting_public\nA lot of the basic functionality is in the helpers.py file, let me know if it helps.\n" ]
[ 0 ]
[]
[]
[ "jira", "jira_rest_api", "python", "python_jira" ]
stackoverflow_0073187270_jira_jira_rest_api_python_python_jira.txt
Q: How can I make a welcome command in discord.py? The welcome message never sends and I don't get any errors, please help @client.event async def on_member_join(member): guild = member.guild channel = guild.get_channel(912778268803993685) embed=discord.Embed(title="Welcome {member.mention}!",description=f"{me...
How can I make a welcome command in discord.py?
The welcome message never sends and I don't get any errors, please help @client.event async def on_member_join(member): guild = member.guild channel = guild.get_channel(912778268803993685) embed=discord.Embed(title="Welcome {member.mention}!",description=f"{member.mention} Has joined us. Go to #info for more inf...
[ "You should use\nchannel = client.get_channel()\n\n", "Try this:\n@bot.event\n\nasync def on_member_join (member):\n channel = bot.get_channel ( 902539930566271027 )\n\n role = discord.utils.get (member.guild.roles, id=891029501520269373)\n print (f'{member.name} join the servers')\n await member.add_...
[ 1, 0 ]
[]
[]
[ "bots", "discord.py", "python" ]
stackoverflow_0070092164_bots_discord.py_python.txt
Q: How to fit a curved surface to 3d vectors with their normals? I have 3d position vectors as follows: A=np.array([-773.58, 645.41, -101.986]) B=np.array([841.01, -205.0, 400.9]) C=np.array([1000.91, 805.45, 745.10]) and their corresponding normal vectors NORM_A = np.array([0.89, -0.031, 0.44]) NORM_B = np.array([...
How to fit a curved surface to 3d vectors with their normals?
I have 3d position vectors as follows: A=np.array([-773.58, 645.41, -101.986]) B=np.array([841.01, -205.0, 400.9]) C=np.array([1000.91, 805.45, 745.10]) and their corresponding normal vectors NORM_A = np.array([0.89, -0.031, 0.44]) NORM_B = np.array([0.87, -0.14, -0.46]) NORM_C = np.array([0.83, -0.23, -0.48]) The...
[ "You need to do some soul searching and choose the geometry of an ideal surface to which you want to attempt a fit. You claim to be able to accept a paraboloid.\nThe equation of a generalised elliptic paraboloid in (y, z) is\nx = ((y - a)/b)² + ((z - c)/d)² - e\n\nor\nf(x, y, z) = e = -x + ((y - a)/b)² + ((z - c)/d...
[ 0 ]
[]
[]
[ "matplotlib", "numpy", "python" ]
stackoverflow_0074232614_matplotlib_numpy_python.txt
Q: Creating unique dataframes based on one with adding a value to the column I have a dataset with statistics by region. I would like to build several other city datasets based on this dataset. At the same time, when creating in each such set, I would like to add a column with the name of the city. That is, from one ...
Creating unique dataframes based on one with adding a value to the column
I have a dataset with statistics by region. I would like to build several other city datasets based on this dataset. At the same time, when creating in each such set, I would like to add a column with the name of the city. That is, from one data set, I would like to receive three. I'll give you an example. Initial data...
[ "Another possible solution:\ndfs = [] \nfor city in city_list:\n dfs.append(df.assign(city = city))\n\ncities = dict(zip(city_list, dfs))\ncities['Los Angeles']\n\nOutput:\n date name_region city\n0 2022-01-01 California Los Angeles\n1 2022-01-02 California Los Angeles\n2 2022-01-02 Calif...
[ 3, 2 ]
[]
[]
[ "dataframe", "pandas", "python" ]
stackoverflow_0074255351_dataframe_pandas_python.txt
Q: Multiprocess on my Raspberry pi won't stop I have a multiprocess script which runs as expected on my normal computer, but when I run the same script on my raspberry pi 3 A model via thonny, stopping the script doesn't seem to stop the process. if __name__ == '__main__': p = Process(target=video_player, args = ...
Multiprocess on my Raspberry pi won't stop
I have a multiprocess script which runs as expected on my normal computer, but when I run the same script on my raspberry pi 3 A model via thonny, stopping the script doesn't seem to stop the process. if __name__ == '__main__': p = Process(target=video_player, args = ([resizer(img,70)])) p.start() the video_...
[ "usually making the child process a daemon process causes it to exit when the main process exits therefore solving the issue.\nif __name__ == '__main__':\n p = Process(target=video_player, args=(resizer(img, 70),), daemon=True)\n\n p.start()\n p.join() # wait for ctrl-C event\n\n" ]
[ 0 ]
[]
[]
[ "multiprocessing", "opencv", "python", "raspberry_pi", "video_processing" ]
stackoverflow_0074254381_multiprocessing_opencv_python_raspberry_pi_video_processing.txt
Q: How to mask indices smaller than or bigger than certain index? Is there a way to mask, using np.ma module, all indices in a specific array smaller or bigger than a given number? For example, if I have an array of 365 elements and I want to mask all of the ones between 170 and 200 and only take into account[0:170] ...
How to mask indices smaller than or bigger than certain index?
Is there a way to mask, using np.ma module, all indices in a specific array smaller or bigger than a given number? For example, if I have an array of 365 elements and I want to mask all of the ones between 170 and 200 and only take into account[0:170] and [201:], can I do it? Tried researching the answer but nothing I ...
[ "You could make a mask along the lines of\nmymask = np.array([0 if x < 170 or x >=200 else 1 for x in range(365)])\n\nand then use\nx = np.ma.masked_array(myarray, mask = mymask)\n\n" ]
[ 0 ]
[]
[]
[ "indexing", "indices", "numpy", "python" ]
stackoverflow_0074255260_indexing_indices_numpy_python.txt
Q: how to convert python functions to classes that do the same thing I am trying to create python classes from a program that I wrote in functions only. So the code is working fine with functions but giving an error/errors when I convert the code to python classes. Functions: def eachList(index): Series=df_ideal....
how to convert python functions to classes that do the same thing
I am trying to create python classes from a program that I wrote in functions only. So the code is working fine with functions but giving an error/errors when I convert the code to python classes. Functions: def eachList(index): Series=df_ideal.iteritems() bigList = [] for (columnName,item) in Series: ...
[ "The error you're hitting (I'm guessing) is that you're calling Task1.residual as if it's a class method, when it's not:\nresult = map(lambda x:x*x,Task1.residual(listing,Task1.eachList(i)))\n\nFor this to work you should be calling self.residual.\nHowever, I think it would be better to just have a simple set of fu...
[ 0 ]
[]
[]
[ "class", "python" ]
stackoverflow_0074255299_class_python.txt
Q: Python pandas 'reverse' split in a dataframe i have a dataframe with a column called details that have this data : 130 m² - 3 Pièces - 2 Chambres - 2 Salles de bains - Bon état - 20-30 ans - when i want to get the first data 130 i did this : df['superficie'] = df['details'].str.split('m²').str[0] its gives me 130...
Python pandas 'reverse' split in a dataframe
i have a dataframe with a column called details that have this data : 130 m² - 3 Pièces - 2 Chambres - 2 Salles de bains - Bon état - 20-30 ans - when i want to get the first data 130 i did this : df['superficie'] = df['details'].str.split('m²').str[0] its gives me 130 in a new column that called "superficie" for the ...
[ "I suggest you to use regular expressions in pandas for this kind of operations:\nimport pandas as pd\n\ndf = pd.DataFrame()\ndf['details'] = [\"130 m² - 3 Pièces - 2 Chambres - 2 Salles de bains - Bon état - 20-30 ans -\"]\n\ndf['nb_chbr'] = df['details'].str.split(\" - \").str[2].str.findall(r'\\d+').str[0].astyp...
[ 1 ]
[]
[]
[ "dataframe", "jupyter_notebook", "pandas", "python" ]
stackoverflow_0074255332_dataframe_jupyter_notebook_pandas_python.txt
Q: How to remove double quotes in csv with Beautifulsoup enter image description here Hi there, I have been dealing with something, but it didn't work whatever i tryed. In my csv file values are separated with double quotes. That's why, happened some problem. Csv file is not completely true. I have been trying to scr...
How to remove double quotes in csv with Beautifulsoup
enter image description here Hi there, I have been dealing with something, but it didn't work whatever i tryed. In my csv file values are separated with double quotes. That's why, happened some problem. Csv file is not completely true. I have been trying to scrape addresses in this page: https://www.worldometers.info/c...
[ "To solve the first issue, you must import QUOTE_NONE from csv:\nfrom csv import QUOTE_NONE\n\nThen, when you create csv_writer, you must specify the following additional arguments:\ncsv_writer = writer(csv_file, escapechar=' ', quoting=csv.QUOTE_NONE)\n\nRegarding the second issue, characters in strings can be rep...
[ 1 ]
[]
[]
[ "beautifulsoup", "python" ]
stackoverflow_0074255469_beautifulsoup_python.txt
Q: Change status of issue in Jira using Rest call from Python I am trying to update the status of issue from 'Request Info' state to 'Submitted' via rest API in python. after digging a lot in the documentation , I ran a Rest call to get the allowed status for the issue ID and i can see that the status 'Submitted' is ...
Change status of issue in Jira using Rest call from Python
I am trying to update the status of issue from 'Request Info' state to 'Submitted' via rest API in python. after digging a lot in the documentation , I ran a Rest call to get the allowed status for the issue ID and i can see that the status 'Submitted' is allows: "expand": "transitions", "transitions": [{ "id": "381", ...
[ "I do most of this work in straight Python using the API, I have a lot of what you need in this repo - https://github.com/dren79/JiraScripting_public\nI'll add a transition function in the helpers file now.\nLet me know if it helps!\n" ]
[ 0 ]
[]
[]
[ "jira", "jira_rest_api", "python" ]
stackoverflow_0074254503_jira_jira_rest_api_python.txt
Q: Quickest way to check if minion passed by pillar exists I have an orchestration state that takes minion's name via pillar. What is the quickest way to determine: pillar value passed represents a valid minion/s get minion's fqdn So far, I can only think of test.ping, but if the minion IS valid but offline, the re...
Quickest way to check if minion passed by pillar exists
I have an orchestration state that takes minion's name via pillar. What is the quickest way to determine: pillar value passed represents a valid minion/s get minion's fqdn So far, I can only think of test.ping, but if the minion IS valid but offline, the return takes a while. There must be a better, quicker way. I us...
[ "The manage runners are probably best for this.\nTo test if a minion id is known (and whether it's up), use manage.status with tgt=minion\n" ]
[ 1 ]
[]
[]
[ "python", "salt_stack" ]
stackoverflow_0074243789_python_salt_stack.txt
Q: Pandas how to group by a column and minutes ranges excluding date I have to elaborate simple statistics grouping a dataframe by one column, for instance day_of_the_week, and minutes ranges, for instance 15 minutess, without keeping the dates. In other words, I need statistics on what is happening in each interval ...
Pandas how to group by a column and minutes ranges excluding date
I have to elaborate simple statistics grouping a dataframe by one column, for instance day_of_the_week, and minutes ranges, for instance 15 minutess, without keeping the dates. In other words, I need statistics on what is happening in each interval of 15 minutes on all sundays, mondays, etc. not split by date. The star...
[ "With the following toy dataframe:\nimport random\nimport pandas as pd\n\nlist_of_dates = pd.date_range(start=\"2021-1-1\", end=\"2021-12-31\", freq=\"T\")\ndf = pd.DataFrame(\n {\n \"datetime\": list_of_dates,\n \"low\": [random.randint(0, 4_999) for _ in range(len(list_of_dates))],\n \"hig...
[ 1 ]
[]
[]
[ "dataframe", "group_by", "pandas", "python" ]
stackoverflow_0074180011_dataframe_group_by_pandas_python.txt
Q: How can I make one print statement for all of the different scenarios together of a restaurant tip bill generator? (Custom amount, percent) My instructions are: You are going to write a tip-calculating program that does the following: Asks the user to enter the subtotal of a restaurant bill Asks the user if they ...
How can I make one print statement for all of the different scenarios together of a restaurant tip bill generator? (Custom amount, percent)
My instructions are: You are going to write a tip-calculating program that does the following: Asks the user to enter the subtotal of a restaurant bill Asks the user if they wish to enter a tip and if they do, let them choose to enter the tip by a specific amount, or by percentage of the subtotal. Display the receipt:...
[ "Use function:\ndef my_print():\n print(\"\\nSubtotal:\", (round(subtotal,2)))\n print(\"Tax Owed:\", (round(tax,2)))\n print(\"Tip:\", (round(tip_2,2)))\n print(\"Final total:\", (round(finaltotal_2,2)))\n\nAnd call this function from your code.\nAlso you can use one “print” and use multi lines in it.\...
[ 0, 0 ]
[]
[]
[ "if_statement", "python" ]
stackoverflow_0074255365_if_statement_python.txt
Q: String Formatting Dollar Sign In Python So I'm trying to get the dollar sign to appear directly to the left of the digits under the column 'Cost'. I'm having trouble figuring this out and any help is appreciated. # Question 5 print("\nQuestion 5.") # Get amount of each type of ticket to be purchased adultTicke...
String Formatting Dollar Sign In Python
So I'm trying to get the dollar sign to appear directly to the left of the digits under the column 'Cost'. I'm having trouble figuring this out and any help is appreciated. # Question 5 print("\nQuestion 5.") # Get amount of each type of ticket to be purchased adultTickets = input("\nHow many adult tickets you want...
[ "If I understand correctly, you want to format a floating point number into a string, and have a dollar sign appear in the output in between the number and the padding that you use to space it out in the string. For example, you want to be able to create these two strings with the same formatting code (just differe...
[ 7, 0 ]
[]
[]
[ "python", "string_formatting" ]
stackoverflow_0060610101_python_string_formatting.txt
Q: What is the fastest way to read in an image to an array of tuples? I am trying to assign provinces to an area for use in a game mod. I have two separate maps for area and provinces. provinces file, area file. Currently I am reading in an image in Python and storing it in an array using PIL like this: import PIL l...
What is the fastest way to read in an image to an array of tuples?
I am trying to assign provinces to an area for use in a game mod. I have two separate maps for area and provinces. provinces file, area file. Currently I am reading in an image in Python and storing it in an array using PIL like this: import PIL land_prov_pic = Image.open(INPUT_FILES_DIR + land_prov_str) land_prov_arr...
[ "It is best to convert the [R,G,B] array to tuple when you need it to be a tuple, rather than converting the whole image to this form. An array of tuples takes up a lot more memory, and will be a lot slower to process, than a numeric array.\n\nThe answer by isCzech shows how to create a NumPy view over a 3D array t...
[ 2, 0 ]
[]
[]
[ "numpy", "opencv", "python", "python_imaging_library" ]
stackoverflow_0060793703_numpy_opencv_python_python_imaging_library.txt
Q: How to use Huggingface Trainer streaming Datasets without wrapping it with torchdata's IterableWrapper? Given a datasets.iterable_dataset.IterableDataset with stream=True, e.g. train_data = load_dataset("csv", data_files="../input/tatoeba/tatoeba-sentpairs.tsv", streaming=True, delimiter="\t", s...
How to use Huggingface Trainer streaming Datasets without wrapping it with torchdata's IterableWrapper?
Given a datasets.iterable_dataset.IterableDataset with stream=True, e.g. train_data = load_dataset("csv", data_files="../input/tatoeba/tatoeba-sentpairs.tsv", streaming=True, delimiter="\t", split="train") and trying to use it in a Trainer object, e.g. # instantiate trainer trainer = Seq2SeqTrainer(...
[ "Found the answer from https://discuss.huggingface.co/t/using-iterabledataset-with-trainer-iterabledataset-has-no-len/15790\nBy adding the with format to the iterable dataset, like this:\ntrain_data.with_format(\"torch\")\n\nThe trainer should work without throwing the len() error.\n# instantiate trainer\ntrainer =...
[ 0 ]
[]
[]
[ "huggingface_datasets", "huggingface_transformers", "iterable", "python", "pytorch" ]
stackoverflow_0074255617_huggingface_datasets_huggingface_transformers_iterable_python_pytorch.txt
Q: CSV error AttributeError: 'int' object has no attribute 'keys' I have this list of dict counters that I need to write in a csv, but I cannot figure out the problem. t = Counter({'dog': 3, 'cat': 5}) with open('test.csv', 'w',encoding='utf8', newline="") as output_file: fieldnames = ["name", "count"] dict_...
CSV error AttributeError: 'int' object has no attribute 'keys'
I have this list of dict counters that I need to write in a csv, but I cannot figure out the problem. t = Counter({'dog': 3, 'cat': 5}) with open('test.csv', 'w',encoding='utf8', newline="") as output_file: fieldnames = ["name", "count"] dict_writer = csv.DictWriter(output_file, fieldnames=fieldnames) dict...
[ "DictWriter takes a sequence of mappings each of which has to have the same keys as fieldnames -- so you need [{\"name\": \"dog\", \"count\": 3}, ...]\nTo fix t:\nrows = [{\"name\": name, \"count\": count} for name, count in t.items()]\n\nAnd then pass rows to DictWriter.writerows(), or generate the correct data st...
[ 0 ]
[]
[]
[ "csv", "python" ]
stackoverflow_0074255657_csv_python.txt
Q: Getting TypeError with pywinauto when calling application.start for Store Apps I tried to automate an application installed from the Microsoft Store, tried different applications, but I allways got the same error. I used this code: import subprocess from pywinauto import Desktop, Application app = Application(ba...
Getting TypeError with pywinauto when calling application.start for Store Apps
I tried to automate an application installed from the Microsoft Store, tried different applications, but I allways got the same error. I used this code: import subprocess from pywinauto import Desktop, Application app = Application(backend='uia').start(subprocess.call(r"start shell:appsFolder\5319275A.WhatsAppDesktop...
[ "It's a wrong usage. subprocess.call already starts the process and returns integer exit code. So you're passing integer instead of string command to method start.\nBut start command is not an executable, so pywinauto with default params is not able to run it. You need explicit usage of cmd.exe and connect to the c...
[ 0 ]
[]
[]
[ "automation", "python", "pywinauto" ]
stackoverflow_0074247297_automation_python_pywinauto.txt
Q: How Do I Simulate Pressing a button on a webpage using the "requests" library in Python I'd like to programmatically press the "Next Week" button on the webpage http://investing.com/economic-calendar/ and use BeautifulSoup to pull the resulting table. I am able to extract the table using BeautifulSoup but cannot s...
How Do I Simulate Pressing a button on a webpage using the "requests" library in Python
I'd like to programmatically press the "Next Week" button on the webpage http://investing.com/economic-calendar/ and use BeautifulSoup to pull the resulting table. I am able to extract the table using BeautifulSoup but cannot seem to be able to programmatically click the "Next Week" button By inspecting the webpage, I ...
[ "2 possible options\n\nUse 'Selenium' which means you're simulating browsing the page\n\nYou get the id of the link and then trigger click event from Javascript (which means you essentially have a client side)\n\n\n" ]
[ 1 ]
[]
[]
[ "python", "web_scraping" ]
stackoverflow_0074255664_python_web_scraping.txt
Q: download Yahoo Finance data with Python I have this code but it doesn't work and I don't know why... please help! import numpy as np import pandas as pd from pandas_datareader import data TSLA = data.DataReader('TSLA', 'yahoo', start='2020-01-01') print("TSLA:",TSLA) Traceback (most recent call last): File "C:\...
download Yahoo Finance data with Python
I have this code but it doesn't work and I don't know why... please help! import numpy as np import pandas as pd from pandas_datareader import data TSLA = data.DataReader('TSLA', 'yahoo', start='2020-01-01') print("TSLA:",TSLA) Traceback (most recent call last): File "C:\Users\David\Desktop\david\Sona\Python\PRUEBA....
[ "import numpy as np\nimport pandas as pd\nfrom pandas_datareader import data\n\nTSLA = data.get_data_yahoo('TSLA', start='2020-01-01')\nprint(\"TSLA:\",TSLA)\n\nOutput\n Open High Low Close Adj Close Volume\nDate \n2020-01-02 28.299999 28.713333 ...
[ 0 ]
[]
[]
[ "python", "windows", "yahoo_finance" ]
stackoverflow_0074255498_python_windows_yahoo_finance.txt
Q: How to write a JSONL file in Python I am trying to write a .jsonl file that needs to look like this: {"file_name": "0001.png", "text": "This is a golden retriever playing with a ball"} {"file_name": "0002.png", "text": "A german shepherd"} {"file_name": "0003.png", "text": "One chihuahua"} This is my attempt: imp...
How to write a JSONL file in Python
I am trying to write a .jsonl file that needs to look like this: {"file_name": "0001.png", "text": "This is a golden retriever playing with a ball"} {"file_name": "0002.png", "text": "A german shepherd"} {"file_name": "0003.png", "text": "One chihuahua"} This is my attempt: import json import pandas as pd dt = pd.rea...
[ "Don't indent the generated JSON and don't append it to a list. Just write out each line to the file:\nimport json\nimport pandas as pd\n\ndf = pd.DataFrame([['0001.png', \"This is a golden retriever playing with a ball\"],\n ['0002.png', \"A german shepherd\"],\n ['0003.png', \...
[ 1 ]
[]
[]
[ "json", "pandas", "python" ]
stackoverflow_0074255708_json_pandas_python.txt
Q: How do I change a working dirrectory for created folder using python? I want to create folder named by date in a selected folder. After that I want to make created folder a working directory. I got stucked with os.path.dirname as workingDirrectory apparently excludes \ARSOFinalTest from the path. Why is it so? del...
How do I change a working dirrectory for created folder using python?
I want to create folder named by date in a selected folder. After that I want to make created folder a working directory. I got stucked with os.path.dirname as workingDirrectory apparently excludes \ARSOFinalTest from the path. Why is it so? delovnaMapa = r"C:\Users\Tim\Desktop\ARSOFinalTest" print(delovnaMapa) today =...
[ "Well, yes, that's what dirname does. Let's have a look at the docs:\nos.path.dirname\n\nReturn the directory name of pathname path. This is the first element of the pair returned by passing path to the function split().\n\nos.path.split\n\nSplit the pathname path into a pair, (head, tail) where tail is the last pa...
[ 0 ]
[]
[]
[ "python" ]
stackoverflow_0074255705_python.txt
Q: Convert a list of strings to a Nested list of integers I have this output: ['0100', '0100'] and I wanted to have something like this [[0,1,0,0],[0,1,0,0]]. How can I do? A: Try: lst = ["0100", "0100"] out = [[int(ch) for ch in s] for s in lst] print(out) Prints: [[0, 1, 0, 0], [0, 1, 0, 0]]
Convert a list of strings to a Nested list of integers
I have this output: ['0100', '0100'] and I wanted to have something like this [[0,1,0,0],[0,1,0,0]]. How can I do?
[ "Try:\nlst = [\"0100\", \"0100\"]\n\nout = [[int(ch) for ch in s] for s in lst]\nprint(out)\n\nPrints:\n[[0, 1, 0, 0], [0, 1, 0, 0]]\n\n" ]
[ 4 ]
[]
[]
[ "nested_lists", "python", "string" ]
stackoverflow_0074255722_nested_lists_python_string.txt
Q: How to import from Qt:: namespase (Qt5, Python3.x)? For my application, I need to set some widget parameters like alignment (Qt::AlignBottom) and others. But I can't import them (other PyQt5 stuff imports without any issues). Using this code from PyQt5 import Qt progressBar = QProgressBar(splash) progressBar.setA...
How to import from Qt:: namespase (Qt5, Python3.x)?
For my application, I need to set some widget parameters like alignment (Qt::AlignBottom) and others. But I can't import them (other PyQt5 stuff imports without any issues). Using this code from PyQt5 import Qt progressBar = QProgressBar(splash) progressBar.setAlignment(Qt.AlignBottom) I got the following error: Trac...
[ "I think the confusion here is that PyQt has a special virtual module called Qt, which imports everything into a single namespace. This is a quite useful feature, but it's a real shame that the name clash with QtCore.Qt wasn't avoided.\nIn the first example, the error can be \"fixed\" by using the somewhat weird-lo...
[ 14, 7, 0 ]
[]
[]
[ "pyqt5", "python", "python_3.x", "qt", "qt5" ]
stackoverflow_0039316693_pyqt5_python_python_3.x_qt_qt5.txt
Q: Python logging using a decorator This is the first example we meet when we face with decorators. But I'm not able to realize what exactly I would like. A simple decorator named LOG. It should work like this: @LOG def f(a, b=2, *c, **d): pass And the result should be something like: f(1, pippo=4, paperino='luc...
Python logging using a decorator
This is the first example we meet when we face with decorators. But I'm not able to realize what exactly I would like. A simple decorator named LOG. It should work like this: @LOG def f(a, b=2, *c, **d): pass And the result should be something like: f(1, pippo=4, paperino='luca') ===== Enter f ===== a = 1 b = 2 pi...
[ "The only thing I noticed is that the dict((varList[i], v) for i, v in enumerate(argt)) construct you used twice is actually dict(zip(varList,argt)). \nOther than that i only have meta-criticism: None of the above belong in a logfile. \nInstead of going trough the logs to\n\nsee if functions are called with the cor...
[ 5, 1, 0, 0 ]
[]
[]
[ "decorator", "introspection", "logging", "python" ]
stackoverflow_0001648707_decorator_introspection_logging_python.txt
Q: Python: abort and retry a sync function after some time I'm developing a standard python script file (no servers, no async, no multiprocessing, ...) i.e. a classic data science program where I load data, process it as dataframes, and so on. Everything is synchronous. At some point, I need to call a function of an ...
Python: abort and retry a sync function after some time
I'm developing a standard python script file (no servers, no async, no multiprocessing, ...) i.e. a classic data science program where I load data, process it as dataframes, and so on. Everything is synchronous. At some point, I need to call a function of an external library which is totally external to me (I have no c...
[ "import time \nimport random\nimport threading\n\n\ndef func_that_waits():\n t1 = time.time()\n while (time.time() - t1) <= 3:\n time.sleep(1)\n if check_unreliable_func.worked:\n break\n if not check_unreliable_func.worked: \n print(\"unreliable function has been wor...
[ 0 ]
[]
[]
[ "python" ]
stackoverflow_0074255215_python.txt
Q: Complicated Nested JSON Normalization in Python After several days of trying, I'm posting for help. I know this question has been asked many times. I tried several solutions but I couldn't solve my problem. I have a large nested JSON file (1GB) and I would like to make it flat and then convert it to a CSV file. Th...
Complicated Nested JSON Normalization in Python
After several days of trying, I'm posting for help. I know this question has been asked many times. I tried several solutions but I couldn't solve my problem. I have a large nested JSON file (1GB) and I would like to make it flat and then convert it to a CSV file. The JSON file is: ` [{ "id": { "$oo...
[ "Not sure if I'm missing something but it seems pretty straight foreward.\ndf = pd.json_normalize(data=data, record_path=\"columnF\")\n\n" ]
[ 0 ]
[]
[]
[ "json", "nested_json", "normalization", "pandas", "python" ]
stackoverflow_0074255606_json_nested_json_normalization_pandas_python.txt
Q: Seaborn residplot not recognising "hue" in scatter_kws I am trying to use residplot on the tips data with hue as below: tips = sns.load_dataset("tips") sns.residplot(data=tips, x="total_bill", y="tip", scatter_kws={"hue":"sex"}) I have also tried: sns.residplot(data=tips, x="total_bill", y="tip", scatter_kws=dict...
Seaborn residplot not recognising "hue" in scatter_kws
I am trying to use residplot on the tips data with hue as below: tips = sns.load_dataset("tips") sns.residplot(data=tips, x="total_bill", y="tip", scatter_kws={"hue":"sex"}) I have also tried: sns.residplot(data=tips, x="total_bill", y="tip", scatter_kws=dict(hue="sex")) But on both occasions the error message is the...
[]
[]
[ "Try using lmplot\nsns.lmplot(x=\"total_bill\", y=\"tip\", hue=\"sex\", data=tips)\nplt.show()\n\n" ]
[ -2 ]
[ "python", "seaborn" ]
stackoverflow_0074255798_python_seaborn.txt
Q: KNN finds equal distances between datapoints after normalization I'm using the fifa players dataset to build a ML model that should find similar players. To this model I'm using KNN, but when I use data normalization it always find the same distance between datapoints. Look the exemple below: With normalization: #...
KNN finds equal distances between datapoints after normalization
I'm using the fifa players dataset to build a ML model that should find similar players. To this model I'm using KNN, but when I use data normalization it always find the same distance between datapoints. Look the exemple below: With normalization: #3.4 - Rescaling values from sklearn.preprocessing import MinMaxScaler...
[]
[]
[ "I noticed that i was fitting the model with scaled data, and evaluating it on unescaled data.\nTo solve this problem I made this\n##3.2 - Rescaling values\n\nfrom sklearn.preprocessing import MinMaxScaler\n\nscaler = MinMaxScaler()\n\nX_scaled = pd.DataFrame()\n\nX_scaled[X.columns.values] = scaler.fit_transform(...
[ -1 ]
[ "knn", "machine_learning", "python", "scikit_learn" ]
stackoverflow_0074254536_knn_machine_learning_python_scikit_learn.txt
Q: How do I make a list of strings withouth invalid characters in any of the strings? For example, if I had this list of invalid characters: invalid_char_list = [',', '.', '!'] And this list of strings: string_list = ['Hello,', 'world.', 'I', 'am', 'a', 'programmer!!'] I would want to get this new list: new_string_...
How do I make a list of strings withouth invalid characters in any of the strings?
For example, if I had this list of invalid characters: invalid_char_list = [',', '.', '!'] And this list of strings: string_list = ['Hello,', 'world.', 'I', 'am', 'a', 'programmer!!'] I would want to get this new list: new_string_list = ['Hello', 'world', 'I', 'am', 'a', 'programmer'] withouth , or . or ! in any of ...
[ "You can use regex and create this pattern : [,.!] and replace with ''.\nimport re\nre_invalid = re.compile(f\"([{''.join(invalid_char_list)}])\")\n# re_invalid <-> re.compile(r'([,.!])', re.UNICODE)\n\nnew_string_list = [re_invalid.sub(r'', s) for s in string_list]\nprint(new_string_list)\n\nOutput:\n['Hello', 'wo...
[ 1, 0, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0074255384_python.txt
Q: how can i get rid of quotation marks in python print I need the print were words in my list are separated with space, but the result of my print is as follows ['Salt'] So it prints it as list with quotations :( sry code is in Finnish :S def poistaTuote(Tuotteet): print("Ostoslistassasi on " + str(len(Tuotteet)...
how can i get rid of quotation marks in python print
I need the print were words in my list are separated with space, but the result of my print is as follows ['Salt'] So it prints it as list with quotations :( sry code is in Finnish :S def poistaTuote(Tuotteet): print("Ostoslistassasi on " + str(len(Tuotteet)) + " tuotetta.") Index = int(input("Anna poistettavan...
[ "Spread the list elements as separate arguments to print:\nprint(*Tuotteet)\n\nOr use str.join:\nprint(\" \".join(Tuotteet))\n\n" ]
[ 2 ]
[]
[]
[ "python", "python_3.x" ]
stackoverflow_0074255831_python_python_3.x.txt
Q: Cartopy fancy box Hello I have been trying to plot data in a Orthographic projection. The data is plotted but I want the box to follow the data limits. Like in this example I am sharing form M_map[enter image description here Do you have any suggestion? A: In the comments under the question, you have several li...
Cartopy fancy box
Hello I have been trying to plot data in a Orthographic projection. The data is plotted but I want the box to follow the data limits. Like in this example I am sharing form M_map[enter image description here Do you have any suggestion?
[ "In the comments under the question, you have several links to the existing answers that match the question. So that, this question is likely a duplicate question. However, none of the answers offers the zebra-pattern border as shown in the sample plot.\nI take this opportunity to offer a distinct answer that also ...
[ 2 ]
[]
[]
[ "cartopy", "matplotlib", "python" ]
stackoverflow_0074124975_cartopy_matplotlib_python.txt
Q: How to search in a very nested dictionary based on a value and get all the main keys I have a nested dictionary like this: my_dict = { "אבד": { "קל": { "עבר": { "אני": "אבדתי", "אתה": "אבדת", "את": "אבדת", "הוא": "אבד", ...
How to search in a very nested dictionary based on a value and get all the main keys
I have a nested dictionary like this: my_dict = { "אבד": { "קל": { "עבר": { "אני": "אבדתי", "אתה": "אבדת", "את": "אבדת", "הוא": "אבד", "היא": "אבדה", "אנחנו": "אבדנו", "אתם": "אבדת...
[ "Try:\ndef search(dct, word, current_path=None):\n if current_path is None:\n current_path = []\n\n for k, v in dct.items():\n if v == word:\n yield current_path\n elif isinstance(v, dict):\n yield from search(v, word, current_path + [k])\n\n\nfor path in search(my_d...
[ 0 ]
[]
[]
[ "dictionary", "python" ]
stackoverflow_0074255828_dictionary_python.txt
Q: Description formatting in Jira Python API I am trying to create a issue in Jira with description containing a dataframe ,i am trying to display the dataframe data in table style but it looks like below when issue is created,display of header is not matching with values enter image description here description='''{...
Description formatting in Jira Python API
I am trying to create a issue in Jira with description containing a dataframe ,i am trying to display the dataframe data in table style but it looks like below when issue is created,display of header is not matching with values enter image description here description='''{0} '''.format(df)
[ "I've a method in https://github.com/dren79/JiraScripting_public - https://github.com/dren79/JiraScripting_public/blob/main/create_jira_tickets/create_fancy_jira_issue.py that will do the job for you. Use the below code (from https://developer.atlassian.com/cloud/jira/platform/apis/document/playground/) and substit...
[ 0 ]
[]
[]
[ "dataframe", "exasol", "jira", "numpy", "python" ]
stackoverflow_0073679250_dataframe_exasol_jira_numpy_python.txt
Q: unable to Fetch date and time from string I am trying to fetch the time and date from the text FOX News October 27, 2022 5:00pm-6:00pm PDT, but not getting a standard approach. While using the position of the string, it doesn't work because the size of the string changes with the different months (April to Decem...
unable to Fetch date and time from string
I am trying to fetch the time and date from the text FOX News October 27, 2022 5:00pm-6:00pm PDT, but not getting a standard approach. While using the position of the string, it doesn't work because the size of the string changes with the different months (April to December) and times. text=['FOX News October 27, 20...
[ "You can use dateutil to extract the dates:\nimport pandas as pd\nfrom dateutil import parser\ntext=['FOX News October 27, 2022 5:00pm-6:00pm PDT','FOX News October 28, 2022 5:00pm-6:00pm PDT']\ndf=pd.DataFrame(list(zip(text)),columns =['text'])\ndf['text'] = df['text'].apply(parser.parse, fuzzy=True)\n\nOutput:\...
[ 0 ]
[]
[]
[ "dataframe", "pandas", "python", "python_3.x", "regex" ]
stackoverflow_0074255780_dataframe_pandas_python_python_3.x_regex.txt
Q: iterate over large JSON file using python and create a reduced JSON output only with specific values How to iterate over JSON using python with children nodes? A: This solution should solve your initial problem (remove configurations with 'vulnerable:false'). I used the sample json data you provided in the quest...
iterate over large JSON file using python and create a reduced JSON output only with specific values
How to iterate over JSON using python with children nodes?
[ "This solution should solve your initial problem (remove configurations with 'vulnerable:false'). I used the sample json data you provided in the question.\nimport json\n\nwith open('data.json','r') as f:\n data = json.load(f)\n\nnodes = data.get('CVE_Items')[0].get('configurations').get('nodes')[0].get('cpe_mat...
[ 0, 0 ]
[]
[]
[ "arrays", "json", "loops", "python" ]
stackoverflow_0074255602_arrays_json_loops_python.txt
Q: Is it possible to use the built-in LogEntry to track actions of every users not only in admin page? I just recently knew about the built in LogEntry model in django, and I've tried to registered it in my admin page. What I want to happen is, for example, the admin added new User not using the django admin page but...
Is it possible to use the built-in LogEntry to track actions of every users not only in admin page?
I just recently knew about the built in LogEntry model in django, and I've tried to registered it in my admin page. What I want to happen is, for example, the admin added new User not using the django admin page but through the add page I made using some model forms in my site, how can i add data to LogEntry regarding ...
[ "You can easily do that in outside the admin by creating a new LogEntry object each time a change is made\nfrom django.contrib.admin.models import LogEntry, ADDITION, CHANGE # these are action flags from the docs\nLogEntry.objects.log_action(\n user_id=request.user.id,\n content_type_id=ContentType.ob...
[ 3, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0057916827_django_python.txt
Q: Failed to install Python Cryptography package with PIP and setup.py When I try to install the Cryptography package for Python through either pip install cryptography or by downloading the package from their site and running python setup.py, I get the following error: D:\Anaconda\Scripts\pip-script.py run on 02/27...
Failed to install Python Cryptography package with PIP and setup.py
When I try to install the Cryptography package for Python through either pip install cryptography or by downloading the package from their site and running python setup.py, I get the following error: D:\Anaconda\Scripts\pip-script.py run on 02/27/14 16:13:17 Downloading/unpacking cryptography Getting page https://py...
[ "I had a similar issue, and found I was simply missing a dependency (libssl-dev, for me). As referenced in https://cryptography.io/en/latest/installation/, ensure that all dependencies are met:\nOn Windows\nIf you’re on Windows you’ll need to make sure you have OpenSSL installed. There are pre-compiled binaries ava...
[ 462, 138, 46, 27, 23, 18, 17, 14, 10, 7, 6, 5, 4, 4, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 ]
[]
[]
[ "cryptography", "pip", "python" ]
stackoverflow_0022073516_cryptography_pip_python.txt
Q: Serializer for Recursive Comment in Django models.py class Comments(models.Model): content = models.CharField(max_length=500) sub_comment_id = models.ForeignKey('self', related_name='sub_comments', null=True, blank=True, on_delete=models.CASCADE) author_id = mode...
Serializer for Recursive Comment in Django
models.py class Comments(models.Model): content = models.CharField(max_length=500) sub_comment_id = models.ForeignKey('self', related_name='sub_comments', null=True, blank=True, on_delete=models.CASCADE) author_id = models.ForeignKey(settings.AUTH_USER_MODEL, related_...
[ "I have never try something like this, but i don't see why it wouldn't work\nCommentSerializer(serializers.Serializer):\n content = serializers.CharField()\n ...\n sub_comments = serializers.SerializerMethodField()\n\n def get_sub_comments(self, comment):\n return self.__class__(comment.sub_comments.al...
[ 0 ]
[]
[]
[ "django", "django_rest_framework", "python" ]
stackoverflow_0074253532_django_django_rest_framework_python.txt
Q: Printing substring from one dataframe to another dataframe In the df_input['Visit' ] column, there are three different timepoints that I would like to extract and have print into a new dataframe (df_output). The time points are Pre, Post, and Screening. I essentially would like to make a for loop (or just a sing...
Printing substring from one dataframe to another dataframe
In the df_input['Visit' ] column, there are three different timepoints that I would like to extract and have print into a new dataframe (df_output). The time points are Pre, Post, and Screening. I essentially would like to make a for loop (or just a single code strand) stating: if data_input['Visit '] contains the ...
[ "df_output['VISIT'] = df_input['Visit'].apply(lambda x: 'Pre' if x.str.contains('Pre') else 'Post' if x.str.contains('Post') else 'Screening' if x.str.contains('Screening') else \"\")\n\nYou must create df_ouput first, tho.\n", "you can use np.select\nimport numpy\n\ndf_output['VISIT'] = np.select( [df_input['Vis...
[ 0, 0 ]
[]
[]
[ "dataframe", "pandas", "python", "string", "substring" ]
stackoverflow_0074255949_dataframe_pandas_python_string_substring.txt
Q: getting specific key from a json format in python I am trying to get a specific key vulnerabilityID and vulnerabilitySoln from this json file. This is towards the bottom of the json script. { "vulnerabilities": [ { "labels": [ { "labelKey": "com.acme.image.source", ...
getting specific key from a json format in python
I am trying to get a specific key vulnerabilityID and vulnerabilitySoln from this json file. This is towards the bottom of the json script. { "vulnerabilities": [ { "labels": [ { "labelKey": "com.acme.image.source", "labelValue": "http://github.com/base-image...
[ "There are also two levels of lists in there:\ndef vulnData():\n for i in data[\"vulnerabilities\"]:\n vuln = i[\"vulnerabilities\"][0]\n vulnID = vuln[\"vulnerabilityID\"]\n vulnSoln = vuln[\"vulnerabilitySoln\"])\n print(vulnID, vulnSoln)\n\n" ]
[ 0 ]
[]
[]
[ "json", "python" ]
stackoverflow_0074255754_json_python.txt
Q: mutiline python script in html (pyscript) I've tried to use pyscript in html but i can only get it to work in one line of code can somebody help me get it to work for the following code? def vpn(website): from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = ...
mutiline python script in html (pyscript)
I've tried to use pyscript in html but i can only get it to work in one line of code can somebody help me get it to work for the following code? def vpn(website): from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument('--no-sa...
[ "Maybe, just maybe, there is an indentation problem. Pyscript code written inside html file will error if tab character is used for indentation even just once instead of spaces and the other way arround. It is hard to notice it as the code with tabs and with 4 spaces looks the same. Example:\n<py-script>\nimport pa...
[ 0 ]
[]
[]
[ "html", "pyscript", "python", "selenium", "selenium_webdriver" ]
stackoverflow_0074035234_html_pyscript_python_selenium_selenium_webdriver.txt
Q: I am trying to edit the toplevel window for a project I am making we are supposed to make a login screen my issue is that I am not familiar with top level windows and I dont know how to put labels and buttons on it This is the code that I am working with import tkinter as tk from tkinter import ttk import ttktheme...
I am trying to edit the toplevel window for a project I am making
we are supposed to make a login screen my issue is that I am not familiar with top level windows and I dont know how to put labels and buttons on it This is the code that I am working with import tkinter as tk from tkinter import ttk import ttkthemes as th class App(th.ThemedTk): def __init__(self, title: str): ...
[ "You need to assign the Label and Button to the new Toplevel that you create in change_text. The first argument in the widget creation functions is the parent widget. The change_text method below is amended to open a new Toplevel window and add the Label and Button to it.\nimport tkinter as tk\nfrom tkinter impor...
[ 0 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0074249873_python_tkinter.txt
Q: greenlet_spawn has not been called I am trying to get the number of rows matched in a one to many relationship. When I try parent.children_count I get : sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place? (Background on this er...
greenlet_spawn has not been called
I am trying to get the number of rows matched in a one to many relationship. When I try parent.children_count I get : sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place? (Background on this error at: https://sqlalche.me/e/14/xd2s) ...
[ "I think the problem here is that by default SQLAlchemy lazy-loads relationships, so accessing parent.children_count implicitly triggers a database query leading to the reported error.\nOne way around this would be to specify a load strategy other than \"lazy\" in the relationship definition. Using SQLModel, this ...
[ 3 ]
[]
[]
[ "python", "sqlalchemy", "sqlite", "sqlmodel" ]
stackoverflow_0074252768_python_sqlalchemy_sqlite_sqlmodel.txt
Q: How do I profile a Python script? Project Euler and other coding contests often have a maximum time to run or people boast of how fast their particular solution runs. With Python, sometimes the approaches are somewhat kludgey - i.e., adding timing code to __main__. What is a good way to profile how long a Python p...
How do I profile a Python script?
Project Euler and other coding contests often have a maximum time to run or people boast of how fast their particular solution runs. With Python, sometimes the approaches are somewhat kludgey - i.e., adding timing code to __main__. What is a good way to profile how long a Python program takes to run?
[ "Python includes a profiler called cProfile. It not only gives the total running time, but also times each function separately, and tells you how many times each function was called, making it easy to determine where you should make optimizations.\nYou can call it from within your code, or from the interpreter, lik...
[ 1663, 507, 230, 178, 158, 144, 105, 96, 61, 43, 39, 38, 24, 21, 15, 14, 12, 11, 9, 9, 8, 8, 7, 6, 6, 5, 5, 3, 3, 2, 1, 1, 0 ]
[]
[]
[ "optimization", "performance", "profiling", "python", "time_complexity" ]
stackoverflow_0000582336_optimization_performance_profiling_python_time_complexity.txt
Q: Can't filter Pandas Series of lists by length I have a Series of ratings, each contained in a list: ratings_series = pd.Series([[5.7],[],[6.3],...]) I want to only include the ratings with values i.e disclude empty strings. I've tried loads of ways to filter the Series, the main one being film_filtered2 = ratings_...
Can't filter Pandas Series of lists by length
I have a Series of ratings, each contained in a list: ratings_series = pd.Series([[5.7],[],[6.3],...]) I want to only include the ratings with values i.e disclude empty strings. I've tried loads of ways to filter the Series, the main one being film_filtered2 = ratings_series[len(ratings_series) > 0] I also tried film_f...
[ "In this case, you can probably use .apply on the series, with len as the function to apply. This then works per element:\n>>> ratings_series = pd.Series([[5.7],[],[6.3]])\n>>> ratings_series\n0 [5.7]\n1 []\n2 [6.3]\ndtype: object\n>>> ratings_series.apply(len)\n0 1\n1 0\n2 1\ndtype: int64\n>>>...
[ 0 ]
[]
[]
[ "pandas", "python", "series" ]
stackoverflow_0074255989_pandas_python_series.txt
Q: How to loop "refresh page" in Selenium I'm using Selenium to extract tables from Excalibur. When you upload a file into it you have to refresh the page until the page redirectioned to workspace. Shows: <div class="container"> == $0 empty Then when you refresh shows: <div class="container"> <div class="row pb-4">...
How to loop "refresh page" in Selenium
I'm using Selenium to extract tables from Excalibur. When you upload a file into it you have to refresh the page until the page redirectioned to workspace. Shows: <div class="container"> == $0 empty Then when you refresh shows: <div class="container"> <div class="row pb-4"> <div class="row"> <div class="row"> I us...
[ "You probably need to add a refresh cool down like so:\nwhile True:\n try:\n driver.find_element_by _linked_text('Workspace'):\n break\n except NoSuchElementException:\n driver.implicitly_wait(2)\n driver.refresh()\n\nWithout this Selenium will constantly try and refresh the page, ...
[ 2, 2, 0 ]
[]
[]
[ "python", "selenium_chromedriver" ]
stackoverflow_0060459552_python_selenium_chromedriver.txt
Q: Is there a way to access a variable from inside a function without passing it as an argument? I'm trying to write a telegram bot, that uses inline keyboards to make criteria for selection in a step by step way. And I want the last step of this to be a message telling me what are the criteria selected. Normally I w...
Is there a way to access a variable from inside a function without passing it as an argument?
I'm trying to write a telegram bot, that uses inline keyboards to make criteria for selection in a step by step way. And I want the last step of this to be a message telling me what are the criteria selected. Normally I would return the string value from one function and pass it into another, but I'm new to telegram bo...
[ "Not sure if this is a standard pattern, but it seems like you could make these handler functions instance methods (so they can share instance attributes) and register them in __init__:\nclass Handler:\n def __init__(self, dp: Dispatcher):\n self.selected_criteria = \"\"\n dp.message_handler(\n ...
[ 0 ]
[]
[]
[ "aiogram", "python", "telegram_bot", "variables" ]
stackoverflow_0074256013_aiogram_python_telegram_bot_variables.txt
Q: "Most likely due to circular import" in Python import threading import time start = time.perf_counter() def do_something(): print("Sleeping in 1 second") time.sleep(1) print("Done sleeping") t1 = threading.Thread(target=do_something) t2 = threading.Thread(target=do_something) finish = time.perf_cou...
"Most likely due to circular import" in Python
import threading import time start = time.perf_counter() def do_something(): print("Sleeping in 1 second") time.sleep(1) print("Done sleeping") t1 = threading.Thread(target=do_something) t2 = threading.Thread(target=do_something) finish = time.perf_counter() print(f"Finished in {round(finish-start,1)} s...
[ "It seems like the program file you have created is named threading.py, and you are importing a module also called threading. This causes a circular import because your file is shadowing the built-in module.\nPlease rename your program (e.g., threading-example.py).\n", "When importing modules, python checks the f...
[ 5, 0, 0 ]
[]
[]
[ "importerror", "python" ]
stackoverflow_0067061049_importerror_python.txt
Q: How do I make a number in a StringVariable increase by 1 every 5 seconds in Tkinter So i've been coding a Cookie Clicker prototype in Tkinter and I stumbled with this problem: I first made an option that when pressed, makes every click worth 2 points(It has a price). Then I wanted to make another option that when ...
How do I make a number in a StringVariable increase by 1 every 5 seconds in Tkinter
So i've been coding a Cookie Clicker prototype in Tkinter and I stumbled with this problem: I first made an option that when pressed, makes every click worth 2 points(It has a price). Then I wanted to make another option that when pressed, it would add up 1 point every 5 seconds but I haven't found a way to make it wor...
[ "Tkinter widgets have a method named after that can be used to schedule functions to run in the future. If that function itself calls after to reschedule itself, it will continue to run for the life of the application.\nThe first argument to after is a delay in milliseconds. The second argument is a reference to a ...
[ 0 ]
[]
[]
[ "intermediate_code", "python", "time", "tkinter" ]
stackoverflow_0074255761_intermediate_code_python_time_tkinter.txt
Q: How to get info from SQL table in python? I am trying to compare value from SQL database with user discord ID. But my code is printing all IDs from SQL database. If user's discord ID exist in SQL databse, print values from insert_time, platform, gamertag, kills, downs, kdRatio. If no print error message (you are n...
How to get info from SQL table in python?
I am trying to compare value from SQL database with user discord ID. But my code is printing all IDs from SQL database. If user's discord ID exist in SQL databse, print values from insert_time, platform, gamertag, kills, downs, kdRatio. If no print error message (you are not registered). This is my database My code: p...
[ "Your SQL statement will only return rows that contain the user id you are looking for. The code should print the row if any are returned or print \"you are not registered\" if nothing is found.\nprint(logTime,\">\", ctx.author.name,\">\", \"Me command starting here...\")\nmydb = mysql.connector.connect(\n h...
[ 0 ]
[]
[]
[ "mysql_connector_python", "python", "select" ]
stackoverflow_0074253261_mysql_connector_python_python_select.txt
Q: Selected data not shown in HTML table Why is my code not working? I tried to {{row[0]}} and it works. But this is not useful when I add DELETE / UPDATE buttons to Row-[0] instead of ID in @app.route. @app.route("/register_style") def style_list(): BASE_DIR = os.path.dirname(os.path.abspath(__file__)) SQ...
Selected data not shown in HTML table
Why is my code not working? I tried to {{row[0]}} and it works. But this is not useful when I add DELETE / UPDATE buttons to Row-[0] instead of ID in @app.route. @app.route("/register_style") def style_list(): BASE_DIR = os.path.dirname(os.path.abspath(__file__)) SQLPATH = os.path.join(BASE_DIR,'DatBaseTexCO...
[ "You have a few inconsistencies in your code with variables declared multiples times and other things. I would go through that once more.\nHowever regarding your issue i see two clear syntax errors in your code.\n1.\nrows = curs.fetchall\n\nshould be\nrows = curs.fetchall()\n\n\nand this probably the one that is ca...
[ 0 ]
[]
[]
[ "flask", "html", "python", "sqlite" ]
stackoverflow_0074255973_flask_html_python_sqlite.txt
Q: Webscraping google search results Python I am trying to obtain both the title and link in some form of list or dictionary of the search results for the first page. However, my output shows Element 'a' href= before the link and my title shows Element 'h3' class=('LC20lb', 'MBeuO', 'DKV0Md') instead of the actual ti...
Webscraping google search results Python
I am trying to obtain both the title and link in some form of list or dictionary of the search results for the first page. However, my output shows Element 'a' href= before the link and my title shows Element 'h3' class=('LC20lb', 'MBeuO', 'DKV0Md') instead of the actual title. I have read through many examples but mos...
[ "You can use BeautifulSoop library to parse your library better\n" ]
[ 0 ]
[]
[]
[ "python", "python_requests", "python_requests_html", "urllib" ]
stackoverflow_0074255514_python_python_requests_python_requests_html_urllib.txt
Q: Use pipenv in airflow docker dag folder I have created an airflow docker container. I'm using a dag folder inside my local system to create DAGs which call python scripts and use PythonOperator. I would like to use some Python packages in the DAGs and work with pipenv, but if I create a pipenv environment inside t...
Use pipenv in airflow docker dag folder
I have created an airflow docker container. I'm using a dag folder inside my local system to create DAGs which call python scripts and use PythonOperator. I would like to use some Python packages in the DAGs and work with pipenv, but if I create a pipenv environment inside the folder, packages are not recognized by the...
[ "If you want to install additional packages in your container and work with them, option suggested in airflow documentation is building the image by yourself.\n\nIf you need to install a new Python library or system library, you can build your image.\n\nhttps://airflow.apache.org/docs/docker-stack/index.html\nBasic...
[ 1 ]
[]
[]
[ "airflow", "docker", "pipenv", "python" ]
stackoverflow_0074256220_airflow_docker_pipenv_python.txt