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: Sybase IQ connection in Python I've spent a few days trying to determine how to connect to a Sybase IQ database through Python 3.6. I've tried pyodbc and pymssql, to no avail. Below are two code snippets that I've been working on, which don't seem to work, no matter what I try. pyodbc: conn = pyodbc.connect(driver...
Sybase IQ connection in Python
I've spent a few days trying to determine how to connect to a Sybase IQ database through Python 3.6. I've tried pyodbc and pymssql, to no avail. Below are two code snippets that I've been working on, which don't seem to work, no matter what I try. pyodbc: conn = pyodbc.connect(driver='{SQL Server Native Client 11.0}', ...
[ "After some time, I was able to resolve this issue (On Windows). First, install SQL Anywhere 17 driver. Once that's been installed, in the Windows ODBC Data Sources window, set up a connection using the SQL Anywhere 17, and your Sybase IQ credentials. Once that has been configured and successfully tested, you can u...
[ 1, 0 ]
[]
[]
[ "database", "python", "python_3.x", "sap_iq", "sybase" ]
stackoverflow_0053726766_database_python_python_3.x_sap_iq_sybase.txt
Q: Iterate over pandas rows and using shift() in if statement I'm trying to iterate over a dataframe, then apply the shift() function. It gives me the error: 'numpy.int64' object has no attribute 'shift' Any simple way to do this while keeping the iteration? It should only show the last index value. import pandas as ...
Iterate over pandas rows and using shift() in if statement
I'm trying to iterate over a dataframe, then apply the shift() function. It gives me the error: 'numpy.int64' object has no attribute 'shift' Any simple way to do this while keeping the iteration? It should only show the last index value. import pandas as pd df = pd.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]], ...
[ "The loop approach would be to use a variable:\nprev = None\nfor index, row in df.iterrows():\n if prev is not None and prev >= 4:\n print(index)\n prev = row['B']\n\nOutput:\n2\n\nHowever, if you can, use vectorial code:\nout = df.index[df['B'].shift().ge(4)]\n\n# if needed to print\nprint(*out, sep='\\n')\n\...
[ 0 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074547789_pandas_python.txt
Q: Python: Saving result from loop to a variable I am storing specific information from an XML file to a variable. The XML file contains a lot of information, but I am just looking for something called nAtt. I am reading the XML file into a data frame: df = pd.read_xml(folder_path2 + filename6) nAtt contains either ...
Python: Saving result from loop to a variable
I am storing specific information from an XML file to a variable. The XML file contains a lot of information, but I am just looking for something called nAtt. I am reading the XML file into a data frame: df = pd.read_xml(folder_path2 + filename6) nAtt contains either 0, 1, 2 or 3 and it looks like nAtt=" 0" So, I say ...
[ "Not entirely clear but I suppose you want to do something like this:\nnAtt_change = np.zeros(shape = len(nAtt))\n\nfor i in range(len(nAtt)):\n if nAtt[i] == 0:\n nAtt_change[i] = yourSpecificValue\n ...\n\nChange yourSPecificValue to the value you want and add other if statements for the rest of the nAtt...
[ 0 ]
[]
[]
[ "loops", "python", "xml" ]
stackoverflow_0074547857_loops_python_xml.txt
Q: am performing a login with django cutsom aunt but i get qoute_from_bytes() expected bytes error The Error! TypeError at /perform_login quote_from_bytes() expected bytes Request Method: POST Request URL: http://127.0.0.1:8000/perform_login Django Version: 4.1.3 Exception Type: TypeError Exception Value: quot...
am performing a login with django cutsom aunt but i get qoute_from_bytes() expected bytes error
The Error! TypeError at /perform_login quote_from_bytes() expected bytes Request Method: POST Request URL: http://127.0.0.1:8000/perform_login Django Version: 4.1.3 Exception Type: TypeError Exception Value: quote_from_bytes() expected bytes Exception Location: C:\Users\DND\AppData\Local\Programs\Python\Python31...
[ "You need to be a correct key value like this take white space in keys ...\nuser_mail = request.POST.get('email_field')\npassword = request.POST.get('password_field')\n\n" ]
[ 0 ]
[]
[]
[ "django", "django_forms", "django_templates", "django_views", "python" ]
stackoverflow_0074543858_django_django_forms_django_templates_django_views_python.txt
Q: Pandas: Grouping columns based on current index I have a pandas data frame, whose data i want to group into column groups their current column index contains the name of the group i want to group by, and i'm having a problem with extracting only that part of the name. the name of the columns is always "day_replica...
Pandas: Grouping columns based on current index
I have a pandas data frame, whose data i want to group into column groups their current column index contains the name of the group i want to group by, and i'm having a problem with extracting only that part of the name. the name of the columns is always "day_replicate". so i'm trying define a function that groups the ...
[ "You can use pandas.MultiIndex.from_arrays and str.extract:\nnew_idx = pd.MultiIndex.from_arrays([\n df.columns,\n df.columns.str.extract('_(\\d+)', expand=False)\n], names=['index', 'day'])\n\ndf.columns = new_idx\n\nBefore:\n d0_1 d0_2 d1_1 d1_2\n0 NaN NaN NaN NaN\n\nAfter:\nindex d0_1 d0_2 d1_1 d1_2\n...
[ 0 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074547923_pandas_python.txt
Q: Making each alternative word lower and upper case Ask for a string from the user and make each alternative word lower and upper case (e.g. the string “I am learning to code” would become “i AM learning TO code”). Using the split and join functions will help you here. I did a similar thing for characters in the st...
Making each alternative word lower and upper case
Ask for a string from the user and make each alternative word lower and upper case (e.g. the string “I am learning to code” would become “i AM learning TO code”). Using the split and join functions will help you here. I did a similar thing for characters in the string, but as I found out it doesn't work with full wor...
[ "You can try this\nnew_string = input(\"Please enter a string: \")\nchar_storage = \"\" #blank string to store all the string's characters\nchar = 1\n\nfor i in new_string.split(): \n if char != 1:\n char_storage += \" \"\n if char % 2 == 0:\n char_storage += i.lower()\n else: \n cha...
[ 1, 0, 0 ]
[]
[]
[ "python", "uppercase" ]
stackoverflow_0074547765_python_uppercase.txt
Q: How do I access items in an OrderedDict within an OrderedDict? I am querying Salesforce with simple_salesforce and getting the following as a result: OrderedDict([('totalSize', 1), ('done', True), ('records', [OrderedDict([('attributes', OrderedD...
How do I access items in an OrderedDict within an OrderedDict?
I am querying Salesforce with simple_salesforce and getting the following as a result: OrderedDict([('totalSize', 1), ('done', True), ('records', [OrderedDict([('attributes', OrderedDict([('type', 'Contact'), ...
[ "In the specific example you provided you would access the first dictionary by dict1['records'][-1]. This works because 'records' is a key in your main dictionary and its item is a list of ordered dictionaries. You want the last item of that list, so you index by [-1].\n" ]
[ 0 ]
[]
[]
[ "dictionary", "pandas", "python" ]
stackoverflow_0074547859_dictionary_pandas_python.txt
Q: What is a "method" in Python? Can anyone, please, explain to me in very simple terms what a "method" is in Python? The thing is in many Python tutorials for beginners this word is used in such way as if the beginner already knew what a method is in the context of Python. While I am of course familiar with the gene...
What is a "method" in Python?
Can anyone, please, explain to me in very simple terms what a "method" is in Python? The thing is in many Python tutorials for beginners this word is used in such way as if the beginner already knew what a method is in the context of Python. While I am of course familiar with the general meaning of this word, I have no...
[ "It's a function which is a member of a class:\nclass C:\n def my_method(self):\n print(\"I am a C\")\n\nc = C()\nc.my_method() # Prints(\"I am a C\")\n\nSimple as that!\n(There are also some alternative kinds of method, allowing you to control the relationship between the class and the function. But I'...
[ 91, 45, 28, 4, 0, 0, 0, 0, 0 ]
[]
[]
[ "methods", "python" ]
stackoverflow_0003786881_methods_python.txt
Q: Different results in KS-test from Scipy and statsmodels My code: from scipy import stats import statsmodels.api as sm data=[-0.032400000000000005,-0.0358,-0.035699999999999996,-0.029500000000000002,-0.0227,-0.0146,-0.0125,-0.0103,-0.0182,-0.0137,-0.021099999999999997,-0.0327,-0.0279,-0.0325,-0.0252,-0.015700000000...
Different results in KS-test from Scipy and statsmodels
My code: from scipy import stats import statsmodels.api as sm data=[-0.032400000000000005,-0.0358,-0.035699999999999996,-0.029500000000000002,-0.0227,-0.0146,-0.0125,-0.0103,-0.0182,-0.0137,-0.021099999999999997,-0.0327,-0.0279,-0.0325,-0.0252,-0.015700000000000002,-0.0148,-0.013999999999999999,-0.0137,-0.0135000000000...
[ "These are two different tests.\nscipy ks_1samp is a KS test given a fully specified distribution, i.e. no estimated parameters. In the example the Null hypothesis test is that the data comes from a standard normal distribution N(0, 1)\nstatsmodels kstest_normal is a KS test with estimated parameters.\nThe Null hyp...
[ 1 ]
[]
[]
[ "python", "statistics" ]
stackoverflow_0074541655_python_statistics.txt
Q: Does customtkinter CTkButton hover has event option? I want to perform an action when a mouse hover event occurred on customtkinter ctkbutton hover. is it yet implemented? A: Per the CTkButton source code, the on_enter method is bound to the <Enter> event. This method is predominantly focused on updating the but...
Does customtkinter CTkButton hover has event option?
I want to perform an action when a mouse hover event occurred on customtkinter ctkbutton hover. is it yet implemented?
[ "Per the CTkButton source code, the on_enter method is bound to the <Enter> event. This method is predominantly focused on updating the button's appearance on hover. If you want to trigger an additional callback on hover, you'll have to add another binding to the button\ndef callback(event):\n # put whatever you...
[ 3 ]
[]
[]
[ "customtkinter", "python", "tkinter" ]
stackoverflow_0074547734_customtkinter_python_tkinter.txt
Q: How to convert dataframe column which contains list of dictionary into separate columns? I have a dataframe column which looks like this: df_cost['region.localCurrency']: 0 [{'content': 'Dirham', 'languageCode': 'EN'}] 1 [{'content': 'Dirham', 'languageCode': 'EN'}] 2 [{'content': 'Dirham', 'languageC...
How to convert dataframe column which contains list of dictionary into separate columns?
I have a dataframe column which looks like this: df_cost['region.localCurrency']: 0 [{'content': 'Dirham', 'languageCode': 'EN'}] 1 [{'content': 'Dirham', 'languageCode': 'EN'}] 2 [{'content': 'Dirham', 'languageCode': 'EN'}] 3 [{'content': 'Euro', 'languageCode': 'DE'}] 4 [{'content': 'Euro', ...
[ "Pandas.json_normalize will probably do the job for you.\nhttps://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.json_normalize.html\n", "Use json_normalize with convert first values by indexing:\nd = {'content':'localCurrencyContent','languageCode':'localCurrencyCode'}\ndf1 = pd.json_normalize(df_cost...
[ 1, 1 ]
[]
[]
[ "dataframe", "dictionary", "nested", "pandas", "python" ]
stackoverflow_0074547753_dataframe_dictionary_nested_pandas_python.txt
Q: How to fix missing port issue with GCP Cloud Function (Gen2) when deployed? I am trying to deploy a cloud function (gen2) in GCP but running into the same issue and get this error with each deploy when Cloud Functions sets up Cloud Run: The user-provided container failed to start and listen on the port defined pr...
How to fix missing port issue with GCP Cloud Function (Gen2) when deployed?
I am trying to deploy a cloud function (gen2) in GCP but running into the same issue and get this error with each deploy when Cloud Functions sets up Cloud Run: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. MAIN.PY from google.cloud import p...
[ "The above error could be caused by configuration issues for the listener port which could be some mismatches in the user defined values settings.\nYou may check and verify the following pointers to understand the probable cause of the error and rectify these to try and eliminate the issue:\n\nCheck if you config...
[ 0 ]
[]
[]
[ "docker", "google_cloud_functions", "google_cloud_run", "python" ]
stackoverflow_0074541847_docker_google_cloud_functions_google_cloud_run_python.txt
Q: "bad input" after executing any git command Yesterday I just installed this script on my Macbook because I was having issues with the git credentials being stored in the keychain and after these expired I was getting error 403. I found that script that claims to periodically check for those credentials and delete ...
"bad input" after executing any git command
Yesterday I just installed this script on my Macbook because I was having issues with the git credentials being stored in the keychain and after these expired I was getting error 403. I found that script that claims to periodically check for those credentials and delete them to avoid that kind of problems. The problem ...
[ "You can open ~/.gitconfig from any terminal you have and remove the cache and wincred helpers.\n" ]
[ 0 ]
[]
[]
[ "bash", "git", "macos", "python" ]
stackoverflow_0066587429_bash_git_macos_python.txt
Q: Next and Before Links for a django paginated query I'm trying to make a search form for Django. Its a typical search form and then returns a table of matches. I wish to paginate the tables returned. The problem lies in the Previous and Next buttons. The links for the return query goes to /records/search/?query=a (...
Next and Before Links for a django paginated query
I'm trying to make a search form for Django. Its a typical search form and then returns a table of matches. I wish to paginate the tables returned. The problem lies in the Previous and Next buttons. The links for the return query goes to /records/search/?query=a (search sample is a) The page outputs the table and its p...
[ "I would recommend putting the solution in a template tag like so:\nmyapp/templatetags/mytemplatetags.py:\nfrom django import template\nregister = template.Library()\n\n@register.simple_tag\ndef url_replace(request, field, value):\n d = request.GET.copy()\n d[field] = value\n return d.urlencode()\n\n@regis...
[ 8, 2, 1, 1, 0 ]
[]
[]
[ "django", "pagination", "python" ]
stackoverflow_0022734695_django_pagination_python.txt
Q: Import issue for falcon.responders in pyinstaller executable Having an import issue when running the exe (as onefile) created by pyinstaller I added 'falcon.responders' to the list of hidden imports. But still the import error when running the executable. What can be wrong? Traceback (most recent call last): Fil...
Import issue for falcon.responders in pyinstaller executable
Having an import issue when running the exe (as onefile) created by pyinstaller I added 'falcon.responders' to the list of hidden imports. But still the import error when running the executable. What can be wrong? Traceback (most recent call last): File "s2rdf.py", line 62, in <module> import morph_kgc File "Py...
[ "I had a similar problem, but it was fixed by removing the last generated directories (\"build\" and \"dist\") and using this hidden import list:\nhiddenimports=['falcon.app_helpers', 'xml.etree', 'falcon.responders', 'xml.etree.ElementTree']\n\n" ]
[ 0 ]
[]
[]
[ "falcon", "pyinstaller", "python" ]
stackoverflow_0073123971_falcon_pyinstaller_python.txt
Q: Tkinter look (theme) in Linux I know that Tkinter is not so modern, not so cool and maybe better to use PyQt or etc. But it is interesting for me can Tkinter look not so ugly in Ubuntu (Linux). Looks that brew version (in OS X) of python's Tkinter compiled with built-in theme and looks good: But Ubuntu's Tkinter ...
Tkinter look (theme) in Linux
I know that Tkinter is not so modern, not so cool and maybe better to use PyQt or etc. But it is interesting for me can Tkinter look not so ugly in Ubuntu (Linux). Looks that brew version (in OS X) of python's Tkinter compiled with built-in theme and looks good: But Ubuntu's Tkinter makes me cry: I've read that for g...
[ "All available themes of ttk can be seen with such commands:\n$ python\n>>> import ttk\n>>> s=ttk.Style()\n>>> s.theme_names()\n('clam', 'alt', 'default', 'classic')\n\nSo you can use 'clam', 'alt', 'default', 'classic' themes with your version of Tkinter.\nAfter trying all of them I think the best one is 'clam'. Y...
[ 14, 1, 1, 0, 0 ]
[]
[]
[ "linux", "python", "tkinter", "ttk", "ubuntu" ]
stackoverflow_0028551948_linux_python_tkinter_ttk_ubuntu.txt
Q: Converting array in Pandas dataframe to a row I have 18x1 dataframe and all the rows of the dataframe have a an array of length 18. I want to convert the 18x1 dataframe to 18x18 dataframe by converting each array into 18 columns I am new to python, so any help would be appreciated A: If the size of the arrays is...
Converting array in Pandas dataframe to a row
I have 18x1 dataframe and all the rows of the dataframe have a an array of length 18. I want to convert the 18x1 dataframe to 18x18 dataframe by converting each array into 18 columns I am new to python, so any help would be appreciated
[ "If the size of the arrays is consistent, the simplest might be to convert to array, then back to DataFrame.\nAssuming \"col\" your column:\nimport numpy as np\ndf2 = pd.DataFrame(np.vstack(df['col']))\n\n# or\ndf2 = pd.DataFrame(df['col'].tolist())\n\nExample input (5x5 only):\ndf = pd.DataFrame({'col': [np.arange...
[ 0 ]
[]
[]
[ "dataframe", "pandas", "python" ]
stackoverflow_0074548152_dataframe_pandas_python.txt
Q: Pandas Create a Categorical Column After Condition I have a dataframe like this: DURATION CLUSTER COEFF 3 0 0.34 3 1 -0.005 3 2 1 3 3 0.33 4 0 -0.02 4 1 -0.28 4 2 0.22 4 3 0.48 ...
Pandas Create a Categorical Column After Condition
I have a dataframe like this: DURATION CLUSTER COEFF 3 0 0.34 3 1 -0.005 3 2 1 3 3 0.33 4 0 -0.02 4 1 -0.28 4 2 0.22 4 3 0.48 5 0 0.65 5 1 -0.26 5 ...
[ "Use groupby.rank and map:\nlabels = ['First', 'Second', 'Third', 'Fourth', 'Fifth']\ndf['RESULT'] = (df.groupby('DURATION')['COEFF']\n .rank('dense', ascending=False).sub(1)\n .map(dict(enumerate(labels)))\n )\n\nOutput:\n DURATION CLUSTER COEFF RESULT\n0 ...
[ 4, 1 ]
[]
[]
[ "dataframe", "pandas", "python" ]
stackoverflow_0074547779_dataframe_pandas_python.txt
Q: Python Cerberus JSON schema validation I have no clue why my code doesn't work, hence looking for some help. That's my sample JSON array: [ { "bookingid": 1774 }, { "bookingid": 1020 } ] and my code is as follows: def test_get_booking_ids_correct_schema(): schema = { "t...
Python Cerberus JSON schema validation
I have no clue why my code doesn't work, hence looking for some help. That's my sample JSON array: [ { "bookingid": 1774 }, { "bookingid": 1020 } ] and my code is as follows: def test_get_booking_ids_correct_schema(): schema = { "type": "array", "items": ...
[ "It's not possible to validate a document which is an array as root element. As you can see on : https://github.com/pyeve/cerberus/issues/220\nby the way, the type array didn't exist in the Cerberus schema, you should use list instead.\n" ]
[ 0 ]
[]
[]
[ "cerberus", "json", "python", "schema" ]
stackoverflow_0072791379_cerberus_json_python_schema.txt
Q: VS Code Python Formatting: Change max line-length with autopep8 / yapf / black I am experimenting with different python formatters and would like to increase the max line length. Ideally without editing the settings.json file. Is there a way to achieve that? A: For all three formatters, the max line length can b...
VS Code Python Formatting: Change max line-length with autopep8 / yapf / black
I am experimenting with different python formatters and would like to increase the max line length. Ideally without editing the settings.json file. Is there a way to achieve that?
[ "For all three formatters, the max line length can be increased with additional arguments passed in from settings, i.e.:\n\nautopep8 args: --max-line-length=120\nblack args: --line-length=120\nyapf args: --style={based_on_style: google, column_limit: 120, indent_width: 4}\n\nHope that helps someone in the future!\n...
[ 26, 0 ]
[]
[]
[ "formatting", "python", "visual_studio_code" ]
stackoverflow_0071078751_formatting_python_visual_studio_code.txt
Q: How to display button (Tkinter) red or green when we got 0 or 1 data? I have project for read and show data from text file. import os import io work_dir = "C:\\Users\\xxxxx\\labels" for index in range(191, 221): name = "CushionOK_{index}.txt".format(index=index) path = os.path.join(work_dir, name) wi...
How to display button (Tkinter) red or green when we got 0 or 1 data?
I have project for read and show data from text file. import os import io work_dir = "C:\\Users\\xxxxx\\labels" for index in range(191, 221): name = "CushionOK_{index}.txt".format(index=index) path = os.path.join(work_dir, name) with io.open(path, mode="r", encoding="utf-8") as fd: content = fd.re...
[ "I put all the widgets in one script as you asked for. As for me, it will work w/out using work_dir. But you can do by yourself.\nimport tkinter as tk\nimport os\nimport io\n\n\nroot = tk.Tk()\n\ndef confirm():\n work_dir = \"C:\\\\Users\\\\xxxxx\\\\labels\"\n\n for index in range(191, 221):\n name = \...
[ 0 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0071691081_python_tkinter.txt
Q: PyTest: ValueError: did not yield a value I just created a pytest fixture and i can't use yield, since it gives me an error I tried different stuff without success. What i'm doing wrong? @pytest.fixture def names_resp(): with open('ropo_resp.json', 'r') as names: global data data = json.load(na...
PyTest: ValueError: did not yield a value
I just created a pytest fixture and i can't use yield, since it gives me an error I tried different stuff without success. What i'm doing wrong? @pytest.fixture def names_resp(): with open('ropo_resp.json', 'r') as names: global data data = json.load(names) return data yield pri...
[ "Your fixture is expecting to yield something, even if it's None. But your yield is unreachable since you have return before it\n@pytest.fixture\ndef names_resp():\n with open('ropo_resp.json', 'r') as names:\n data = json.load(names)\n yield data\n print(\"a\")\n\n" ]
[ 1 ]
[]
[]
[ "pytest", "python", "python_3.x" ]
stackoverflow_0074548172_pytest_python_python_3.x.txt
Q: In python, how do I add a custom method to a class created by open() statement? I am trying to mock a service bus with text stream from file and want to be able to put some logic into complete_message() method. How do I define complete_message of whatever object is returned by open() so that below statement works?...
In python, how do I add a custom method to a class created by open() statement?
I am trying to mock a service bus with text stream from file and want to be able to put some logic into complete_message() method. How do I define complete_message of whatever object is returned by open() so that below statement works? receiver = open('mock\mock_queue.txt', "r") receiver.complete_message() I was looki...
[ "Are you looking for something like this?\nimport builtins\n\n\nclass File(object):\n\n def __init__(self, path, *args, **kwargs):\n self._fobj = builtins.open(path, *args, **kwargs)\n\n def read(self, n_bytes=-1):\n data = self._fobj.read(n_bytes)\n ...\n return data\n\n def co...
[ 0 ]
[]
[]
[ "python", "stream" ]
stackoverflow_0074547517_python_stream.txt
Q: How to reduce Cognitive Complexity in this Python method I am faced with a challenge. I have an Python method implemented and the SonarLint plugin of my PyCharm warns me with the message: "Refactor this function to reduce its Cognitive Complexity from 19 to the 15 allowed." but I can't see how to reduce the comple...
How to reduce Cognitive Complexity in this Python method
I am faced with a challenge. I have an Python method implemented and the SonarLint plugin of my PyCharm warns me with the message: "Refactor this function to reduce its Cognitive Complexity from 19 to the 15 allowed." but I can't see how to reduce the complexity. My Python method is: def position(key): if key == 'a...
[ "You can refactor this to look some thing like this:\ndef position(key):\n values =\"abcdefghijklmnñopq\"\n try:\n return values.index(key)\n except Exception as e:\n print(e) #you can use logger here if you want\n\n>>> position(\"a\")\n0\n>>> position(\"z\")\nsubstring not found\n\n", ...
[ 3, 1, 1, 0 ]
[]
[]
[ "pycharm", "python", "sonarlint" ]
stackoverflow_0074547365_pycharm_python_sonarlint.txt
Q: How to run multiple Python versions on Windows I had two versions of Python installed on my machine (versions 2.6 and 2.5). I want to run 2.6 for one project and 2.5 for another. How can I specify which I want to use? I am working on Windows XP SP2. A: Running a different copy of Python is as easy as starting t...
How to run multiple Python versions on Windows
I had two versions of Python installed on my machine (versions 2.6 and 2.5). I want to run 2.6 for one project and 2.5 for another. How can I specify which I want to use? I am working on Windows XP SP2.
[ "Running a different copy of Python is as easy as starting the correct executable. You mention that you've started a python instance, from the command line, by simply typing python. \nWhat this does under Windows, is to trawl the %PATH% environment variable, checking for an executable, either batch file (.bat), com...
[ 172, 142, 60, 57, 37, 20, 11, 11, 7, 5, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0 ]
[ "Using the Rapid Environment Editor you can push to the top the directory of the desired Python installation. For example, to start python from the c:\\Python27 directory, ensure that c:\\Python27 directory is before or on top of the c:\\Python36 directory in the Path environment variable. From my experience, the ...
[ -1, -1, -9 ]
[ "compatibility", "python", "windows" ]
stackoverflow_0004583367_compatibility_python_windows.txt
Q: How to make a Flask API on GCP run on https instead of http I have a flask API which is running on a google VM instance but currently it is running on http. So for instance, http://36.137.283.44:5000/get_values is the url for one endpoint where 36.137.283.44 is the external IP of the VM instance and 5000 is the po...
How to make a Flask API on GCP run on https instead of http
I have a flask API which is running on a google VM instance but currently it is running on http. So for instance, http://36.137.283.44:5000/get_values is the url for one endpoint where 36.137.283.44 is the external IP of the VM instance and 5000 is the port. I just want to the http to become https. I've seen some answe...
[ "You need to have the SSL certificate to run flask on https.\nOnce you have the private key and certificate pem files for the SSL.\nCopy it to the folder where you are the running the python API. Say you copied over the cert.pem and key.pem, to the API code folder then change the API code for the following line to...
[ 0 ]
[]
[]
[ "flask", "google_cloud_platform", "https", "python", "ssl_certificate" ]
stackoverflow_0067982448_flask_google_cloud_platform_https_python_ssl_certificate.txt
Q: What is the function to return the cash balance of an account? I am currently using the ibkr api with the ib_insync package and I was wondering how one would return the cash balance in an account. I've tried accountSummary and accountValues but can't seem to find it. A: If you mean this balance field You could ...
What is the function to return the cash balance of an account?
I am currently using the ibkr api with the ib_insync package and I was wondering how one would return the cash balance in an account. I've tried accountSummary and accountValues but can't seem to find it.
[ "If you mean this balance field\n\nYou could fetch it with iterating the account values (they are automatically synced with IB)\n[x.value for x in self._ib.accountValues() if x.tag == \"CashBalance\" and x.currency == \"USD\"][0]\n\n" ]
[ 0 ]
[]
[]
[ "ib_insync", "python" ]
stackoverflow_0072021941_ib_insync_python.txt
Q: SQLAlchemy ORM conversion to pandas DataFrame Is there a solution converting a SQLAlchemy <Query object> to a pandas DataFrame? Pandas has the capability to use pandas.read_sql but this requires use of raw SQL. I have two reasons for wanting to avoid it: I already have everything using the ORM (a good reason in a...
SQLAlchemy ORM conversion to pandas DataFrame
Is there a solution converting a SQLAlchemy <Query object> to a pandas DataFrame? Pandas has the capability to use pandas.read_sql but this requires use of raw SQL. I have two reasons for wanting to avoid it: I already have everything using the ORM (a good reason in and of itself) and I'm using python lists as part of...
[ "Below should work in most cases:\ndf = pd.read_sql(query.statement, query.session.bind)\n\nSee pandas.read_sql documentation for more information on the parameters.\n", "Just to make this more clear for novice pandas programmers, here is a concrete example,\npd.read_sql(session.query(Complaint).filter(Complaint....
[ 252, 142, 25, 18, 6, 5, 2, 0, 0, 0 ]
[]
[]
[ "flask_sqlalchemy", "pandas", "python", "sqlalchemy" ]
stackoverflow_0029525808_flask_sqlalchemy_pandas_python_sqlalchemy.txt
Q: OneDrive free up space with Python I have been using OneDrive to store a large amount of images and now I need to process those, so I have sync'd my OneDrive folder to my computer, which takes relatively no space on disk. However, since I have to open() them in my code, they all get downloaded, which would take mu...
OneDrive free up space with Python
I have been using OneDrive to store a large amount of images and now I need to process those, so I have sync'd my OneDrive folder to my computer, which takes relatively no space on disk. However, since I have to open() them in my code, they all get downloaded, which would take much more than the available memory on my ...
[ "According to this microsoft post it is possible to call Attrib.exe to do that sort of manipulation on files.\nThis little snippet does the job for a per-file usage. As shown in the linked post, it's also possible to do it on the full contents of a folder using the /s argument, and much more.\nimport subprocess\n\n...
[ 5, 2, 0 ]
[]
[]
[ "onedrive", "python" ]
stackoverflow_0056600252_onedrive_python.txt
Q: How can I create a list of dicts from multiple separate lists? say I have four separate lists like so: colors = ['red', 'blue', 'green', 'black'] widths = [10.0, 12.0, 8.0, 22.0] lengths = [35.5, 41.0, 36.5, 36.0] materials = ['steel', 'copper', 'iron', 'steel'] What's the best way to take this data and create a ...
How can I create a list of dicts from multiple separate lists?
say I have four separate lists like so: colors = ['red', 'blue', 'green', 'black'] widths = [10.0, 12.0, 8.0, 22.0] lengths = [35.5, 41.0, 36.5, 36.0] materials = ['steel', 'copper', 'iron', 'steel'] What's the best way to take this data and create a list of dicts representing objects like so: objects = [{'color': 're...
[ "This answer combines the use of a list-comprehension to easily create a list and the zip() built-in function that iterates over several iterables in parallel.\nobjects = [{\"color\": c, \"width\": w, \"length\": l, \"material\": m} for c, w, l, m in zip(colors, widths, lengths, materials)]\n\n", "Use the range f...
[ 3, 0, 0, 0 ]
[]
[]
[ "dictionary", "list", "python" ]
stackoverflow_0074548240_dictionary_list_python.txt
Q: How to check if a variable is binary in Python In order to check if a given list is constituted only by 0 and 1 values, I tried to set up a function returning True when the list is binary, while it returns False when not: My code def is_binary(y): for x in y: if x in [2,3,4,5,6,7,8,9]: retu...
How to check if a variable is binary in Python
In order to check if a given list is constituted only by 0 and 1 values, I tried to set up a function returning True when the list is binary, while it returns False when not: My code def is_binary(y): for x in y: if x in [2,3,4,5,6,7,8,9]: return False break else: ...
[ "I would turn around your logic.\ndef is_binary(y):\n for x in y:\n if x not in [0,1]:\n return False\n return True\n\nThe root of the problem is that you are returning the result at the first iteration round, because the return statement stops the execution of the function. This also makes...
[ 1, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0074548214_python.txt
Q: data not being fetched properly from a website I want to get the urls of the products from a particular website and then get more data thereafter (but I'm currently stuck here in just getting the urls) Here are what I tried: here are the modules I used import bs4 import pandas as pd import numpy as np import rando...
data not being fetched properly from a website
I want to get the urls of the products from a particular website and then get more data thereafter (but I'm currently stuck here in just getting the urls) Here are what I tried: here are the modules I used import bs4 import pandas as pd import numpy as np import random import requests from lxml import etree import time...
[ "Try this code, this will navigate to each page by page number, scroll down to the bottom, then fetch all the products' URLs.\nfor page in range(1, 10):\n driver.get(\"https://www.sephora.com/shop/skincare?currentPage=\"+str(page))\n while True:\n driver.execute_script(\"window.scrollBy(0, 800);\")\n ...
[ 0 ]
[]
[]
[ "beautifulsoup", "python", "selenium", "web_scraping" ]
stackoverflow_0074539720_beautifulsoup_python_selenium_web_scraping.txt
Q: Python Apache Beam TaggedOutput Not Working I'm having an issue with TaggedOutputs in Apache Beam (DataflowRunner) using Python 3.9. I've included the necessary pieces of code below for understanding. Basically the tagged output from parent_check_pipeline for Tag.REQS_SATISFIED) is not working. When the code in ...
Python Apache Beam TaggedOutput Not Working
I'm having an issue with TaggedOutputs in Apache Beam (DataflowRunner) using Python 3.9. I've included the necessary pieces of code below for understanding. Basically the tagged output from parent_check_pipeline for Tag.REQS_SATISFIED) is not working. When the code in CheckParentRequirements yields that tagged output...
[ "At a first glance, I see nothing wrong with your tagged outputs (assuming Tag.WHATEVER returns a string). However, I am a bit confused about the way you outsource pipeline parts. Usually, you would use PTransforms instead of simple python functions. That might be the source of your strange behavior.\nI would recom...
[ 1, 0 ]
[]
[]
[ "apache_beam", "google_cloud_dataflow", "python" ]
stackoverflow_0074492124_apache_beam_google_cloud_dataflow_python.txt
Q: Why am I getting a RuntimeWarning? I am using a dataframe looking like this: with those dtypes: priceNum float64 volumeNum float64 deliveryStart datetime64[ns, UTC] execution datetime64[ns, UTC] buySell object dtype: object I want to peform a...
Why am I getting a RuntimeWarning?
I am using a dataframe looking like this: with those dtypes: priceNum float64 volumeNum float64 deliveryStart datetime64[ns, UTC] execution datetime64[ns, UTC] buySell object dtype: object I want to peform a simple calculation using the volumeNum ...
[ "It looks to me like it is coming from adding a number to a NaN. You can do a broad sweep to fix this with .fillna() if you cannot otherwise prevent a NaN from populating those cells.\n" ]
[ 0 ]
[]
[]
[ "dataframe", "pandas", "python", "runtime" ]
stackoverflow_0074548314_dataframe_pandas_python_runtime.txt
Q: How to use value after checking if exists in a list using 'any' command python I am trying to check if an entered value is in a list of values and then use it if it does using the any command in an if statement. But for some reason when the command finished iterating through the list it won't let me use this value...
How to use value after checking if exists in a list using 'any' command python
I am trying to check if an entered value is in a list of values and then use it if it does using the any command in an if statement. But for some reason when the command finished iterating through the list it won't let me use this value.Can someone where do I neeed to change my code to make it work?. I want to print th...
[ "for key in publicKeys:\n if SHA3_256.new(key.export_key()).hexdigest() == hashed_pk:\n print(key)\n # Use `break` here if you want\n\n", "Instead of any use next, which retrieves the first value valid in a generator, and use the guard expression as a filter clause, this way:\nkey = next((key for...
[ 1, 1, 1, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0074548467_python.txt
Q: What's wrong with this code to find index of list of integers where sum of integers to the left equals the sum to the left? I am going to be given an array of integers. My job is to take that array and find an index N where the sum of the integers to the left of N is equal to the sum of the integers to the right o...
What's wrong with this code to find index of list of integers where sum of integers to the left equals the sum to the left?
I am going to be given an array of integers. My job is to take that array and find an index N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no index that would make this happen, return -1. My code is: def find_even_index(arr): #your code here f...
[ "So return returns from the function the moment it's run. You're doing the check and returning one thing or another every time - so if the first element doesn't evenly divide, you immediately return -1.\nYou need to only return false if you go through the entire list without finding a valid N.\nAfter you fix that y...
[ 0, 0 ]
[]
[]
[ "iteration", "python", "slice" ]
stackoverflow_0074548292_iteration_python_slice.txt
Q: How to encode and decode Arabic text in python I want to encode an Arabic string. I actually tried to pass the string as is, but it did not work. I tried to encode it and it also didn't work. Here is the code and the output: جاÙ\x85عة اÙ\x84Ù\x8aرÙ\x85Ù\x88Ù\x83 self.set_font("Arial","",11) self.set_text_c...
How to encode and decode Arabic text in python
I want to encode an Arabic string. I actually tried to pass the string as is, but it did not work. I tried to encode it and it also didn't work. Here is the code and the output: جاÙ\x85عة اÙ\x84Ù\x8aرÙ\x85Ù\x88Ù\x83 self.set_font("Arial","",11) self.set_text_color(15,164,12) self.set_y(2.0) str="جامعة اليرموك" ...
[ "If you're using Python3, you don't need to encode or decode anything. Strings are unicode by default:\n>>> title = \"جامعة المبروك\" \n>>> print(title)\nجامعة المبروك\n\nAs mentioned in the comments, you shouldn't use str as a variable name, because it's a built-in function in Python. (You can tell it's a built-in...
[ 0 ]
[]
[]
[ "arabic", "encoding", "pyfpdf", "python", "utf_8" ]
stackoverflow_0074479392_arabic_encoding_pyfpdf_python_utf_8.txt
Q: How to find the position of a string in another string without the find() and index() method? My task is to write a code that reproduces the str.find() method. I'm not allowed to use these: str.find(), str.index(), str.split(). So far I have: string = "haystack" if " needle " in (" " + string + " "): print(#he...
How to find the position of a string in another string without the find() and index() method?
My task is to write a code that reproduces the str.find() method. I'm not allowed to use these: str.find(), str.index(), str.split(). So far I have: string = "haystack" if " needle " in (" " + string + " "): print(#here I want to print the first index in which "needle" is in "haystack" else: print(„-1“))
[ "Assuming you are simply looking for a way to solve the problem at all (and not in a particularly efficient way), perhaps it would help to consider this type of logic (in pseudocode):\nfor index i in str\n if searchStr is in str starting at index i\n return i\nreturn -1\n\nwhere:\n\nstr is input string to searc...
[ 0 ]
[]
[]
[ "indexing", "loops", "python" ]
stackoverflow_0074547150_indexing_loops_python.txt
Q: Python: ValueError: I/O operation on closed file. Input/Output Lab In my Python lab, I need to ask the user how many numbers to store; have them enter said numbers individually and store them in a file named numbers1.txt. Then again, repeat this process but store the numbers in a file named numbers2.txt. From ther...
Python: ValueError: I/O operation on closed file. Input/Output Lab
In my Python lab, I need to ask the user how many numbers to store; have them enter said numbers individually and store them in a file named numbers1.txt. Then again, repeat this process but store the numbers in a file named numbers2.txt. From there I had to write some code that would read a line from one file and a li...
[ "Files must keep open in the loop while reading.\nwhile number1 != \"\" and number2 != \"\":\n scalar_product += int(number1) * int(number2)\n number1 = numfile1.readline()\n number2 = numfile2.readline()\n\n# close files at the end\nnumfile1.close()\nnumfile2.close()\n\n", "You are closing the files too...
[ 1, 0, 0 ]
[]
[]
[ "io", "python", "valueerror" ]
stackoverflow_0074547926_io_python_valueerror.txt
Q: Wrong Shape in Filter of Scipy.ndimage.filters.convolve I am trying to scipy convolve function but it shows an error that there is wrong shape of filter. I have a filter shape of (1, 3, 3, 1) and image shape of (10,8,8,3) I found a similar post but it has one less dimension which is not true in my case. Any idea...
Wrong Shape in Filter of Scipy.ndimage.filters.convolve
I am trying to scipy convolve function but it shows an error that there is wrong shape of filter. I have a filter shape of (1, 3, 3, 1) and image shape of (10,8,8,3) I found a similar post but it has one less dimension which is not true in my case. Any idea, how could I resolve this? Sample Code : from scipy import...
[ "I fixed it by adding cv2.IMREAD_GRAYSCALE while reading the image.\n cv2.imread(\"yourImage.jpg\", cv2.IMREAD_GRAYSCALE)\n OR\n cv2.imread(\"yourImage.jpg\",0) #loading graysclae image\n\n" ]
[ 0 ]
[]
[]
[ "keras", "loss_function", "python", "scipy", "tensorflow" ]
stackoverflow_0047234375_keras_loss_function_python_scipy_tensorflow.txt
Q: Inner merge two DataFrames on string partial match We have the following two data frames temp = pd.DataFrame(np.array([['I am feeling very well',1],['It is hard to believe this happened',0], ['What is love?',1], ['No new friends',0], ['I love this show...
Inner merge two DataFrames on string partial match
We have the following two data frames temp = pd.DataFrame(np.array([['I am feeling very well',1],['It is hard to believe this happened',0], ['What is love?',1], ['No new friends',0], ['I love this show',1],['Amazing day today',1]]), ...
[ "You can use:\nimport re\npattern = '|'.join(map(re.escape, temp_truncated['message']))\n\nkey = temp['message'].str.extract(f'({pattern})', expand=False)\n\nout = (temp\n .merge(temp_truncated.rename(columns={'message': 'sub'}),\n left_on=key, right_on='sub')\n .drop(columns='sub')\n)\n\nOutput:\n ...
[ 5, 0, 0 ]
[]
[]
[ "dataframe", "pandas", "python" ]
stackoverflow_0074548343_dataframe_pandas_python.txt
Q: Python seaborn histplot returns StopIteration I installed seaborn, but when I do the example from the Seaborn website, I get StopIteration message, how do I fix it? import seaborn as sns penguins = sns.load_dataset("penguins") sns.histplot(data=penguins, x="flipper_length_mm") StopIteration ...
Python seaborn histplot returns StopIteration
I installed seaborn, but when I do the example from the Seaborn website, I get StopIteration message, how do I fix it? import seaborn as sns penguins = sns.load_dataset("penguins") sns.histplot(data=penguins, x="flipper_length_mm") StopIteration Traceback (most recent call last) Cell In [33]...
[ "The problem seem to be in the default color definition function. If you specify a color you can skip the error:\nsns.histplot(data=penguins, x=\"flipper_length_mm\", color='blue')\n\nThat solved the problem for me, hope it does for you as well.\nCheers\n", "The problem is with matplotlib==3.6.1\nYou have 2 varia...
[ 0, 0 ]
[]
[]
[ "python", "seaborn", "stopiteration" ]
stackoverflow_0074104246_python_seaborn_stopiteration.txt
Q: Treeview: How to set values in a specific row where row contains "x" value? I have a treeview with the following columns: self.columns = ("Name", "Status", "Activity") This treeview is updated depending on the socket message and client name it receives. If the program receives "NAME:", it will insert a new row in...
Treeview: How to set values in a specific row where row contains "x" value?
I have a treeview with the following columns: self.columns = ("Name", "Status", "Activity") This treeview is updated depending on the socket message and client name it receives. If the program receives "NAME:", it will insert a new row in the treeview with the client name placed under the "Name" column. Else if it's "...
[ "Thanks to @acw1668, it turns out the cause of the error was a spelling mistake; in x = self.message.replace(\"CLOSED\", \"\") a : was missing.\nTo set the values of \"Status\" and \"Activity\" where the \"Name\" value is the same as the client name, the code is as follows:\nelif \"CLOSED:\" in self.message:\n x...
[ 1, 1 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0074546782_python_tkinter.txt
Q: Add an image (nparray) to a dictionary I created an empty dictionary in python. I'm reading images and processing them in a loop and after processing, the result is a numpy array. I'd like to add the nparray to the newly created dictionary and store a sequential integer as they key, and the array as the value. ...
Add an image (nparray) to a dictionary
I created an empty dictionary in python. I'm reading images and processing them in a loop and after processing, the result is a numpy array. I'd like to add the nparray to the newly created dictionary and store a sequential integer as they key, and the array as the value. How do I get started? In the end I'd like t...
[ "I'd like to add the nparray to the newly created dictionary and store a sequential integer as they key to me sounds like a list, where elements are already indexed with consecutive numbers.\nIf you want to use a dictionary:\n\n#init empty dictionary\nimg_dict = {} \nimg_n = 0\n\nfor imagesdir in os.listdir(folder)...
[ 1 ]
[]
[]
[ "arrays", "numpy", "python" ]
stackoverflow_0074548666_arrays_numpy_python.txt
Q: TypeError: 'module' object is not callable File "C:\Users\Administrator\Documents\Mibot\oops\blinkserv.py", line 82, in __init__ self.serv = socket(AF_INET,SOCK_STREAM) TypeError: 'module' object is not callable Why am I getting this error? I'm confused. What do you need to know to answer my question? A: so...
TypeError: 'module' object is not callable
File "C:\Users\Administrator\Documents\Mibot\oops\blinkserv.py", line 82, in __init__ self.serv = socket(AF_INET,SOCK_STREAM) TypeError: 'module' object is not callable Why am I getting this error? I'm confused. What do you need to know to answer my question?
[ "socket is a module, containing the class socket.\nYou need to do socket.socket(...) or from socket import socket:\n>>> import socket\n>>> socket\n<module 'socket' from 'C:\\Python27\\lib\\socket.pyc'>\n>>> socket.socket\n<class 'socket._socketobject'>\n>>>\n>>> from socket import socket\n>>> socket\n<class 'socket...
[ 762, 311, 126, 50, 37, 24, 8, 1, 1, 0, 0, 0 ]
[ "A simple way to solve this problem is export thePYTHONPATH variable enviroment. For example, for Python 2.6 in Debian/GNU Linux: \nexport PYTHONPATH=/usr/lib/python2.6`\n\nIn other operating systems, you would first find the location of this module or the socket.py file.\n", "check the import statements since a ...
[ -1, -3 ]
[ "python", "sockets" ]
stackoverflow_0004534438_python_sockets.txt
Q: Why `itertools.repeat` always generate the same random number? Compare the outputs of these two functions: from itertools import repeat def rand_list1(): l = lambda: np.random.rand(3) return list(repeat(l(), 5)) def rand_list2(): return [np.random.rand(3) for i in range(5)] We see that rand_list1 who...
Why `itertools.repeat` always generate the same random number?
Compare the outputs of these two functions: from itertools import repeat def rand_list1(): l = lambda: np.random.rand(3) return list(repeat(l(), 5)) def rand_list2(): return [np.random.rand(3) for i in range(5)] We see that rand_list1 who uses itetools.repeat always generates the same 3 numbers. why is th...
[ "There is a basic miscomprehension on how the language works in your question.\nWith the lambda expression, you simply create a new function named l.\nAt the moment you do l() Python will call the function - and it will return a value: it is the returned value that will be used in place of the expression l() in th...
[ 2, 0 ]
[]
[]
[ "functional_programming", "python" ]
stackoverflow_0074548570_functional_programming_python.txt
Q: "if string in" returning False I am creating a text based game for a Python class. I created a dictionary for my rooms and created a list for my directions: rooms = { 'Great Hall': { 'name': 'Great Hall', 'South': 'Bedroom' }, 'Bedroom': { 'name': 'Bedroom', 'North': 'Gr...
"if string in" returning False
I am creating a text based game for a Python class. I created a dictionary for my rooms and created a list for my directions: rooms = { 'Great Hall': { 'name': 'Great Hall', 'South': 'Bedroom' }, 'Bedroom': { 'name': 'Bedroom', 'North': 'Great Hall', 'East': 'Cellar' ...
[ "Let's reduce your problem down some more:\nIt seems to me this is all the code that is necessary to describe your problem:\n directions = ['South', 'North', 'East', 'West']\n command = 'South'\n if command in directions:\n print('This works as LaLoba expects')\n \n command = 'Go South'\n if command...
[ 3, 0 ]
[]
[]
[ "dictionary", "if_statement", "python" ]
stackoverflow_0074548659_dictionary_if_statement_python.txt
Q: How to save and read matrices with pandas I am trying to save and read matrices of different sizes with pd.to_csv command. The probleme is that pandas saves matrices in a string form, thus when I read the CSV file I don't retrive the matrices in their numerical form. import numpy as np import pandas as pd L = [] ...
How to save and read matrices with pandas
I am trying to save and read matrices of different sizes with pd.to_csv command. The probleme is that pandas saves matrices in a string form, thus when I read the CSV file I don't retrive the matrices in their numerical form. import numpy as np import pandas as pd L = [] for Dim in range(3,10): L.append(np.random....
[ "\\n appears when append is done, probably \"vector\" objects are converted to \"simple\". Therefore, I immediately converted the resulting numpy array into a dataframe, and then added it to the desired dataframe. For the data type, I used the experimental type, because the empty cells of the pandas were filled wit...
[ 0 ]
[]
[]
[ "csv", "pandas", "python", "read.csv", "save" ]
stackoverflow_0074546131_csv_pandas_python_read.csv_save.txt
Q: Task scheduler not run task with cmd prompt running background I am trying to run a particular program that uses os.system to run cmd commands from Task Scheduler. os.system('"C:\\Program Files\\BlueStacks_nxt\\HD-Player.exe" --instance Nougat32') os.system('cmd /c "adb start-server"') The code works perfectly wh...
Task scheduler not run task with cmd prompt running background
I am trying to run a particular program that uses os.system to run cmd commands from Task Scheduler. os.system('"C:\\Program Files\\BlueStacks_nxt\\HD-Player.exe" --instance Nougat32') os.system('cmd /c "adb start-server"') The code works perfectly when I run from my IDE. However, whenever I try to run the py file or ...
[ "It's possible that the os.system does work, but the process fails to run for some reason.\nCan you try to save the output of the terminal to a file and see if there is any output?\nTo do this you can your command with subprocess.Popen which gives you the stout and stderr of the command.\n" ]
[ 0 ]
[]
[]
[ "python", "windows_task_scheduler" ]
stackoverflow_0074500868_python_windows_task_scheduler.txt
Q: Why do python variables of same value point to the same memory address? I ran into an interesting case today wherein a = 10 b = 10 print (a is b) logged out True. I did some searching and came across the concept of interning. Now that explains why True is correct for the range [-5, 256]. However, I get the same r...
Why do python variables of same value point to the same memory address?
I ran into an interesting case today wherein a = 10 b = 10 print (a is b) logged out True. I did some searching and came across the concept of interning. Now that explains why True is correct for the range [-5, 256]. However, I get the same results even while using floats. Please help me understand why. Here is the pa...
[ "What you are looking at in your case is called \"constant folding\". That's an implementation detail, not a language specification - meaning there is no guarantee that this behaviour will remain the same and you should not rely on it in your code. But, in general it comes down to the fact that things that can be c...
[ 5 ]
[]
[]
[ "memory_management", "python" ]
stackoverflow_0074548693_memory_management_python.txt
Q: Why does python sounddevice returns nothing? I'm using wsl version 2 and Xlaunch to connect with x11 server. The problem is when I'm running this code: import sounddevice as sd print(sd.query_devices()) It returns nothing or even running $python3 -m sounddevice ,again returns nothing. what can be the problem? A:...
Why does python sounddevice returns nothing?
I'm using wsl version 2 and Xlaunch to connect with x11 server. The problem is when I'm running this code: import sounddevice as sd print(sd.query_devices()) It returns nothing or even running $python3 -m sounddevice ,again returns nothing. what can be the problem?
[ "You mention setting up Xlaunch (VcXsrv), but this only provides graphical support, not audio. PulseAudio is typically used to provide a connection between the Linux code running in WSL and the Windows audio source.\nWhile you can configure PulseAudio manually, I would recommend simply using the WSLg feature of WS...
[ 0 ]
[]
[]
[ "python", "python_sounddevice", "wsl_2" ]
stackoverflow_0074546184_python_python_sounddevice_wsl_2.txt
Q: How to make a function act as a generator only when used as one One existing example of this is open which can be used in these two ways: f = open("File") print(f.readline()) f.close() # ...and... with open("File") as f: print(f.readline()) I intend to create a version of the asyncio.Lock class which allows y...
How to make a function act as a generator only when used as one
One existing example of this is open which can be used in these two ways: f = open("File") print(f.readline()) f.close() # ...and... with open("File") as f: print(f.readline()) I intend to create a version of the asyncio.Lock class which allows you to not only acquire and release the lock manually but also to use ...
[ "The thing you look for isn't a generator, but a context manager.\nYou don't even need to implement one, This works:\nlock = asyncio.Lock()\n\nasync def example():\n async with lock:\n # Your code here\n\n", "For other people getting here: although the OP wanted something that already works out of the b...
[ 1, 1 ]
[]
[]
[ "generator", "python", "python_asyncio" ]
stackoverflow_0074542734_generator_python_python_asyncio.txt
Q: How to select every letter from every word? I'm trying to make my own OCR for Egyptian. This is my code: import keras from keras.models import load_model import seaborn as sn from sklearn.metrics import confusion_matrix import os import numpy as np from sklearn.utils import shuffle import matplotlib.pyplot as plt ...
How to select every letter from every word?
I'm trying to make my own OCR for Egyptian. This is my code: import keras from keras.models import load_model import seaborn as sn from sklearn.metrics import confusion_matrix import os import numpy as np from sklearn.utils import shuffle import matplotlib.pyplot as plt import tensorflow as tf from tqdm import tqdm imp...
[ "I know this is not the answer you want, but I think what you're trying to do here is too difficult — it's not the kind of thing a single person can cobble together.\nHere's the big issue: Even vanilla OCR for print, Standard Arabic is not a solved problem. I was recently trying out pdfplumber on a digital (not sca...
[ 2 ]
[]
[]
[ "arabic", "computer_vision", "machine_learning", "ocr", "python" ]
stackoverflow_0074257224_arabic_computer_vision_machine_learning_ocr_python.txt
Q: iteration over a Spark Dataframe and edit list from for loop I am currently working on a Python function.The process is supposed to loop over a pandas dataframe containing my data structure (I get the info of which table contains the value for a field I am looking for) and then loop over a spark dataframe that loa...
iteration over a Spark Dataframe and edit list from for loop
I am currently working on a Python function.The process is supposed to loop over a pandas dataframe containing my data structure (I get the info of which table contains the value for a field I am looking for) and then loop over a spark dataframe that loads the right table from the precedent loop and if the value for th...
[ "You can filter the dataframe, with something like this:\ndf_table.filter(f\"{field} = {id_p}\").filter(f\"{field} NOT IN {list_drop}\")\nThen it's depends on the size of this filtering:\n\n(Big) you could save the results on disk for each dataframe (df.write methods), and read that back with spark.\n(Small) Or you...
[ 0 ]
[]
[]
[ "apache_spark", "for_loop", "pandas", "pyspark", "python" ]
stackoverflow_0074547837_apache_spark_for_loop_pandas_pyspark_python.txt
Q: How to control spces and page break in docxtpl (based on exist docx template)? I created a docx template and then generated the python code to update variable and all the other data into this template using python's docxtpl package as: tpl = DocxTemplate((path.join('report','templates','my_template.docx'))) tpl....
How to control spces and page break in docxtpl (based on exist docx template)?
I created a docx template and then generated the python code to update variable and all the other data into this template using python's docxtpl package as: tpl = DocxTemplate((path.join('report','templates','my_template.docx'))) tpl.new_subdoc() file_path = path.join(output_dir_name, file_name) get_all_data_report...
[ "from docxtpl import *\ntpl = DocxTemplate('templates/escape_tpl.docx')\ncontext = {'myvar': R('\"less than\" must be escaped : <, this can be done with RichText() or R()'),\n 'myescvar': 'It can be escaped with a \"|e\" jinja filter in the template too : < ',\n 'nlnp': R('Here is a multiple\\nlines\\ns...
[ 4, 0 ]
[ "You can put conditional page break of space. \nStep to do : \n\nOpen documents in Microsoft word open documents\nClick on Home then click (Ctrl+*) or quote symbol\nYou will find all page break and spaces like screenshot\nThen add conditional statement like show in screenshot\n\n", "I already found the solution y...
[ -1, -1 ]
[ "docx", "python", "python_docx" ]
stackoverflow_0055656280_docx_python_python_docx.txt
Q: How this Python Numpy ndarray slicing is working? I wish to understand a piece of code that I have seen in python. enter image description here in my particular case, face is a list and when the code is executed x is 739 y is 229 w is 232 h is 349 image is a numpy.ndarray, I wanted to understand how the slicing of...
How this Python Numpy ndarray slicing is working?
I wish to understand a piece of code that I have seen in python. enter image description here in my particular case, face is a list and when the code is executed x is 739 y is 229 w is 232 h is 349 image is a numpy.ndarray, I wanted to understand how the slicing of image is acctually working... which part of the image ...
[ "To slice a multi-dimensional array, you specify a standard slicing range (with up to 3 arguments seperated by :) for each dimension, and seperate the ranges with a ,.\nIn this example, the array is sliced in the range of y up to y + h on one dimension, and x to x + w on the other.\nread this if for more examples\n...
[ 0 ]
[]
[]
[ "numpy_ndarray", "python" ]
stackoverflow_0074548943_numpy_ndarray_python.txt
Q: python open new window idk what to do when i define a function it dosent wanna use it in a button command NameError: name 'openNewWindow' is not defined. Did you mean: 'PanedWindow' idk whats the problem from tkinter import* win = Tk() win.title("igra") win.config(bg = "black") win.overrideredirect(True) win.geo...
python open new window
idk what to do when i define a function it dosent wanna use it in a button command NameError: name 'openNewWindow' is not defined. Did you mean: 'PanedWindow' idk whats the problem from tkinter import* win = Tk() win.title("igra") win.config(bg = "black") win.overrideredirect(True) win.geometry("{0}x{1}+0+0".format(...
[ "Is this is what you want? I rearranged code. I moved function before widgets.\nTry this:\nfrom tkinter import*\n\n\nwin = Tk()\n\nwin.title(\"igra\")\nwin.config(bg = \"black\")\n#win.overrideredirect(True)\nwin.geometry(\"1080x900\")\n\n\ndef openNewWin():\n openNewWin = Toplevel(win)\n openNewWin.geometry(...
[ 0 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0071664543_python_tkinter.txt
Q: Resolving "The terminal shell CWD "/mnt/c/Users/User/Downloads/IG-Bot/C:\Users\User\VSC" does not exist error message I was trying to build an Instagram Bot using visual studio code python and WSL, (Windows Subsystem for Linux) when I decided to begin by opening a terminal window in Visual Studio Code and I got th...
Resolving "The terminal shell CWD "/mnt/c/Users/User/Downloads/IG-Bot/C:\Users\User\VSC" does not exist error message
I was trying to build an Instagram Bot using visual studio code python and WSL, (Windows Subsystem for Linux) when I decided to begin by opening a terminal window in Visual Studio Code and I got the error "The terminal shell CWD "/mnt/c/Users/User/Downloads/IG-Bot/C:\Users\User\VSC" does not exist" message not sur...
[ "Make sure to use the WSL - Remote extension as that will make sure VS Code acts like you're working under Linux. Otherwise you end up in a situation like you're in where VS Code thinks you're trying to work under Windows.\n", "I have encountered this issue when connecting to a remote host via SSH. The connection...
[ 1, 0 ]
[]
[]
[ "linux", "powershell", "python", "visual_studio_code" ]
stackoverflow_0062263311_linux_powershell_python_visual_studio_code.txt
Q: Repeated rows in a numpy array I feel like I'm going insane because I can't figure out what feels like should be a simple problem! I want to generate fake data in a numpy array and I can't figure out how to repeat a row of observations. I'd rather generate thousands of rows and I can't figure out how to repeat a r...
Repeated rows in a numpy array
I feel like I'm going insane because I can't figure out what feels like should be a simple problem! I want to generate fake data in a numpy array and I can't figure out how to repeat a row of observations. I'd rather generate thousands of rows and I can't figure out how to repeat a row whenever I feel like. For example...
[ "Use np.repeat():\nvoters = np.array([['row1', 'row1', 'row1'],\n ['row2', 'row2', 'row2']])\n\n# We repeat 2 times the first row and 4 times the second row.\nnp.repeat(voters,[2,4],axis=0)\n# voters.repeat([2,4],axis=0) produce the same result.\n\nAnd we obtain:\narray([['row1', 'row1', 'row1'],\...
[ 3, 1 ]
[]
[]
[ "numpy", "python" ]
stackoverflow_0074548612_numpy_python.txt
Q: mysql command is not found in terminal mac I want to use mysql to get the access to google cloud and link it to python but i faced this message in terminal How can i download mysql command ? i already download the mysql shell but still this message appear. rag@rags-MacBook-Pro ~ % mysql --version zsh: command not ...
mysql command is not found in terminal mac
I want to use mysql to get the access to google cloud and link it to python but i faced this message in terminal How can i download mysql command ? i already download the mysql shell but still this message appear. rag@rags-MacBook-Pro ~ % mysql --version zsh: command not found: mysql --version
[ "To install mysql on mac, follow the official guide: https://dev.mysql.com/doc/mysql-macos-excerpt/5.7/en/macos-installation.html .\nAfter mysql is installed this way, you might still have to add the path to it to ~/.zshrc in order to be able to use that command from zsh.\nTo add the path to ~/.zshrc you can:\n\nna...
[ 2, 1, 0 ]
[]
[]
[ "mysql", "python" ]
stackoverflow_0071156432_mysql_python.txt
Q: How to add several AxesSubplot instances into a subplot I've called an instance method four times, and each time an instance of the Matplotlib class AxesSubPlot is returned. I'm slowly getting to grips with Matplotlib, but I'm unsure how I render the four separate instances of AxesSubPlot as a MatplotLib subplot o...
How to add several AxesSubplot instances into a subplot
I've called an instance method four times, and each time an instance of the Matplotlib class AxesSubPlot is returned. I'm slowly getting to grips with Matplotlib, but I'm unsure how I render the four separate instances of AxesSubPlot as a MatplotLib subplot of 2x2. In short: if something returns an AxesSubplot instance...
[ "You can reference each AxesSubplot instance like so:\nimport matplotlib.pyplot as plt\n\nfig, ax = plt.subplots(2, 2)\nprint(ax)\nax[0, 0].annotate(\"Upper Left\", (0.5, 0.5))\nax[0, 1].annotate(\"Upper Right\", (0.5, 0.5))\nax[1, 0].annotate(\"Lower Left\", (0.5, 0.5))\nax[1, 1].annotate(\"Lower Right\", (0.5, 0....
[ 0, 0 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0074283198_matplotlib_python.txt
Q: How to devide each value of a column of a numpy array by a value I have a numpy array Y_test_traInv_RMSE with 3 columns, as you can see in the screenshot Now I would like to devide the each value of the third column (index 2) by the value 4700. I tried the following commands but none of them helped: Y_test_traInv_...
How to devide each value of a column of a numpy array by a value
I have a numpy array Y_test_traInv_RMSE with 3 columns, as you can see in the screenshot Now I would like to devide the each value of the third column (index 2) by the value 4700. I tried the following commands but none of them helped: Y_test_traInv_RMSE [2] [:] = Y_test_traInv_RMSE [2] [:] /4700 Y_test_traInv_RMSE [:]...
[ "Your third option should work. At least it works with this test data, so maybe you have another issue.\ntest = np.arange(30).astype(float).reshape(10, 3)\nprint(test)\ntest[:,2] = test[:,2] / 4700\nprint(test)\n\n" ]
[ 1 ]
[]
[]
[ "numpy", "python" ]
stackoverflow_0074548724_numpy_python.txt
Q: Plotting points on one line in python. 1 dimension This is the kind of graph that I would like to plot, without y axis . How can I achieve this in python using matplotlib if possible. A: Sadly there is not built-in fonction in matplotlib to create such a graph. However, You can use the following code to have a s...
Plotting points on one line in python. 1 dimension
This is the kind of graph that I would like to plot, without y axis . How can I achieve this in python using matplotlib if possible.
[ "Sadly there is not built-in fonction in matplotlib to create such a graph.\nHowever, You can use the following code to have a similar output. This snippet is removing unwanted spines (left, right and top) and then using scatterplot to simulate a 1d graph.\nAs Follows:\nfrom matplotlib import pyplot as plt\nimport ...
[ 1 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0074548385_matplotlib_python.txt
Q: How can I shortern if, elif, elif statements in Python How can I make the following code short: q=0.34 density='' if abs(q) ==0: density='Null' elif abs(q) <= 0.09: density='negligible' elif abs(q) <= 0.49: density='slight' elif abs(q) <= 0.69: density='strong' ...
How can I shortern if, elif, elif statements in Python
How can I make the following code short: q=0.34 density='' if abs(q) ==0: density='Null' elif abs(q) <= 0.09: density='negligible' elif abs(q) <= 0.49: density='slight' elif abs(q) <= 0.69: density='strong' else: density='very strong' print(q,", ", densit...
[ "You can try something like that:\ndef f(q):\n # List of your limits values and their density values\n values = [(0, \"Null\"), (0.09, \"negligible\"), (0.49, \"slight\"), (0.69, \"strong\")]\n # Default value of the density, i.e. your else statement\n density = \"very strong\"\n\n # Search the good ...
[ 2, 1, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0074548574_python.txt
Q: How do I show text from a third dataframe column when hovering over a line chart made from 2 other columns? So I have a dataframe with 3 columns: date, price, text import pandas as pd from datetime import datetime import random columns = ('dates','prices','text') datelist = pd.date_range(datetime.today(), periods...
How do I show text from a third dataframe column when hovering over a line chart made from 2 other columns?
So I have a dataframe with 3 columns: date, price, text import pandas as pd from datetime import datetime import random columns = ('dates','prices','text') datelist = pd.date_range(datetime.today(), periods=5).tolist() prices = [] for i in range(0, 5): prices.append(random.randint(50, 60)) text =['AAA','BBB','CCC'...
[ "You could use Plotly.\nimport plotly.graph_objects as go\n\nfig = go.Figure(data=go.Scatter(x=df['dates'], y=df['price'], mode='lines+markers', text=df['text']))\nfig.show()\n\n", "You should be aware that cursor & dataframe indexing will probably work well with points on a scatter plot, but it is a little bit t...
[ 1, 0 ]
[]
[]
[ "matplotlib", "pandas", "plotly_python", "python" ]
stackoverflow_0074548257_matplotlib_pandas_plotly_python_python.txt
Q: Why are python dates such a mess and what can I do about it? A common source of errors in my Python codebase are dates. Specifically, the different implementations of dates and datetimes, and how comparisons are handled between them. These are the date types in my codebase import datetime import pandas as pd impo...
Why are python dates such a mess and what can I do about it?
A common source of errors in my Python codebase are dates. Specifically, the different implementations of dates and datetimes, and how comparisons are handled between them. These are the date types in my codebase import datetime import pandas as pd import polars as pl x1 = pd.to_datetime('2020-10-01') x2 = datetime....
[ "All listed types can be converted to numpy datetime64. If you don't need more than seconds resolution, you might set the unit to 's' (optional). Ex:\n# Python datetime.datetime\nx2_np = np.datetime64(x2.replace(tzinfo=None), 's')\nprint(x2_np, repr(x2_np))\n# 2020-10-01T00:00:00 numpy.datetime64('2020-10-01T00:00:...
[ 1 ]
[]
[]
[ "date", "datetime", "numpy", "pandas", "python" ]
stackoverflow_0074547208_date_datetime_numpy_pandas_python.txt
Q: Create a multiplication table application where user will enter a sentinel value n and the application will display the mathematical multiplication tables till given sentinel value n. For example, if user enters n = 4 then application will display the multiplication tables of 2, 3, and 4. Constraint:  Make use of...
Create a multiplication table application
where user will enter a sentinel value n and the application will display the mathematical multiplication tables till given sentinel value n. For example, if user enters n = 4 then application will display the multiplication tables of 2, 3, and 4. Constraint:  Make use of oop concepts class methods and attributes DISP...
[]
[]
[ "class tables:\ndef tables (self ,n value):\nfor x in range(2, n value + 1):\nprint(\"\\n\",\" TABLE OF \",x,\"\\n\")\nfor y in range(1, 11):\nprint(x,\" x\", y,\"=\",x*y)\nn value=in t(input(\"enter a value:\"))\nf=tables()\nf. tables(n value)\n" ]
[ -1 ]
[ "oop", "python" ]
stackoverflow_0074541913_oop_python.txt
Q: Command runs in discord.py, but does not send embed and gives no error I ran into a strange problem on discord.py where. The rest of it works, but it does not reply with my embed with no errors. This is the code that wont work: #The code if the number is incorrect print(arg1) placement = sessions.index(ctx.aut...
Command runs in discord.py, but does not send embed and gives no error
I ran into a strange problem on discord.py where. The rest of it works, but it does not reply with my embed with no errors. This is the code that wont work: #The code if the number is incorrect print(arg1) placement = sessions.index(ctx.author.id) placement = +1 if arg1 != str(sessions[placement]): if...
[ "Try Ctx.send or Ctx.message.reply\nI use Colour name in embeds try to change that too\n" ]
[ 0 ]
[]
[]
[ "discord.py", "python" ]
stackoverflow_0074548681_discord.py_python.txt
Q: What is a "callable"? Now that it's clear what a metaclass is, there is an associated concept that I use all the time without knowing what it really means. I suppose everybody made once a mistake with parenthesis, resulting in an "object is not callable" exception. What's more, using __init__ and __new__ lead to...
What is a "callable"?
Now that it's clear what a metaclass is, there is an associated concept that I use all the time without knowing what it really means. I suppose everybody made once a mistake with parenthesis, resulting in an "object is not callable" exception. What's more, using __init__ and __new__ lead to wonder what this bloody __...
[ "A callable is anything that can be called. \nThe built-in callable (PyCallable_Check in objects.c) checks if the argument is either:\n\nan instance of a class with a __call__ method or\nis of a type that has a non null tp_call (c struct) member which indicates callability otherwise (such as in functions, methods e...
[ 351, 91, 44, 39, 11, 10, 7, 6, 4, 4, 2, 0, 0 ]
[]
[]
[ "callable", "python" ]
stackoverflow_0000111234_callable_python.txt
Q: Checking if a value exists in one template so that I can create a notification in another template I have a bootstrap card that holds a list of information and within that information there is a boolean value. If that value is true, I'd like to show some kind of notification on the card. Here is what it looks like...
Checking if a value exists in one template so that I can create a notification in another template
I have a bootstrap card that holds a list of information and within that information there is a boolean value. If that value is true, I'd like to show some kind of notification on the card. Here is what it looks like So if in one of those links there is a value that is true, I'd like something notifying the user that ...
[ "You can try the following in the nested loop:\n{% for info in object.prop_infos.all %}\n <ul id=\"list\">\n {% if info.winter_mode and info.instln_confirmed %}\n <p>Everything is right</p>\n {% else %}\n <p> something went wrong.</p>\n {% endif %}\n <li>{{ info....
[ 0 ]
[]
[]
[ "bootstrap_5", "django", "python" ]
stackoverflow_0074548924_bootstrap_5_django_python.txt
Q: How to search and replace a specific value in a line in Python I have a text file that has some values as follows: matlab.file.here.we.go{1} = 50 matlab.file.here.sxd.go{1} = 50 matlab.file.here.asd.go{1} = 50 I want the code to look for "matlab.file.here.sxd.go{1}" and replace the value assigned to it from 50 to...
How to search and replace a specific value in a line in Python
I have a text file that has some values as follows: matlab.file.here.we.go{1} = 50 matlab.file.here.sxd.go{1} = 50 matlab.file.here.asd.go{1} = 50 I want the code to look for "matlab.file.here.sxd.go{1}" and replace the value assigned to it from 50 to 1. But I want it to be dynamic (i.e., later I will have over 20 val...
[ "You can split on the equal sign. You can read and write files at the same time.\nimport os\nfile_path = r'test\\testfile.txt'\nfile_path_temp = r'test\\testfile.txt.TEMP'\nnew_value = 50\nchanging = 'matlab.file.here.we.go{1} = 1'\nwith open(file_path, 'r') as rf, open(file_path_temp, 'w') as wf:\n for line in ...
[ 1 ]
[]
[]
[ "python", "readline", "text" ]
stackoverflow_0074548827_python_readline_text.txt
Q: Calculating total number of values based on same id in pandas dataframe I have a dataframe that looks like this: api_spec_id commitdates commits Year-Month API Age info_version 84 2014-12-15 110 2014-12 110 6.0.1 84 2014-11-06 33 2014-...
Calculating total number of values based on same id in pandas dataframe
I have a dataframe that looks like this: api_spec_id commitdates commits Year-Month API Age info_version 84 2014-12-15 110 2014-12 110 6.0.1 84 2014-11-06 33 2014-11 33 6.0.2 84 2014-10-15 110 2014-10 ...
[ "You can use pd.groupby and nunique for this:\ndf['Total_versions'] = df.groupby('api_spec_id').info_version.transform('nunique')\n\nIt counts the number of unique values in the column 'info_version' for each 'api_spec_id'.\nOutput:\napi_spec_id commitdates commits Year-Month API_Age info_version Total_versions...
[ 2 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074549239_pandas_python.txt
Q: Creating relations between countries in neo4j using python I need help with creating relations between countries in neo4j using python. I have a code, but in neo4j browser it doesn't create relations. from neo4j import GraphDatabase driver = GraphDatabase.driver("neo4j://localhost:7687", ...
Creating relations between countries in neo4j using python
I need help with creating relations between countries in neo4j using python. I have a code, but in neo4j browser it doesn't create relations. from neo4j import GraphDatabase driver = GraphDatabase.driver("neo4j://localhost:7687", auth=("neo4j", "test")) def create_country(tx, name,contine...
[ "You are getting duplicates because merge will create more bcountry even if it exists already. Please use below new query.\nFunction: create_bordering_country\nOld code:\n MATCH (a:Country) WHERE a.name = $name \n MERGE (a)-[:HAS_BORDER_WITH]-(:Country {name: $bcountry}) \n RETURN DISTINCT a.name\n\nNew code:\n MER...
[ 1, 0 ]
[]
[]
[ "foreach", "neo4j", "python", "relation" ]
stackoverflow_0074537662_foreach_neo4j_python_relation.txt
Q: Split the single column to 4 different separate columns in Dataframe I just need need to split a single column of dataframe to 4 different columns. I tried few steps but didn't worked. DATA1: Dump 12525 2 153 89-8 Winch 24798 1 147 65-4 Gear 65116 4 Screw 46456 1 Rowing 46563 5 ...
Split the single column to 4 different separate columns in Dataframe
I just need need to split a single column of dataframe to 4 different columns. I tried few steps but didn't worked. DATA1: Dump 12525 2 153 89-8 Winch 24798 1 147 65-4 Gear 65116 4 Screw 46456 1 Rowing 46563 5 Nut Expected1: Item Qty Part_no Description ...
[ "You could match the data format of the Part_no column in a capture group and make the data in that group optional to keep 4 columns.\n(\\d+)\\s+(\\S+)\\s+((?:\\d+\\s+\\d+-\\d+)?\\s*)(.+)$\n\nRegex demo\nExample with named capture groups and str.extractall\nimport pandas as pd\n\npattern = r'(?m)(?P<Item>\\d+)\\s+(...
[ 0 ]
[]
[]
[ "dataframe", "pandas", "python", "regex" ]
stackoverflow_0074549107_dataframe_pandas_python_regex.txt
Q: How to return a list with a certain parameter from an API? I need to return a list with the the title ("titulo") of the news that appear in this api: https://www.publico.pt/api/list/ultimas I tried this but it only returns the title of the title (titulo) of the first new and not all the titles. import requests de...
How to return a list with a certain parameter from an API?
I need to return a list with the the title ("titulo") of the news that appear in this api: https://www.publico.pt/api/list/ultimas I tried this but it only returns the title of the title (titulo) of the first new and not all the titles. import requests def get_news(): url = "https://www.publico.pt/api/list/ul...
[ "i think this might be what you actually want to do:\nurl = \"https://www.publico.pt/api/list/ultimas\"\n\nresponse = requests.get(url)\ndata = response.json()\ntitulo = []\nfor news in data: \n titulo.append(news[\"titulo\"]) \n \nreturn titulo\n\nthis puts all the data into a list and returns the list.\...
[ 0 ]
[]
[]
[ "api", "list", "python" ]
stackoverflow_0074549288_api_list_python.txt
Q: Permutations between 2 lists From 2 list i would like to know an optimal way in Python to do a sort of "indexed permutation". This is how this would look like : input : list2 = [3,4,5] list1 = [0,1,2] output [[0,1,2], [0,1,5], [0,4,2], [3,1,2], [3,4,5], [3,4,2], [3,1,5], [0,4,5], ] So each element of the l...
Permutations between 2 lists
From 2 list i would like to know an optimal way in Python to do a sort of "indexed permutation". This is how this would look like : input : list2 = [3,4,5] list1 = [0,1,2] output [[0,1,2], [0,1,5], [0,4,2], [3,1,2], [3,4,5], [3,4,2], [3,1,5], [0,4,5], ] So each element of the lists remains in the same index.
[ "You basically want two variables: list_to_pick, which can vary in range(number_of_lists), and index_to_swap which can vary in the range(-1, len(list1)). Then, you want the product of these two ranges to decide which list to pick, and which item to swap. When index_to_swap is -1, we won't swap any items\nimport ite...
[ 1 ]
[]
[]
[ "python", "python_itertools" ]
stackoverflow_0074549211_python_python_itertools.txt
Q: how to change the position of dropdown using tkinter im trying to make a simple dropdown gui,but i need some help on how to position the dropdown menu , the full code is : import tkinter as tk from tkinter import * root=tk.Tk() canvas1 = tk.Canvas(root, width = 400, height = 300) canvas1.pack() username = tk.E...
how to change the position of dropdown using tkinter
im trying to make a simple dropdown gui,but i need some help on how to position the dropdown menu , the full code is : import tkinter as tk from tkinter import * root=tk.Tk() canvas1 = tk.Canvas(root, width = 400, height = 300) canvas1.pack() username = tk.Entry(root) canvas1.create_window(200,140, window=userna...
[ "You just need to add this statement canvas1.create_window(250,250, window=w) at the end of this code:\nfrom Tkinter import *\n\nmaster = Tk()\n\nvariable = StringVar(master)\nvariable.set(\"one\") # default value\n\nw = OptionMenu(master, variable, \"one\", \"two\", \"three\")\nw.pack()\n\n", "You can change pos...
[ 0, 0 ]
[]
[]
[ "python", "python_3.x", "tkinter" ]
stackoverflow_0058959423_python_python_3.x_tkinter.txt
Q: Python: how to form the correct list This is my data looks like my_list = [('Australia',), ('Europe',)] I need to remove the comma "," after every element. new_list = [('Australia'), ('Europe')] I can achieve this using a loop and extracting one element at a time and replacing it. Is there a better way to achieve ...
Python: how to form the correct list
This is my data looks like my_list = [('Australia',), ('Europe',)] I need to remove the comma "," after every element. new_list = [('Australia'), ('Europe')] I can achieve this using a loop and extracting one element at a time and replacing it. Is there a better way to achieve the same. Thank you
[ "That comma, indicates that you have a tuple. If you want to not have that comma, you can change tuples to lists:\nnew_list = [list(country) for country in my_list]\n\nIt gives You:\n[['Australia'], ['Europe']]\n\n", "my_list = [('Australia',), ('Europe',)]\n# lambda create a function and returns first value of x...
[ 0, 0 ]
[]
[]
[ "arrays", "list", "python", "replace", "trim" ]
stackoverflow_0074549120_arrays_list_python_replace_trim.txt
Q: This calculator program does not give an answer it just repeats. How do I fix it? I wrote this simple calculator program to ask for two numbers and then perform a certain action on them like dividing the first by the second etc. I implemented it in a big while loop that is repeated if the user chooses to repeat it...
This calculator program does not give an answer it just repeats. How do I fix it?
I wrote this simple calculator program to ask for two numbers and then perform a certain action on them like dividing the first by the second etc. I implemented it in a big while loop that is repeated if the user chooses to repeat it after a calculation. However, after the user enters the operation they want to perform...
[ "Problem lies in the valid variable.\nYou define it as 3 before the first iteration.\nThen, inside the second while loop, it is reduced to 0 by\nvalid -= 3\nAnd you never restore the starting value. So, the program comes back to the operation input, reads the loop condition:\n while valid > 0:\nAnd omits it, a...
[ 0 ]
[]
[]
[ "calculator", "python" ]
stackoverflow_0074397026_calculator_python.txt
Q: Pandas: Incorrect Result when multiplying two columns I am going through the Pandas-Kaggle information here: DataSet https://www.dropbox.com/s/16cwjq5ibtcmzgi/Lookup211.csv?dl=0 Action I want to take I want to combine the two columns. Issue I am getting But for some reason, even simple multiplication is not yieldi...
Pandas: Incorrect Result when multiplying two columns
I am going through the Pandas-Kaggle information here: DataSet https://www.dropbox.com/s/16cwjq5ibtcmzgi/Lookup211.csv?dl=0 Action I want to take I want to combine the two columns. Issue I am getting But for some reason, even simple multiplication is not yielding the correct value. This is what i have wine.points_norma...
[ "I can not reproduce your error, to mee seems fine. Seems like a cliche for IT but try to restar your kernel if you are in Jupyter notebook:\nwith \"Restart & Clear Output\" + \"Restar & Run All\"\n\n", "I experienced a similar issue and got 'RuntimeWarning: overflow encountered in ushort_scalars' when I ran the ...
[ 0, 0 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0071973393_pandas_python.txt
Q: Does TDengine Python connector support executemany? I'm currently using TDengine and Python to store time-series data. I tried Python connector. conn = taos.connect() conn.execute(“…”) It’s OK. However, the performance is not very good. Does TDengine Python connector support executemany and binding parameters?...
Does TDengine Python connector support executemany?
I'm currently using TDengine and Python to store time-series data. I tried Python connector. conn = taos.connect() conn.execute(“…”) It’s OK. However, the performance is not very good. Does TDengine Python connector support executemany and binding parameters? Or is there another way to improve performance?
[ "Article on improving the performance of data writing into TDengine.\nAppears a combination of batch writes and multi-thread parallel writing with certain limits can improve speed but that will depend on your run environment.\nBefore you do anything I'd put some decent profiling in place so you know if you're getti...
[ 1 ]
[]
[]
[ "database", "python", "tdengine" ]
stackoverflow_0074549390_database_python_tdengine.txt
Q: find pattern substring using python re I am trying to find all substrings within a multi string in python 3, I want to find all words in between the word 'Colour:': example string: str = """ Colour: Black Colour: Green Colour: Black Colour: Red Colour: Orange Colour: Blue Colour: Green """ I want to get all of th...
find pattern substring using python re
I am trying to find all substrings within a multi string in python 3, I want to find all words in between the word 'Colour:': example string: str = """ Colour: Black Colour: Green Colour: Black Colour: Red Colour: Orange Colour: Blue Colour: Green """ I want to get all of the colours into a list like: x = ['Black', 'G...
[ "In regex, the dot . does not match new line by default. This mean your program is trying to find something like \"Color: blueColor\".\nTo overcome this, you can just do something like :\ncolours = re.findall(r'Colour: (.+)', str)\n\nNote the use of re.findall to avoid using the list comprehension.\nFurthermore, if...
[ 1, 0, 0 ]
[]
[]
[ "python", "python_3.x", "python_re" ]
stackoverflow_0074549121_python_python_3.x_python_re.txt
Q: How to make a search-engine using tkinter in python? I tried on making a gui-based search engine in python, but for some reason I am facing two errors. I am unable to locate the 'Search' button even though I have added it in code. (I think so) Due to not being able to use the search button I am unable to find any...
How to make a search-engine using tkinter in python?
I tried on making a gui-based search engine in python, but for some reason I am facing two errors. I am unable to locate the 'Search' button even though I have added it in code. (I think so) Due to not being able to use the search button I am unable to find any search results even after pressing enter. ###Edit After ...
[ "this two things must be canged to run your code ok:\n\nstructure.geometry(\"1230*1230\")\n\nwill become: 'structure.geometry(\"1230x1230\")'\n\nbutton=Button(structure,text=\"Search\",font=(\"Times\",15,\"bold\"),width=30,bd=2,bg=\"white\",command=search)\n\nwill become: 'button=Button(structure,text=\"Search\",fo...
[ 0 ]
[]
[]
[ "error_handling", "python", "search_engine", "tkinter" ]
stackoverflow_0074542285_error_handling_python_search_engine_tkinter.txt
Q: replace column values with values from different dataframe I have 2 pandas dataframes: df1 Home Place a MS Z2 c KM Z3 d RR R2 df2 Place1 a A2 c A66 z F32 x K41 t E90 I want to replace values of df2['Place1'] with df1['Place'] when indexes are matching and leave i...
replace column values with values from different dataframe
I have 2 pandas dataframes: df1 Home Place a MS Z2 c KM Z3 d RR R2 df2 Place1 a A2 c A66 z F32 x K41 t E90 I want to replace values of df2['Place1'] with df1['Place'] when indexes are matching and leave it the same when indexes are not matching. Desired result: P...
[ "Try with update\ndf2['Place1'].update(df1['Place'])\ndf2\nOut[75]: \n Place1\na Z2\nc Z3\nz F32\nx K41\nt E90\n\n", "You can do this with update.\ndf2['Place1'] = df2['Place1'].update(df1['Place'])\n\n" ]
[ 1, 0 ]
[]
[]
[ "dataframe", "numpy", "pandas", "python", "replace" ]
stackoverflow_0074549492_dataframe_numpy_pandas_python_replace.txt
Q: Running sudo command on a Azure function app using consumption plan I am trying to deploy an azure function written using python to an azure function app. The function is using pyzbar library. The pyzbar library documentation says that in a Linux environment, the below command needs to be executed so that the pyzb...
Running sudo command on a Azure function app using consumption plan
I am trying to deploy an azure function written using python to an azure function app. The function is using pyzbar library. The pyzbar library documentation says that in a Linux environment, the below command needs to be executed so that the pyzbar can work. sudo apt-get install libzbar0 How can I execute this comman...
[ "\nI have a work around where every time you trigger your function it will run a script that will install the required packages using the command prompt.\n\nThis can be achieved using subprocess module\n\n\ncode :\nsubprocess.run([\"apt-get\",\" install\",\" libzbar0\"])\n\nfor Example in the following code I am in...
[ 0 ]
[]
[]
[ "azure_functions", "python", "zbar" ]
stackoverflow_0074542828_azure_functions_python_zbar.txt
Q: Date and time format from string I'm converting the date of this string in this way, but I get the error "time data 'Aug 6, 2022, 10:44 AM' does not match format '%m %d, %Y, %I:%Mp'" fechaDAT = 'Aug 6, 2022, 10:44 AM' dateC = datetime.strptime(fechaDAT, "%m %d, %Y, %I:%Mp") A: here is the right format : dateC =...
Date and time format from string
I'm converting the date of this string in this way, but I get the error "time data 'Aug 6, 2022, 10:44 AM' does not match format '%m %d, %Y, %I:%Mp'" fechaDAT = 'Aug 6, 2022, 10:44 AM' dateC = datetime.strptime(fechaDAT, "%m %d, %Y, %I:%Mp")
[ "here is the right format :\ndateC = datetime.strptime(fechaDAT, \"%b %d, %Y, %I:%M %p\")\n\n%b for month abbrevation\n%p for locale AM/PM\n" ]
[ 0 ]
[]
[]
[ "datetime", "python" ]
stackoverflow_0074549555_datetime_python.txt
Q: Upload CSV files into partitioned bigquery table (generate partition from file name) I am using bigquery client object to upload some CSV files (located in cloud storage) into a bigquery table. I managed to upload the data into a bigquery table but I want to change the destination table to a partitioned table. And...
Upload CSV files into partitioned bigquery table (generate partition from file name)
I am using bigquery client object to upload some CSV files (located in cloud storage) into a bigquery table. I managed to upload the data into a bigquery table but I want to change the destination table to a partitioned table. And partition will be date which is in the filename. filename is a column in the CSV file whi...
[ "I think it is better to take advantage of external tables, given that your data is already being stored in cloud storage.\nYou can create external table, permanent or temporary, by reading directly the CSV files.\nhttps://cloud.google.com/bigquery/docs/external-data-cloud-storage\nAnd then load the information to ...
[ 1 ]
[]
[]
[ "google_bigquery", "google_cloud_platform", "python" ]
stackoverflow_0074525763_google_bigquery_google_cloud_platform_python.txt
Q: Splitting an array in different groups Suppose I have an array with 302 elements. I want to split the array into n = 6 groups (roughly equal size), such that it looks like the following. The following code works when n = 6. However, if n is 51 groups, then it failed and generated 60 groups. How can I get this righ...
Splitting an array in different groups
Suppose I have an array with 302 elements. I want to split the array into n = 6 groups (roughly equal size), such that it looks like the following. The following code works when n = 6. However, if n is 51 groups, then it failed and generated 60 groups. How can I get this right ? n = 6 group_num = np.arange(302) // (302...
[ "Use numpy.linspace:\nn = 51\nnp.linspace(0, n, num=302, endpoint=False).astype(int)\n\nOutput:\narray([ 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,\n 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5,\n 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, ...
[ 2, 0 ]
[]
[]
[ "numpy", "python" ]
stackoverflow_0074549328_numpy_python.txt
Q: Python __str__ no returning the desired result I'm working on my first few weeks of pythong, and i'm trying to modify some code from a course im following. I have added some data into a mssql, and I want to extract that table into my flask page. I was told to use str for my class, and I have added that, but i'm st...
Python __str__ no returning the desired result
I'm working on my first few weeks of pythong, and i'm trying to modify some code from a course im following. I have added some data into a mssql, and I want to extract that table into my flask page. I was told to use str for my class, and I have added that, but i'm still not getting a proper result. My app.py code is h...
[ "Use repr instead of str to declare or print the official string representation of an object. In your case you can represent it with something like this.\ndef __repr__(self):\n return f'<id: {self.id}, name: {self.name}, code: {self.code}>'\n\n" ]
[ 0 ]
[]
[]
[ "flask", "python" ]
stackoverflow_0074547647_flask_python.txt
Q: Unpacking list in Python - ValueError: not enough values to unpack I test my script just printing return value of .split: for f in os.listdir(): f_name, f_ext = os.path.splitext(f) print(f_name.split('-')) and it shows me what I'd like to see - lists with 3 strings in each. ['Earth ', ' Our Solar System '...
Unpacking list in Python - ValueError: not enough values to unpack
I test my script just printing return value of .split: for f in os.listdir(): f_name, f_ext = os.path.splitext(f) print(f_name.split('-')) and it shows me what I'd like to see - lists with 3 strings in each. ['Earth ', ' Our Solar System ', ' #4'] ['Saturn ', ' Our Solar System ', ' #7'] ['The Sun ', ' Our Sol...
[ "What you are experiencing is the diffrence between unpacking three items and a list. What you are getting from f.split is a single item only which is a list of the 'words'\nf_name = 'a-b-c'\nf_name.split(\"-\") -> [a,b,c] #But a list is a single entity\n\nSo consider :\n[title,course,num]= f_name.split(\"-\")\n\nH...
[ 0, 0 ]
[]
[]
[ "list", "python", "unpack", "valueerror" ]
stackoverflow_0074549630_list_python_unpack_valueerror.txt
Q: Can variables be stored in Lists in Python? Can I do this in python? lst = [listItem = 0,listItem2 = 0,listItem3 = 0] Then update the variable in the list like: number = 1 if number > 0: lst[1] += 1 listItem2 is now = 1 A: Well for the first if you want store data in list just put them like this: List = [0,...
Can variables be stored in Lists in Python?
Can I do this in python? lst = [listItem = 0,listItem2 = 0,listItem3 = 0] Then update the variable in the list like: number = 1 if number > 0: lst[1] += 1 listItem2 is now = 1
[ "Well for the first if you want store data in list just put them like this:\nList = [0, 1, 2]\nnot this: List1 = [var1 = 0, var2 = 1]\nif you need to make variables from data stored in list just use them like this:\nvar1 = List[1]\nThis how your code should look like:\nlst = [0, 0, 0]\n\nnumber = 1\n\nif number > 0...
[ 0 ]
[]
[]
[ "list", "python" ]
stackoverflow_0074549506_list_python.txt
Q: FastAPI: How to show multiple request examples in the docs and keep the default one I would like to show different example for a request in the FastAPI docs. As described here: https://fastapi.tiangolo.com/tutorial/schema-extra-example This code creates two examples ("Denmark, Sweden") but when I run it, the auto ...
FastAPI: How to show multiple request examples in the docs and keep the default one
I would like to show different example for a request in the FastAPI docs. As described here: https://fastapi.tiangolo.com/tutorial/schema-extra-example This code creates two examples ("Denmark, Sweden") but when I run it, the auto generated full example is no longer available. How can I keep the default example at the ...
[ "Adding a \"default\" entry with no \"value\" adds the default to the list of examples.\n examples={\n # add \"default example\" here \n \"default\": {\"summary\": \"Default example\"},\n\n \"denmark\": {\"summary\": \"A Denmark example\", \"value\": {\"hello\": \"denmark\"}},\n \"sw...
[ 0 ]
[]
[]
[ "fastapi", "python" ]
stackoverflow_0074545715_fastapi_python.txt
Q: How can I rename the PDF file, with the URL from where I downloaded it using Python I have a List of links that I have collected from google search results and I'm downloading these (PDF) files using selenium. I want to rename each file so that its filename contains the URL. What can I do? I have not tried any co...
How can I rename the PDF file, with the URL from where I downloaded it using Python
I have a List of links that I have collected from google search results and I'm downloading these (PDF) files using selenium. I want to rename each file so that its filename contains the URL. What can I do? I have not tried any code so please help me. I'm showing the code of selenium that I used to download the files....
[ "I dont think there's any python core library that can do this on selenium download. What you can do is to have a folder watchdog that keeps track of any changes or events that occur in the folder so that you can the rename the new file from there.\nCheck out pyWatch it could be of help.\n", "for z in range(len(l...
[ 0, 0, 0 ]
[]
[]
[ "python", "selenium" ]
stackoverflow_0074547662_python_selenium.txt
Q: TypeError: '_io.TextIOWrapper' object is not subscriptable The main function that the code should do is to open a file and get the median. This is my code: def medianStrat(lst): count = 0 test = [] for line in lst: test += line.split() for i in lst: count = count +1 ...
TypeError: '_io.TextIOWrapper' object is not subscriptable
The main function that the code should do is to open a file and get the median. This is my code: def medianStrat(lst): count = 0 test = [] for line in lst: test += line.split() for i in lst: count = count +1 if count % 2 == 0: x = count//2 ...
[ "You can't index (__getitem__) a _io.TextIOWrapper object. What you can do is work with a list of lines. Try this in your code:\nlst = open(input(\"Input file name: \"), \"r\").readlines()\n\n\nAlso, you aren't closing the file object, this would be better:\nwith open(input(\"Input file name: \", \"r\") as lst:\n ...
[ 15, 0 ]
[]
[]
[ "python", "typeerror" ]
stackoverflow_0028977477_python_typeerror.txt
Q: Remove decimals from a Float column shocked beyond belief how difficult this is turning out to be. All I can find are suggestions to change the format of the column to 'int' but I need to keep the comma thousand separators and changing the format to int gets rid of them. THEN i can't find anything on how to add co...
Remove decimals from a Float column
shocked beyond belief how difficult this is turning out to be. All I can find are suggestions to change the format of the column to 'int' but I need to keep the comma thousand separators and changing the format to int gets rid of them. THEN i can't find anything on how to add comma separators to an int column. any idea...
[]
[]
[ "Format your floats...in a string format?\nmy_string = '{:,.0f}'. format(my_number) \n\nE.g.:\nx = 1000.00\n'{:,.0f}'. format(x)-> 1,000\n\nWhich gives you what you want...something you can print with commas. 0f sets to 0 precision. (for how many decimal places)\n" ]
[ -1 ]
[ "floating_point", "format", "python" ]
stackoverflow_0074549782_floating_point_format_python.txt
Q: Convert from plotter coordinates to world coordinates in PyVista I am new to PyVista and vtk. I am implementing a mesh editing tool (Python=3.10, pyvista=0.37,vtk=9.1 ) When a user clicks all points within a given radius of the mouse cursor's world coordinates (e.g. projected point on the surface) should be select...
Convert from plotter coordinates to world coordinates in PyVista
I am new to PyVista and vtk. I am implementing a mesh editing tool (Python=3.10, pyvista=0.37,vtk=9.1 ) When a user clicks all points within a given radius of the mouse cursor's world coordinates (e.g. projected point on the surface) should be selected. I have implemented this much through callbacks to mouse clicks usi...
[ "I figured this one out. They key was to use 'pick_mouse_position' after calling 'track_mouse_position'.\n\n\nimport pyvista as pv\ndef myCallback(src,evt):\n out = p.pick_mouse_position()\n print(out)\n \nsp = pv.Sphere()\np = pv.Plotter()\np.add_mesh(sp)\np.track_mouse_position()\np.iren.add_observer(\"...
[ 1 ]
[]
[]
[ "coordinate_systems", "python", "pyvista", "vtk" ]
stackoverflow_0074549375_coordinate_systems_python_pyvista_vtk.txt
Q: Is there any way in python to parse files in a directory full of directories full of text files to find for a match? I have a directory full of other directories with thousands of text files and I don't know how to parse every file to look for matches. Is there any way in python? I tried the read file module but I...
Is there any way in python to parse files in a directory full of directories full of text files to find for a match?
I have a directory full of other directories with thousands of text files and I don't know how to parse every file to look for matches. Is there any way in python? I tried the read file module but I have to specify a directory and I don't know how to open every file, not only the ones I specified.
[ "If you have a character that separates each directory, you can use that to split the text.\nSearch about the split function in Python.\n' txt.split('') '\nIf you put the text it's more easy to explain.\n" ]
[ 0 ]
[]
[]
[ "directory", "python", "txt" ]
stackoverflow_0074549827_directory_python_txt.txt
Q: How to put text inside a rectangle in Manim Community this is the thing I wanted to make I'm very new to manim I'm trying to put the text inside a rectangle like given in the image How can I do that ?? :( A: You can use VGroup to group a box and a text together. Example Code: from manimlib import * def create_t...
How to put text inside a rectangle in Manim Community
this is the thing I wanted to make I'm very new to manim I'm trying to put the text inside a rectangle like given in the image How can I do that ?? :(
[ "You can use VGroup to group a box and a text together.\nExample Code:\nfrom manimlib import *\n\ndef create_textbox(color, string):\n result = VGroup() # create a VGroup\n box = Rectangle( # create a box\n height=2, width=3, fill_color=color, \n fill_opacity=0.5, stroke_color=color\n )\n ...
[ 5, 0 ]
[ "Writing a text inside a rectangle can be achieved in few steps:\n\nImporting manim\nWrite the text to be inside the shape (I am using Rectangle as an example)\nAnimate or create an image.\n\nfrom manim import *\n\nclass TextInsideRec(Scene):\n def construct(self):\n text = Text(\"I am the text to be insi...
[ -1 ]
[ "algorithm_animation", "animation", "manim", "python", "python_3.x" ]
stackoverflow_0070142914_algorithm_animation_animation_manim_python_python_3.x.txt
Q: the following arguments are required I have the Python script . What I'm trying to do is to test this code in colab The problem is that the initial script requires arguments. They are defined as follows: if __name__ == "__main__": parser = argparse.ArgumentParser(description="Pipeline to train a NN model speci...
the following arguments are required
I have the Python script . What I'm trying to do is to test this code in colab The problem is that the initial script requires arguments. They are defined as follows: if __name__ == "__main__": parser = argparse.ArgumentParser(description="Pipeline to train a NN model specified by a YML config") parser.add_argu...
[ "Arguments are received when you run a program from the command line (shell, bash, cmd) and they enable effecting the program without changing it e.g. my-program -varX 1 vs my-program -varX 2, you are not doing so, so instead you can remove that code and replace args.config, args.tag etc. with variables e.g. config...
[ 0 ]
[ "parser = argparse.ArgumentParser(description=\"Pipeline to train a NN model specified by a YML config\")\nparser.add_argument(\"-t\", \"--tag\", nargs=\"?\", type=str, help=\"Model tag of the experiment\", required=True)\nparser.add_argument(\"-c\", \"--config\", nargs=\"?\", type=str, default=\"syndoc.yml\", help...
[ -1 ]
[ "python" ]
stackoverflow_0067071077_python.txt
Q: request.get to seemingly valid URL returns 404 status code / fails Valid URL fails requests.get https://finance.yahoo.com/quote/AAPL/analysis?p=AAPL is a valid URL as is not redirects DOES NOT WORK import requests url6 = 'https://finance.yahoo.com/quote/AAPL/analysis?p=AAPL' r = requests.get(url6) returns False ...
request.get to seemingly valid URL returns 404 status code / fails
Valid URL fails requests.get https://finance.yahoo.com/quote/AAPL/analysis?p=AAPL is a valid URL as is not redirects DOES NOT WORK import requests url6 = 'https://finance.yahoo.com/quote/AAPL/analysis?p=AAPL' r = requests.get(url6) returns False 404 [] or more simply requests.get('https://finance.yahoo.com/quote/AAPL...
[ "I added headers to your request. More specifically, I added the user agent.\nimport requests\n\nurl6 = 'https://finance.yahoo.com/quote/AAPL/analysis?p=AAPL'\nheaders={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36'}\n\nr = requests.ge...
[ 0, 0 ]
[]
[]
[ "beautifulsoup", "python", "python_requests" ]
stackoverflow_0074549610_beautifulsoup_python_python_requests.txt