content
stringlengths
85
101k
title
stringlengths
0
150
question
stringlengths
15
48k
answers
list
answers_scores
list
non_answers
list
non_answers_scores
list
tags
list
name
stringlengths
35
137
Q: How run hello_world example in pythons' faust lib my kafka deployed in kubernetes, so I forwarded port 9092 kubectl port-forward -n kafka svc/kafka 9092 and try run hello_world.py but faced with exception [2020-10-01 00:31:52,331] [3503] [ERROR] Unable connect to node with id 0: [Errno -2] Name or service not know...
How run hello_world example in pythons' faust lib
my kafka deployed in kubernetes, so I forwarded port 9092 kubectl port-forward -n kafka svc/kafka 9092 and try run hello_world.py but faced with exception [2020-10-01 00:31:52,331] [3503] [ERROR] Unable connect to node with id 0: [Errno -2] Name or service not known [2020-10-01 00:31:52,341] [3503] [ERROR] [^Worker]: E...
[ "I use wsl\n\nso after added to /etc/hosts line \n127.0.0.1 kafka-0.kafka-headless.kafka.svc.cluster.local\nI've solved my problem\n", "For me on macOS helped add this line to /etc/hosts:\n127.0.0.1 kafka\n" ]
[ 0, 0 ]
[]
[]
[ "faust", "python" ]
stackoverflow_0064151313_faust_python.txt
Q: config.ini not reading string I am trying to build my first config.ini file for Python, but having issues using it in my script. I am attempting to use it with the JIRA module for work, so that's where I am hitting a snag. Before using a config file, when assigning a variable, it would look something like this: va...
config.ini not reading string
I am trying to build my first config.ini file for Python, but having issues using it in my script. I am attempting to use it with the JIRA module for work, so that's where I am hitting a snag. Before using a config file, when assigning a variable, it would look something like this: var1 = issue.fields.customfield10000 ...
[ "does this help? It worked for me.\nChange this:\nconfig.read(config.ini)\n\nto:\nconfig.read(\"config.ini\")\n\n" ]
[ 0 ]
[]
[]
[ "config", "jira", "python" ]
stackoverflow_0074282953_config_jira_python.txt
Q: How to convert a column of ints, NaN, and strings to only integers and NaNs I have a DataFrame that looks like this: df = pd.DataFrame({ 'name': ['John','Mary', 'Phil', 'Sue', 'Robert', 'Lucy', 'Blake'], 'age': ['15', '20s', 37, 'teen', '', 'elderly', 57] }) df name age 0 John 15 ...
How to convert a column of ints, NaN, and strings to only integers and NaNs
I have a DataFrame that looks like this: df = pd.DataFrame({ 'name': ['John','Mary', 'Phil', 'Sue', 'Robert', 'Lucy', 'Blake'], 'age': ['15', '20s', 37, 'teen', '', 'elderly', 57] }) df name age 0 John 15 1 Mary 20s 2 Phil 37 3 Sue teen 4 Robert 5 Lucy ...
[ "You could do the following, using the apply method.\nimport pandas as pd\nimport numpy as np\n\ndf = pd.DataFrame({\n 'name': ['John','Mary', 'Phil', 'Sue', 'Robert', 'Lucy', 'Blake'],\n 'age': ['15', '20s', 37, 'teen', '', 'elderly', 57]\n })\n\ndef func(x):\n try:\n return int(x)\n except:\...
[ 0, 0 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074283500_pandas_python.txt
Q: Create a male/female variable for an equation I’m developing a BMI and fat percentage calculator for a school project. I took a model with a ready-made GUI and made the necessary adjustments, but I’m stuck in the equation to calculate the fat percentage. This is my full code: from tkinter import * from tkinter imp...
Create a male/female variable for an equation
I’m developing a BMI and fat percentage calculator for a school project. I took a model with a ready-made GUI and made the necessary adjustments, but I’m stuck in the equation to calculate the fat percentage. This is my full code: from tkinter import * from tkinter import messagebox def fazer_reset(): idade_tf.de...
[ "The radio button values are being assigned to the variable var in your example. However, you need to extract the value by using var.get().\nWith this information in mind, you could set the sexo variable to be equal to var.get().\n...\n\ndef calcular_gordura():\n sexo = var.get()\n \n idade = int(idade...
[ 1 ]
[]
[]
[ "python" ]
stackoverflow_0074283479_python.txt
Q: Pandas - Processing DF with multiple identifier into a combined column I have below DF that i wanted to process to be like the sample below. Im having a hard time due to the identifier is sharing the column where what site they are located. the column location is also not fix as there are certain times where the "...
Pandas - Processing DF with multiple identifier into a combined column
I have below DF that i wanted to process to be like the sample below. Im having a hard time due to the identifier is sharing the column where what site they are located. the column location is also not fix as there are certain times where the "Land" has 30days whereas the "Water" only has 5 days Thank you for helping m...
[ "Is this what you wanted ? I would first split into 2 dataframes with each containing different identifier and at the end union them back tgt. here's the code and hope it helps.\ndf = pd.DataFrame({'Unnamed: 0': ['Site',\"A\", \"B\",\"C\"],\n 'Unnamed: 1': ['Identifier 1',\"Land\", \"Land\",\"Land\"],\n ...
[ 2 ]
[]
[]
[ "dataframe", "numpy", "pandas", "python" ]
stackoverflow_0074283486_dataframe_numpy_pandas_python.txt
Q: How to filter a dataframe with multiple-dimension index based on one dimension I have a dataframe with multiple dimensional index using pandas. Say employee_id and date. Now I want to update records that's prior to a specific date, say 2020-01-01. To be consistent with other codes, the update was made using np.whe...
How to filter a dataframe with multiple-dimension index based on one dimension
I have a dataframe with multiple dimensional index using pandas. Say employee_id and date. Now I want to update records that's prior to a specific date, say 2020-01-01. To be consistent with other codes, the update was made using np.where. So how can I add this date filter into this assignment, df['Sale'] = np.where(df...
[ "One solution is to create a boolean mask from the date part of the index and use it to mask out non-relevant rows during update\nSample input dataframe\ndf = pd.DataFrame([[0, '2019-01-01', 100, 200, 0], [1, '2019-02-01', 150, 100, 0], [0, '2021-12-12', 200, 100, 0]], columns=['id', 'date','sale_expect', 'sale_act...
[ 1 ]
[]
[]
[ "numpy", "pandas", "python" ]
stackoverflow_0074283203_numpy_pandas_python.txt
Q: DataFrame: Concatenate columns without loosing the other columns I have dataset of 5 columns, I'll call them ['A', 'B', 'C', 'D', 'F') for here. I am trying to concatenate A, B and C and still have D and F in the dataframe. Maybe concatenating isn't even the thing I am looking for? I just want the strings from A, ...
DataFrame: Concatenate columns without loosing the other columns
I have dataset of 5 columns, I'll call them ['A', 'B', 'C', 'D', 'F') for here. I am trying to concatenate A, B and C and still have D and F in the dataframe. Maybe concatenating isn't even the thing I am looking for? I just want the strings from A, B and C to be in one columns. I tried to use newdf['ABC'] = newdf['A']...
[ ">>> df\n A B C D E\n0 1 2 3 4 5\n>>> df['ABC'] = df['A'] + df['B'] + df['C']\n>>> df\n A B C D E ABC\n0 1 2 3 4 5 6\n\nIt does not overwrite D, E columns.\nIf it's not the one you want, can you explain your code and input/output?\n" ]
[ 1 ]
[]
[]
[ "dataframe", "numpy", "pandas", "python" ]
stackoverflow_0074283588_dataframe_numpy_pandas_python.txt
Q: detect the number of three way conversations in chat dataset using pandas Three way conversation: red_01 replies to green_01. green_01 replies back to red_01. This can be considered 1 three way conversation in the entire dataset. So, I am trying to think of solution to query the count how many such conversations h...
detect the number of three way conversations in chat dataset using pandas
Three way conversation: red_01 replies to green_01. green_01 replies back to red_01. This can be considered 1 three way conversation in the entire dataset. So, I am trying to think of solution to query the count how many such conversations have occured in the entire dataset? This is 1 to 1 conversation system by the wa...
[ "import pandas as pd\ntest_df = pd.DataFrame([[1,\"red1\",\"\", 1],[1,\"green1\",\"\", 2],[1,\"red1\",\"\", 3], [2,\"red1\",\"\", 1],[2,\"red1\",\"\", 2],[2,\"red1\",\"\", 3]],\n columns = [\"conversation_id\",\"user_id\",\"messages\",\"timestamp\"])\n\ncriteria = (\n lambda x: len(x) == 3 \n and x.iloc[0]...
[ 1 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074283503_pandas_python.txt
Q: error reading txt file as data frame that is selected from a list - python/pandas I'm currently learning - and I don't understand a lot of specifics about python/pandas. So, there may be an easy fix for this. currently what I am trying to do is list txt files in a select directory and then be able to select them b...
error reading txt file as data frame that is selected from a list - python/pandas
I'm currently learning - and I don't understand a lot of specifics about python/pandas. So, there may be an easy fix for this. currently what I am trying to do is list txt files in a select directory and then be able to select them by number/index. Then for it to be read as a dataframe, for me to run data analysis agai...
[ "df = pd.read_csv(f\"{input_dir}/{filelist[int(choice)]}\")\n\n", "you need to provide the path of the file\nthe other way to provide that is by using os.path.join(input_dir, f) like the one you use in the filelist = ...\nSo it will be like this\n# open the file based on the key input by user\ndf = pd.read_csv(os...
[ 0, 0 ]
[]
[]
[ "dataframe", "pandas", "python" ]
stackoverflow_0074283572_dataframe_pandas_python.txt
Q: Add external margins with constrained layout? When generating a figure to save to a pdf file, I'd like to adjust the positioning of the figure relative to the edges of the page, for example to add an inch margin along all sides. As far as I can tell, the solutions to do this (for example, in this question) either:...
Add external margins with constrained layout?
When generating a figure to save to a pdf file, I'd like to adjust the positioning of the figure relative to the edges of the page, for example to add an inch margin along all sides. As far as I can tell, the solutions to do this (for example, in this question) either: don't work with constrained_layout mode -- applyi...
[ "Have you tried using the constrained layout padding option?\nfig.set_constrained_layout_pads(w_pad=4./72., h_pad=4./72.,\n hspace=0./72., wspace=0./72.)\n\nWhile this might help with spacing, the constrained layout will restrict the amount of object that you can add to the defined space.\n''' Here is th...
[ 4, 1, 0 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0063505647_matplotlib_python.txt
Q: how to separate text lines in python I am trying to split diffrent lines of text in python. I tried to use the split function and it dosent work for what I want. here is an example. ` list = open(file,"r") for Password in passlist: print(list) ` and I want it to give this output: number 1 and number 2 A: ...
how to separate text lines in python
I am trying to split diffrent lines of text in python. I tried to use the split function and it dosent work for what I want. here is an example. ` list = open(file,"r") for Password in passlist: print(list) ` and I want it to give this output: number 1 and number 2
[ "I do not know how you have saved the Passwords in your File but if you would like to open the passwords you could do something like this:\npasslist = open(\"file\" ,\"r\")\nx = passlist.read().split(\", \") <--- change to the format you use to save the passwords \nprint(x)\n\nthen you could assign password1 and 2 ...
[ 0, 0 ]
[ "If you want to have each line in a list:\n# Open the file (in read mode)\nfile = open(file, \"r\")\n\n# Read the file and split at every new line\n# The 'split()' function will return a list\ncontent = file.read().split(\"\\n\")\n\n# Close the file\nfile.close()\n\n# Now each line should be in the list\nprint(cont...
[ -1 ]
[ "list", "python", "text" ]
stackoverflow_0074283012_list_python_text.txt
Q: how to identify webp image type with python I want to identify the type of a Image to tell whether it's a webp format or not, but I can't just using file command because the image is stored in memory as binary which was download from the internet. so far I can't find any method to do this in the PIL lib or imghdr ...
how to identify webp image type with python
I want to identify the type of a Image to tell whether it's a webp format or not, but I can't just using file command because the image is stored in memory as binary which was download from the internet. so far I can't find any method to do this in the PIL lib or imghdr lib here is what I wan't to do: from PIL import I...
[ "The imghdr module doesn't yet support webp image detection; it is to be added to Python 3.5.\nAdding it in on older Python versions is easy enough:\nimport imghdr\n\ntry:\n imghdr.test_webp\nexcept AttributeError:\n # add in webp test, see http://bugs.python.org/issue20197\n def test_webp(h, f):\n ...
[ 3, 0 ]
[]
[]
[ "image", "python", "python_imaging_library", "webp" ]
stackoverflow_0028085271_image_python_python_imaging_library_webp.txt
Q: How do I write a regex to match the pattern "Day Month Date TimeStamp Year"? I want to filter log data using python regex based on the format "Day Month Date Timestamp Year" Example : Mon Mar 16 13:03:07 2020 Content of log file will look something like below SR 194 1584363914 0 1 Mon Mar 16 13:05:14 2020 ...
How do I write a regex to match the pattern "Day Month Date TimeStamp Year"?
I want to filter log data using python regex based on the format "Day Month Date Timestamp Year" Example : Mon Mar 16 13:03:07 2020 Content of log file will look something like below SR 194 1584363914 0 1 Mon Mar 16 13:05:14 2020 200002305 4 bay18 cupMonitor ssListProcessing.c 980 The precursor ...
[ "You can build a regex matcher as follow:\nimport datetime\nimport re\n\nmonths = '|'.join([f'{datetime.datetime(1970,i+1,1):%b}' for i in range(12)])\nweekdays = '|'.join([f'{datetime.datetime(1970,1,i+1):%a}' for i in range(7)])\npat = re.compile(fr'\\b({weekdays})\\s+({months})\\s(\\d\\d)\\s+(\\d\\d:\\d\\d:\\d\...
[ 2 ]
[]
[]
[ "python", "python_re", "python_regex", "regex", "regex_group" ]
stackoverflow_0074283611_python_python_re_python_regex_regex_regex_group.txt
Q: Python: How to compare time in 24 Hrs format I am stuck with this tricky part with time manipulation:- start_time = 22.00.00 -------------[10pm] end_time = 05.00.00 ---------[5.0am] current_time = 01.00.00 -----------[1am] Here, I want to verify my current time is between start and end time. This line of conditio...
Python: How to compare time in 24 Hrs format
I am stuck with this tricky part with time manipulation:- start_time = 22.00.00 -------------[10pm] end_time = 05.00.00 ---------[5.0am] current_time = 01.00.00 -----------[1am] Here, I want to verify my current time is between start and end time. This line of condition does not work here:- if start_time < current_tim...
[ "Given that your time strings are in HH.MM.SS format, you can compare them directly as strings. However you need to take account of the fact that the period might span a 24-hour boundary, so that end_time < start_time. In that scenario you need to reverse the compare and invert the result.\nstart_time = \"22.00.00\...
[ 1, 0 ]
[]
[]
[ "datetime_format", "python", "python_3.x" ]
stackoverflow_0074283514_datetime_format_python_python_3.x.txt
Q: Strange matplotlib zorder behavior with legend and errorbar I encountered a rather strange behavior of legend and the errorbar plot commands. I am using Python xy 2.7.3.1 with matplotlib 1.1.1 The code below exemplifies the observed behavior: import pylab as P import numpy as N x1=N.linspace(0,6,10) y1=N.sin(x1)...
Strange matplotlib zorder behavior with legend and errorbar
I encountered a rather strange behavior of legend and the errorbar plot commands. I am using Python xy 2.7.3.1 with matplotlib 1.1.1 The code below exemplifies the observed behavior: import pylab as P import numpy as N x1=N.linspace(0,6,10) y1=N.sin(x1) x2=N.linspace(0,6,5000) y2=N.sin(x2) xerr = N.repeat(0.01,10) ye...
[ "The created plots are correct according to the code you have posted. The objects with the lowest zorder is placed on the bottom, while the object with the highest zorder is placed on top. The zorder problem you linked to is fixed in matplotlib version 1.2.1, so you should update your install if possible.\nIn your ...
[ 11, 0 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0016770049_matplotlib_python.txt
Q: Django Help! Form with method post is not callin the action correctly with django url tag need help understanding why this doesn not work? While trying to create a simple search form using method="POST" and action linking to a url that should trigger a view to render a different template I have come across it not ...
Django Help! Form with method post is not callin the action correctly with django url tag need help understanding why this doesn not work?
While trying to create a simple search form using method="POST" and action linking to a url that should trigger a view to render a different template I have come across it not working all it does is tag on the csrf to my index url and acts like I am using GET not POST any thoughts on why? HTML URL: http://127.0.0.1:800...
[ "I can provide two suggestions, first to render outside the else condition, and the second to see searched has any value or not by printing it.\n@login_required(login_url='login_register')\ndef search_site(request):\n if request.method == \"POST\":\n searched = request.POST['searched']\n print(f\"s...
[ 3 ]
[]
[]
[ "django", "django_templates", "django_urls", "django_views", "python" ]
stackoverflow_0074281424_django_django_templates_django_urls_django_views_python.txt
Q: EOF Error occurs when trying to give a user input I am learning python and have the following code in test.py: string = input() print(string) Contrary to tutorials, it gives me an error: string = input() EOFError: EOF when reading a line I have no idea what I do wrong here! Any help appreciated! A: Somethi...
EOF Error occurs when trying to give a user input
I am learning python and have the following code in test.py: string = input() print(string) Contrary to tutorials, it gives me an error: string = input() EOFError: EOF when reading a line I have no idea what I do wrong here! Any help appreciated!
[ "Something gotta be wrong with you IDE just tried you code and it works like it's supposed to. What program are you using to code (IDE)?\n", "You seem to have an EOFError exception when running your code. EOFError is short for \"End-of-Line Error.\" This error occurs when Python has reached the end of user input ...
[ 3, 0 ]
[]
[]
[ "eof", "input", "python" ]
stackoverflow_0074283683_eof_input_python.txt
Q: How can I send idle request using pywinusb in python I am trying to copy the behaviour of a software which control a device using HID interface, the work flow is send an idle request then send a bunch of data to the device, I can send the data, but I don't know how to send the idle request. I found the HID docume...
How can I send idle request using pywinusb in python
I am trying to copy the behaviour of a software which control a device using HID interface, the work flow is send an idle request then send a bunch of data to the device, I can send the data, but I don't know how to send the idle request. I found the HID document online and saw this and I can find similar question us...
[ "I found out that this is a dumb question I simply send the code below\nidle=[0x21,0x0A,0x200]\ndevice.send_output_report(idle)\n\n\nbut now it occur another question is that I can send idle request, but the code give me error 87\n\nimport pywinusb.hid as hid\nimport time\nimport datetime\n\n\nv_id = 0x047a\np_id =...
[ 0 ]
[]
[]
[ "python", "pywinusb" ]
stackoverflow_0074283437_python_pywinusb.txt
Q: RuntimeError on windows trying python multiprocessing I am trying my very first formal python program using Threading and Multiprocessing on a windows machine. I am unable to launch the processes though, with python giving the following message. The thing is, I am not launching my threads in the main module. The t...
RuntimeError on windows trying python multiprocessing
I am trying my very first formal python program using Threading and Multiprocessing on a windows machine. I am unable to launch the processes though, with python giving the following message. The thing is, I am not launching my threads in the main module. The threads are handled in a separate module inside a class. EDI...
[ "On Windows the subprocesses will import (i.e. execute) the main module at start. You need to insert an if __name__ == '__main__': guard in the main module to avoid creating subprocesses recursively. \nModified testMain.py:\nimport parallelTestModule\n\nif __name__ == '__main__': \n extractor = parallelTestMo...
[ 373, 43, 17, 12, 10, 1, 0, 0, 0, 0 ]
[]
[]
[ "multiprocessing", "python", "windows" ]
stackoverflow_0018204782_multiprocessing_python_windows.txt
Q: build scipy error cythonize failed I'm trying to build scipy and I get a RuntimeError: $sudo python setup.py build Processing scipy/cluster/_vq_rewrite.pyx Traceback (most recent call last): File "tools/cythonize.py", line 172, in <module> main() File "tools/cythonize.py", line 168, in main find_proces...
build scipy error cythonize failed
I'm trying to build scipy and I get a RuntimeError: $sudo python setup.py build Processing scipy/cluster/_vq_rewrite.pyx Traceback (most recent call last): File "tools/cythonize.py", line 172, in <module> main() File "tools/cythonize.py", line 168, in main find_process_files(root_dir) File "tools/cythoniz...
[ "Python setuptools solved the problem.\nhttp://docs.cython.org/src/quickstart/install.html\neasy_install cython or pip install cython\n", "If you do not have Cython installed then use: pip install Cython.\nHowever, if you do have an old version of Cython installed like me then this is what solved it for me: pip i...
[ 83, 3, 0 ]
[]
[]
[ "cython", "python", "scipy" ]
stackoverflow_0015175135_cython_python_scipy.txt
Q: How do I run a python file from command prompt: not getting any response How can I run below file? Here is my code: main.py def calculation(a, b): print(a) return a I have tried, py main.py it does not return anything. A: Invoke that function def calculation(a, b): print(a) return a print(calculati...
How do I run a python file from command prompt: not getting any response
How can I run below file? Here is my code: main.py def calculation(a, b): print(a) return a I have tried, py main.py it does not return anything.
[ "Invoke that function\ndef calculation(a, b):\n print(a)\n return a\n\nprint(calculation(1, 3))\n\n", "You can access command line arguments using sys.argv. This is a very minimal example.\nmy_prog.py\nimport sys\n\ndef calculation(a, b):\n print(a)\n return a\n\nif __name__ =='__main__':\n a,b = sys....
[ 1, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0074283876_python.txt
Q: How Do I Count The Number of Times a Subset of Words Appear In My Pandas Dataframe? I have a bunch of keywords stored in a 620x2 pandas dataframe seen below. I think I need to treat each entry as its own set, where semicolons separate elements. So, we end up with 1240 sets. Then I'd like to be able to search how m...
How Do I Count The Number of Times a Subset of Words Appear In My Pandas Dataframe?
I have a bunch of keywords stored in a 620x2 pandas dataframe seen below. I think I need to treat each entry as its own set, where semicolons separate elements. So, we end up with 1240 sets. Then I'd like to be able to search how many times keywords of my choosing appear together. For example, I'd like to figure out ho...
[ "Not sure if this is considered straightforward, but it works. keyword_list is the list of paired keywords you want to search.\ndf['Author Keywords'] = df['Author Keywords'].fillna('').str.split(';\\s*').apply(set)\ndf['Index Keywords'] = df['Index Keywords'].fillna('').str.split(';\\s*').apply(set)\ndf.apply(lambd...
[ 0, 0 ]
[]
[]
[ "counting", "dataframe", "pandas", "python", "subset_sum" ]
stackoverflow_0074282290_counting_dataframe_pandas_python_subset_sum.txt
Q: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed I have been trying to connect to the broker for a while. But I get the following error when I use the dns: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificat...
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
I have been trying to connect to the broker for a while. But I get the following error when I use the dns: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'ec2-x-x-x-x.us-east-2.compute.amazonaws.com'. (_ssl.c:1131) When I use the...
[ "\nThe certificate is valid\n\nThat may be the case; but is it valid for \"ec2-x-x-x-x.us-east-2.compute.amazonaws.com\"? The error you are getting is basically saying \"I asked ec2-x-x-x-x.us-east-2.compute.amazonaws.com for its certificate; it gave me a valid certificate but its for a different hostname (e.g. bad...
[ 0, 0 ]
[]
[]
[ "certificate", "mqtt", "paho", "python", "ssl_certificate" ]
stackoverflow_0068639448_certificate_mqtt_paho_python_ssl_certificate.txt
Q: Get the first word after specific word in a column I am trying to get the zip code after the specific word 'zip_code' within a string. I have a data frame with a column named "location", in this column there is a string, I want to identify the word "zip_code" and get the value after this word for each row. Input n...
Get the first word after specific word in a column
I am trying to get the zip code after the specific word 'zip_code' within a string. I have a data frame with a column named "location", in this column there is a string, I want to identify the word "zip_code" and get the value after this word for each row. Input name location Bar1 LA Jefferson zip_code 202378 Aven...
[ "The best way is to use extract() which accepts regex and allows searching through each row.\nimport pandas as pd\nimport numpy as np\n\ndf = pd.DataFrame({'name':['Bar1', 'Pizza', 'Tacos'],\n 'location':['LA Jefferson zip_code 202378 Avenue free', 'Avenue 45 zip_code 45623 wichita st', 'Las Americas avenue 7...
[ 2 ]
[]
[]
[ "dataframe", "pandas", "python", "split" ]
stackoverflow_0074283980_dataframe_pandas_python_split.txt
Q: How to stop logging locally but only save to wandb's servers and have wandb work using soft links? I am having a weird issue where I change the location of all my code & data to a different location with more disk space, then I soft link my projects & data to those locations with more space. I assume there must be...
How to stop logging locally but only save to wandb's servers and have wandb work using soft links?
I am having a weird issue where I change the location of all my code & data to a different location with more disk space, then I soft link my projects & data to those locations with more space. I assume there must be some file handle issue because wandb's logger is throwing me issues. So my questions: how do I have wa...
[ "seems like the solution is to not log to weird places with symlinks but log to real paths and instead clean up the wandb local paths often to avoid disk quota errors in your HPC. Not my fav solution but gets it done :).\nWandb should fix this, the whole point of wandb is that it works out of the box and I don't ha...
[ 2, 0 ]
[]
[]
[ "deep_learning", "machine_learning", "python", "pytorch", "wandb" ]
stackoverflow_0074175401_deep_learning_machine_learning_python_pytorch_wandb.txt
Q: How can I send a message to someone with my telegram bot using their Username I am using the telepot python library, I know that you can send a message when you have someone's UserID(Which is a number). I wanna know if it is possible to send a message to someone without having their UserID but only with their user...
How can I send a message to someone with my telegram bot using their Username
I am using the telepot python library, I know that you can send a message when you have someone's UserID(Which is a number). I wanna know if it is possible to send a message to someone without having their UserID but only with their username(The one which starts with '@'), Also if there is a way to convert a username t...
[ "\nPost one message from User to the Bot.\nOpen https://api.telegram.org/bot<Bot_token>/getUpdates page.\nFind this message and navigate to the result->message->chat->id key.\nUse this ID as the [chat_id] parameter to send personal messages to the User.\n\n", "It is only possible to send messages to users whom ha...
[ 81, 19, 16, 8, 0, 0 ]
[]
[]
[ "python", "python_telegram_bot", "telegram", "telegram_bot", "visual_studio_code" ]
stackoverflow_0041664810_python_python_telegram_bot_telegram_telegram_bot_visual_studio_code.txt
Q: python for loop ; copy specific list item to another List1 = ['a','b','c','d','e','f','g','h','i'] List2 = [] I want to copy item#3,6,9 from list1 to list2 using for loop. can anyone give me example code please. A: You can just loop over the indices that you want using a list comprehension (remembering that pyt...
python for loop ; copy specific list item to another
List1 = ['a','b','c','d','e','f','g','h','i'] List2 = [] I want to copy item#3,6,9 from list1 to list2 using for loop. can anyone give me example code please.
[ "You can just loop over the indices that you want using a list comprehension (remembering that python lists are zero indexed so item #3 is index 2, etc...):\nList1 = ['a','b','c','d','e','f','g','h','i']\nindices = [2,5,8]\n\nList2 = [List1[i] for i in indices]\n\n# ['c', 'f', 'i']\n\n", "You can use enumerate() ...
[ 6, 3, 0, 0, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0064398594_python.txt
Q: Setting a parameter once and use it multiple times in python I'm new to Python and I have a design question. I have a file in this structure: @pytest.fixture( scope = "module", autouse = True ) def auth( input ) : body = { name= "secret" type="A" } . . . class TestArtifacts(object...
Setting a parameter once and use it multiple times in python
I'm new to Python and I have a design question. I have a file in this structure: @pytest.fixture( scope = "module", autouse = True ) def auth( input ) : body = { name= "secret" type="A" } . . . class TestArtifacts(object): def test_e2e( self, input): name = "secret" . . . ...
[ "Your example shows two functions encapsulated in a class object. Why not use self-variables to store and use one input for both functions? It avoids the use of the globals keyword and can be easily accessed in your class functions.\nclass Foo:\n def __init__(self, input):\n self.input = input\n def ba...
[ 1 ]
[]
[]
[ "python" ]
stackoverflow_0074283984_python.txt
Q: How can I add the sqlite3 module to Python? Can someone tell me how to install the sqlite3 module alongside the most recent version of Python? I am using a Macbook, and on the command line, I tried: pip install sqlite but an error pops up. A: You don't need to install sqlite3 module. It is included in the stand...
How can I add the sqlite3 module to Python?
Can someone tell me how to install the sqlite3 module alongside the most recent version of Python? I am using a Macbook, and on the command line, I tried: pip install sqlite but an error pops up.
[ "You don't need to install sqlite3 module. It is included in the standard library (since Python 2.5).\n", "For Python version 3:\npip install pysqlite3 \n\n", "I have python 2.7.3 and this solved my problem:\npip install pysqlite\n\n", "Normally, it is included. However, as @ngn999 said, if your python has be...
[ 290, 71, 43, 25, 1, 0 ]
[]
[]
[ "pip", "python", "sqlite" ]
stackoverflow_0019530974_pip_python_sqlite.txt
Q: In Python, how did I prevent a name from repeating in dataset and sum or average the information of the data given? **I am analyzing data found on github reflecting COVID-19 (coronavirus) by Our World in Data on GitHub. The data found will be presented in an organized table format. ** Link to data https://raw.gith...
In Python, how did I prevent a name from repeating in dataset and sum or average the information of the data given?
**I am analyzing data found on github reflecting COVID-19 (coronavirus) by Our World in Data on GitHub. The data found will be presented in an organized table format. ** Link to data https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/owid-covid-data.csv Project Goals: List every country in alphabet...
[ "df = pd.read_csv(r'https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/owid-covid-data.csv')\n\ndf[['location', 'total_vaccinations']].groupby('location').sum().reset_index()\n\n location total_vaccinations\n0 Afghanistan 4.013568e+08\n1 Africa 1.853572...
[ 0 ]
[]
[]
[ "database", "datatables", "pandas", "python" ]
stackoverflow_0074283931_database_datatables_pandas_python.txt
Q: How can I add a label to specific bars (not all) in a matplotlib bar? I have built a bar chart that is showing value counts for every day in a year - I want to add labels to specific days, is this possible? I can only find examples where this applies to all. This is my code: daychart = data.groupby(['Day'], as_ind...
How can I add a label to specific bars (not all) in a matplotlib bar?
I have built a bar chart that is showing value counts for every day in a year - I want to add labels to specific days, is this possible? I can only find examples where this applies to all. This is my code: daychart = data.groupby(['Day'], as_index=False, sort=False).agg(Count=('Day','size')) plt.figure(figsize=(20,4)) ...
[ "Hopefully this helps, first get a basic date for any year of Jan 1, then this Jan 1 + the corresponding value from 0 to 365 and then display back the value without year. change the x-axis to this value instead of 0-365. Below is the code to get the job done.\nimport pandas as pd\nd = { 'day_in_year': [n for n in r...
[ 1 ]
[]
[]
[ "bar_chart", "matplotlib", "python" ]
stackoverflow_0074283918_bar_chart_matplotlib_python.txt
Q: What's the fastest way in Python to calculate cosine similarity given sparse matrix data? Given a sparse matrix listing, what's the best way to calculate the cosine similarity between each of the columns (or rows) in the matrix? I would rather not iterate n-choose-two times. Say the input matrix is: A= [0 1 0 0 1...
What's the fastest way in Python to calculate cosine similarity given sparse matrix data?
Given a sparse matrix listing, what's the best way to calculate the cosine similarity between each of the columns (or rows) in the matrix? I would rather not iterate n-choose-two times. Say the input matrix is: A= [0 1 0 0 1 0 0 1 1 1 1 1 0 1 0] The sparse representation is: A = 0, 1 0, 4 1, 2 1, 3 1, 4 2, 0 2, 1 ...
[ "You can compute pairwise cosine similarity on the rows of a sparse matrix directly using sklearn. As of version 0.17 it also supports sparse output:\nfrom sklearn.metrics.pairwise import cosine_similarity\nfrom scipy import sparse\n\nA = np.array([[0, 1, 0, 0, 1], [0, 0, 1, 1, 1],[1, 1, 0, 1, 0]])\nA_sparse = sp...
[ 89, 53, 16, 14, 4, 3, 1, 0, 0, 0 ]
[]
[]
[ "cosine_similarity", "numpy", "pandas", "python", "similarity" ]
stackoverflow_0017627219_cosine_similarity_numpy_pandas_python_similarity.txt
Q: trying to import a file of python (where I have the functions) into my main python file hello as i said in my question i am trying to import a file of python (where I have the functions) into my main python file, the file imports however, it gives me an error saying "accounts" is not defined (which is a list I mad...
trying to import a file of python (where I have the functions) into my main python file
hello as i said in my question i am trying to import a file of python (where I have the functions) into my main python file, the file imports however, it gives me an error saying "accounts" is not defined (which is a list I made). I assume this happens because the main file has it defined, but the function file doesn't...
[ "To import a python file into your main file:\nimport #(file name)\n\nor if you want to import a function from a python file to the main file:\nfrom \"\"\"file name remove the \". \"\"\" import #function to import from the file\n\n\nPlease note that the file you are importing from should be in the same\nlocation as...
[ 1, 0, 0 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0068064158_python_tkinter.txt
Q: Python Latex Library I often work with groups of materials and my file/materials are named as alphanumeric strings. Is there a library to turn a string like r"Mxene - Ti3C2" to latex styled r"Mxene - Ti$_\mathrm{3}$C$_\mathrm{2}$"? I usually use a dictionary but going through every name is a hassle and prone to er...
Python Latex Library
I often work with groups of materials and my file/materials are named as alphanumeric strings. Is there a library to turn a string like r"Mxene - Ti3C2" to latex styled r"Mxene - Ti$_\mathrm{3}$C$_\mathrm{2}$"? I usually use a dictionary but going through every name is a hassle and prone to error because materials can ...
[ "I've ultimately created this solution in case anyone else needs it. Since my problem is mostly to create subscripts, the following code will look for numbers and replace them with a latex equivalent to create one.\ndef latexify(s):\n\n import re\n nums = re.findall(r'\\d+', s)\n pos = [[m.start(0), m.end(...
[ 0 ]
[]
[]
[ "latex", "python" ]
stackoverflow_0074275485_latex_python.txt
Q: Python Pandas how to test equality between pandas columns that are category data types I have large datasets that I cross-join with python pandas. Both datasets load in pandas and I convert all 'object' columns to 'category'. The issue is I need to pd.query() against various 'category' dtype columns. When doing so...
Python Pandas how to test equality between pandas columns that are category data types
I have large datasets that I cross-join with python pandas. Both datasets load in pandas and I convert all 'object' columns to 'category'. The issue is I need to pd.query() against various 'category' dtype columns. When doing so with 'category' columns it returns an error (I expect this because not all columns have the...
[ "You can use union_categoricals to do what you want.\nThen to compare your two columns you code will look like this:\nfrom pandas.api.types import union_categoricals\n\nunion = union_categoricals([df.c1, df.c2]).categories\n\ndf['c1'] = df.c1.cat.set_categories(union)\ndf['c2'] = df.c2.cat.set_categories(union)\n\n...
[ 3 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074284055_pandas_python.txt
Q: 'pyarrow' is not installed - Snowpark stored procedure with Python I have created this basic stored procedure to query a Snowflake table based on a customer id: CREATE OR REPLACE PROCEDURE SP_Snowpark_Python_Revenue_2(site_id STRING) RETURNS STRING LANGUAGE PYTHON RUNTIME_VERSION = '3.8' PACKAGES = ('snowflake-sno...
'pyarrow' is not installed - Snowpark stored procedure with Python
I have created this basic stored procedure to query a Snowflake table based on a customer id: CREATE OR REPLACE PROCEDURE SP_Snowpark_Python_Revenue_2(site_id STRING) RETURNS STRING LANGUAGE PYTHON RUNTIME_VERSION = '3.8' PACKAGES = ('snowflake-snowpark-python') HANDLER = 'run' AS $$ from snowflake.snowpark.functions i...
[ "You need to ask for pyarrow as a package:\nPACKAGES = ('snowflake-snowpark-python', 'pyarrow')\n\nBut to get these packages, someone in your org will need to approve the Anaconda terms of service, or you'll get the following error:\nSQL compilation error: Anaconda terms must be accepted by ORGADMIN to use Anaconda...
[ 1 ]
[]
[]
[ "pandas", "python", "snowflake_cloud_data_platform", "snowpark" ]
stackoverflow_0074281446_pandas_python_snowflake_cloud_data_platform_snowpark.txt
Q: Tweepy - Create tweet I'm trying to create a twitter bot that would tweet a randomly selected text within a list. When I use the Client.create_tweet(text='test') function, I get a message saying that I'm missing a required positional argument 'self'. From what I understand, this type of error is what you get when ...
Tweepy - Create tweet
I'm trying to create a twitter bot that would tweet a randomly selected text within a list. When I use the Client.create_tweet(text='test') function, I get a message saying that I'm missing a required positional argument 'self'. From what I understand, this type of error is what you get when you don't initialized a fun...
[ "Oops, here's a simple way to create a tweet with tweepy\nto start you need to create the Client and insert your self keys:\nimport tweepy\n\napi=tweepy.Client(\n bearer_token='',\n consumer_key='',\n consumer_secret='',\n access_token='',\n access_token_secret='', \n)\n\nafter that you can use try p...
[ 0 ]
[]
[]
[ "bots", "python", "tweepy", "twitter" ]
stackoverflow_0072588488_bots_python_tweepy_twitter.txt
Q: FIX Protocol : 35=8 Execution Report coming in log file but not passing through fromApp()/onMessage() I am sending the below FIX sample message using the quickfix python library. 8=FIX4.4,9=225,35=D,34=3,49=AB,52=20220919-07:43:13.917,56=CD,11=44536,15=EUR,17=00002,21=3,37=44536,38=918293,40=2,44=0,48=11,54=1,55=E...
FIX Protocol : 35=8 Execution Report coming in log file but not passing through fromApp()/onMessage()
I am sending the below FIX sample message using the quickfix python library. 8=FIX4.4,9=225,35=D,34=3,49=AB,52=20220919-07:43:13.917,56=CD,11=44536,15=EUR,17=00002,21=3,37=44536,38=918293,40=2,44=0,48=11,54=1,55=EURUSD,58=LKLA, 59=0,60=20220919-07:43:13.917,64=20220921,78=1,79=LKLA,80=918293,448=f88f2f6277,10=097 Imme...
[ "The reasons I know are:\n\nYour lib might be ignoring PossDupFlag(43=Y) messages (IgnorePossDupResendRequests=Y configured if you are using QuickfixN - http://quickfixn.org/tutorial/configuration.html)\nYour system is rejecting the messages that don't match against the DataDictionary used by the other counter part...
[ 0 ]
[]
[]
[ "fix_protocol", "python", "quickfix" ]
stackoverflow_0073853338_fix_protocol_python_quickfix.txt
Q: How does one ignore extra arguments passed to a dataclass? I'd like to create a config dataclass in order to simplify whitelisting of and access to specific environment variables (typing os.environ['VAR_NAME'] is tedious relative to config.VAR_NAME). I therefore need to ignore unused environment variables in my da...
How does one ignore extra arguments passed to a dataclass?
I'd like to create a config dataclass in order to simplify whitelisting of and access to specific environment variables (typing os.environ['VAR_NAME'] is tedious relative to config.VAR_NAME). I therefore need to ignore unused environment variables in my dataclass's __init__ function, but I don't know how to extract the...
[ "Cleaning the argument list before passing it to the constructor is probably the best way to go about it. I'd advice against writing your own __init__ function though, since the dataclass' __init__ does a couple of other convenient things that you'll lose by overriding it.\nAlso, since the argument-cleaning logic i...
[ 53, 26, 7, 0, 0 ]
[]
[]
[ "python", "python_3.x", "python_dataclasses" ]
stackoverflow_0054678337_python_python_3.x_python_dataclasses.txt
Q: I want to populate the column of a dataframe with values from the column of another dataframe when the values of two columns match I want to populate values of df2['VALUE'] in a new column in df1 df1['New'] when category and location match for both dataframes. When df1['category'] = df2['CATEGORY'] AND df1['locat...
I want to populate the column of a dataframe with values from the column of another dataframe when the values of two columns match
I want to populate values of df2['VALUE'] in a new column in df1 df1['New'] when category and location match for both dataframes. When df1['category'] = df2['CATEGORY'] AND df1['location'] = df2['LOCATION'] populate values of df2['VALUE'] into a new row in df1 so that using df1['v1'] I can calculate df1['calculatedfie...
[ "You can use pandas.set_index() function to create a multiIndex dataframe for obtaining values from df2 and use the pandas.reset.index() to reset the dataframe. Please see below my sample code. I have replicated your dataframes df1 and df2.\ncode:\nimport pandas as pd\n\ndata1 = {'category': ['A', 'A', 'A', 'A','B'...
[ 0 ]
[]
[]
[ "dataframe", "numpy", "pandas", "populate", "python" ]
stackoverflow_0074283571_dataframe_numpy_pandas_populate_python.txt
Q: Pandas: efficient way to replace entire string with a substring I have a dataframe that looks like this: df = pd.DataFrame({ 'name': ['John','William', 'Nancy', 'Susan', 'Robert', 'Lucy', 'Blake', 'Sally', 'Bruce'], 'injury': ['right hand broken', 'lacerated left foot', 'foot broken', 'right foot fractured...
Pandas: efficient way to replace entire string with a substring
I have a dataframe that looks like this: df = pd.DataFrame({ 'name': ['John','William', 'Nancy', 'Susan', 'Robert', 'Lucy', 'Blake', 'Sally', 'Bruce'], 'injury': ['right hand broken', 'lacerated left foot', 'foot broken', 'right foot fractured', '', 'sprained finger', 'chest pain', 'swelling in arm', 'laceratio...
[ "The standard way to get the first match of a regex on a string column is to use .extract(), please see the quickstart 10 minutes to pandas: working with text data.\ndf['injury'].str.extract('(arm|chest|finger|foot|hand)', expand=False)\n\n0 hand\n1 foot\n2 foot\n3 foot\n4 NaN\n5 finger...
[ 0, 0, 0 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074284156_pandas_python.txt
Q: ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type int) I am trying to tune the hyperparameters of MLP sequential model but getting an error while performing this task. I have tried degrading/upgrading the scikit-learn version and using np.asarray(X).astype(np.int) and np.asarray(X).a...
ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type int)
I am trying to tune the hyperparameters of MLP sequential model but getting an error while performing this task. I have tried degrading/upgrading the scikit-learn version and using np.asarray(X).astype(np.int) and np.asarray(X).astype(np.float32) but still getting the error. Please someone help me with how to fix this ...
[ "The error may be faulty data pre processing;make sure that everything is properly formatted.\nBelow shows what the model expects as inputs:\n[print(i.shape, i.dtype) for i in model.inputs]\n[print(o.shape, o.dtype) for o in model.outputs]\n[print(l.name, l.input_shape, l.dtype) for l in model.layers]\n\nPass the d...
[ 0 ]
[]
[]
[ "keras", "machine_learning", "python", "tensorflow" ]
stackoverflow_0067030417_keras_machine_learning_python_tensorflow.txt
Q: Animate a tkinter frame I want to create a tkinter animation in which a frame on all its contents move from right to left. After clicking the button, the frame and its contents should move from left to right. I was able to achieve the former but when I click the button, the frame and its contents disappear. imp...
Animate a tkinter frame
I want to create a tkinter animation in which a frame on all its contents move from right to left. After clicking the button, the frame and its contents should move from left to right. I was able to achieve the former but when I click the button, the frame and its contents disappear. import tkinter as tk from tkint...
[ "I had tested your code, when the windows is expanded, you can see that after button is clicked, the section teleported back to the original position.\nIn another word, the section did not disappear, it instead reach the destination instantly.\nThis is cause by you using i as parameter in contract(), since x=i, pas...
[ 1 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0074284031_python_tkinter.txt
Q: leetcode 39. Combination Sum why do I have to return after I get one solution? so the question is like this: Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in ...
leetcode 39. Combination Sum why do I have to return after I get one solution?
so the question is like this: Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order. The same number may be chosen from candidates an unlimited number of time...
[ "Just print each your steps and you will see why it works.\nFor example, if you don't add return after res.append(cur[:]), what happens?\ni = 1 cur = [2, 2, 3] total = 7\n\nThen you will add cur to res\nres = [[2, 2, 3]]\n\nBut you will go next because i = 1 < len(candidates) AND total < target.\ni = 2 cur =...
[ 1 ]
[]
[]
[ "backtracking", "depth_first_search", "python" ]
stackoverflow_0074284276_backtracking_depth_first_search_python.txt
Q: Seperate values in specific dataframe column to some row I have dataframe with multivalue in some columns df = pd.DataFrame({'id': ['1','2','3',], 'fruits': ['apple, Apple','Orange, grapefruit','Melon'], 'count': [2,2,1]}) I want to seperate the value in fruits column, so my ...
Seperate values in specific dataframe column to some row
I have dataframe with multivalue in some columns df = pd.DataFrame({'id': ['1','2','3',], 'fruits': ['apple, Apple','Orange, grapefruit','Melon'], 'count': [2,2,1]}) I want to seperate the value in fruits column, so my dataframe become like this id fruits 1 apple 1 Apple 2 ...
[ "you can use the str methods with explode on the relevant columns:\nser = df.fruits.str.split(\",\\s\").explode()\n\noutput:\n0 apple\n0 Apple\n1 Orange\n1 grapefruit\n2 Melon\nName: fruits, dtype: object\n\nif you wish to keep the id:\ndf2 = pd.DataFrame(ser)\ndf2['id'] = df['id']...
[ 2, 2, 1 ]
[]
[]
[ "dataframe", "pandas", "python" ]
stackoverflow_0074284263_dataframe_pandas_python.txt
Q: Delete Specific Rows from a NumPy Array I have 2 numpy arrays: A [['12345' 45 100] ['12345' 29 100] ['45451' 23 0] ['56789' 45 450] ['56789' 56 50] ['56567' 5 500] ['89321' 15 0] ['90234' 43 40] ['90234' 55 0] ['99843' 18 5500]] B [['12345'] ['90234'] ['45451'] ['56789'] ['89321']] I need to leave...
Delete Specific Rows from a NumPy Array
I have 2 numpy arrays: A [['12345' 45 100] ['12345' 29 100] ['45451' 23 0] ['56789' 45 450] ['56789' 56 50] ['56567' 5 500] ['89321' 15 0] ['90234' 43 40] ['90234' 55 0] ['99843' 18 5500]] B [['12345'] ['90234'] ['45451'] ['56789'] ['89321']] I need to leave in array B only rows where elements equals t...
[ "In this line\nif (A[ind1][0] == B[ind2]) and (A[ind1][2] > 0):\n\nIt should be as\nif (A[ind1][:, :1] == B[ind2]) and (A[ind1][2] > 0):\n\nIn the 2nd line where the changes made, you are trying to match the first column in array A to array B, this should work\n", "import numpy as np\na = np.array(\n [[12345, ...
[ 0, 0 ]
[]
[]
[ "arrays", "numpy", "pandas", "python" ]
stackoverflow_0074281701_arrays_numpy_pandas_python.txt
Q: I am categorizing the data, but my results are no the expectable I am categorizing the data, but my results are no the expectable. Here's the code: import pandas as pd import numpy as np df=pd.read_csv(r'C:\Users\gabri\Downloads\credit_scoring_eng.csv') def assign_status(row): test='Negado' # Desempregad...
I am categorizing the data, but my results are no the expectable
I am categorizing the data, but my results are no the expectable. Here's the code: import pandas as pd import numpy as np df=pd.read_csv(r'C:\Users\gabri\Downloads\credit_scoring_eng.csv') def assign_status(row): test='Negado' # Desempregado if row['income_type']=='unemployed': test='N' #...
[ "Ahh, overlooked something, replace the '&' in the if/elif statements with and and retest\nthanks for the accept\n" ]
[ 1 ]
[]
[]
[ "apply", "dataframe", "pandas", "python", "series" ]
stackoverflow_0074258221_apply_dataframe_pandas_python_series.txt
Q: How to debug a Flask app How are you meant to debug errors in Flask? Print to the console? Flash messages to the page? Or is there a more powerful option available to figure out what's happening when something goes wrong? A: Running the app in debug mode will show an interactive traceback and console in the b...
How to debug a Flask app
How are you meant to debug errors in Flask? Print to the console? Flash messages to the page? Or is there a more powerful option available to figure out what's happening when something goes wrong?
[ "Running the app in debug mode will show an interactive traceback and console in the browser when there is an error. As of Flask 2.2, to run in debug mode, pass the --app and --debug options to the flask command.\n$ flask --app example --debug run\n\n\nPrior to Flask 2.2, this was controlled by the FLASK_ENV=develo...
[ 192, 52, 33, 23, 18, 14, 12, 8, 5, 5, 5, 3, 0 ]
[ "Use loggers and print statements in the Development Environment, you can go for sentry in case of production environments.\n" ]
[ -1 ]
[ "debugging", "flask", "python" ]
stackoverflow_0017309889_debugging_flask_python.txt
Q: Minimax evaluation in chess I am implementing an artificial intelligence that plays chess using the minimax algorithm. The initial board I have is white rook and white king against black rook and black king. All the evaluations I've thought of, do not provide enough intelligence to my IA. What could be a good eval...
Minimax evaluation in chess
I am implementing an artificial intelligence that plays chess using the minimax algorithm. The initial board I have is white rook and white king against black rook and black king. All the evaluations I've thought of, do not provide enough intelligence to my IA. What could be a good evaluation of this especific configur...
[ "Do you just want an evaluation function that works in this specific case, and not a general one? There are two options that you can implement, if you want it to work for other cases you can just expand on these:\n\nMore advanced: Read up on https://www.chessprogramming.org/Endgame where you find links to some conc...
[ 1 ]
[]
[]
[ "chess", "minimax", "python" ]
stackoverflow_0074260691_chess_minimax_python.txt
Q: Binary Search Tree with user inputted data I'm trying to create a binary search tree where the user can input data into the main(), where the first number will be the root, and the rest will be sorted and printed into pre-order from there. Python. I'm new to this, and am pretty lost. So far, it's making the user i...
Binary Search Tree with user inputted data
I'm trying to create a binary search tree where the user can input data into the main(), where the first number will be the root, and the rest will be sorted and printed into pre-order from there. Python. I'm new to this, and am pretty lost. So far, it's making the user input data twice, and it won't do the insert func...
[ "Your code has several problem.\n\nYou call main() too much. Whenever you call main(), it requests you to give an array.\n\nYou split input wrong. I guess you want to make BST with int. You can do like this.\n\n\nkeys = list(map(int,input('Enter data to construct a BST (numbers divided by a space): ').split()))\n\n...
[ 0 ]
[]
[]
[ "binary_search_tree", "preorder", "python" ]
stackoverflow_0074284256_binary_search_tree_preorder_python.txt
Q: Random Names picker with new draws on Each new Button Click I'm trying to select random names from a list to display on a textbox in a tkinter GUI, with a button and need new draws to display in tkinter script each time I click the button. Here's my code so far: from tkinter import * from random import sample ro...
Random Names picker with new draws on Each new Button Click
I'm trying to select random names from a list to display on a textbox in a tkinter GUI, with a button and need new draws to display in tkinter script each time I click the button. Here's my code so far: from tkinter import * from random import sample root = Tk() root.title('Name Picker') root.iconbitmap('c:/myguipyth...
[ "In your code you are calling the widget constructor for the Text widget every time you press the button. What you should do is create the widget outside of the function and use the function just to update the widget's contents. There is also quite a bit of erroneous code as well.\nFor example:\nfrom tkinter impo...
[ 1 ]
[]
[]
[ "button", "python", "python_3.x", "tkinter" ]
stackoverflow_0074283438_button_python_python_3.x_tkinter.txt
Q: How to scrape a website which requires login using python i want to webscrpe this website and i need to login to get the account datail (https://online.cspension.com.hk/hkpensionweb/#/login?source=corporateHK&vgnLocale=en_CA), i don't want to use selenium how to login and get the account datail A: You can use a ...
How to scrape a website which requires login using python
i want to webscrpe this website and i need to login to get the account datail (https://online.cspension.com.hk/hkpensionweb/#/login?source=corporateHK&vgnLocale=en_CA), i don't want to use selenium how to login and get the account datail
[ "You can use a requests.Session() instance to make a post request to the login url with your login details as a payload. Making requests from a session instance is essentially the same as using requests normally, it simply adds persistence, allowing you to store and use cookies etc.\nimport requests\n\n# Fill in yo...
[ 3 ]
[]
[]
[ "python", "web_scraping" ]
stackoverflow_0074284543_python_web_scraping.txt
Q: Cannot start Jupyter Notebook kernel in VSCode I tried to install the Jupyter Notebook Kernel on VSCode, and it cant seem to connect, it shows this text in the VSCode: Failed to start the Kernel. C:\Users\Theodore\AppData\Roaming\Python\Python310\site-packages\traitlets\traitlets.py:2412: FutureWarning: Supportin...
Cannot start Jupyter Notebook kernel in VSCode
I tried to install the Jupyter Notebook Kernel on VSCode, and it cant seem to connect, it shows this text in the VSCode: Failed to start the Kernel. C:\Users\Theodore\AppData\Roaming\Python\Python310\site-packages\traitlets\traitlets.py:2412: FutureWarning: Supporting extra quotes around strings is deprecated in trait...
[ "Turns out I have a VPN, and it made it crash, i used this in the CMD:\nnetsh winsock reset\n\nand it worked. Thanks for your help\n", "Use command pip install ipykernel in the cmd.\nAlternative method:\nUse following command in the terminal to reinstall pyzmq package.\npip uninstall pyzmq\npip install pyzmq\n\n"...
[ 1, 0 ]
[]
[]
[ "jupyter_notebook", "python", "visual_studio_code" ]
stackoverflow_0074276517_jupyter_notebook_python_visual_studio_code.txt
Q: PyQt5 - How to make a push button always has true value when click down and false value when it has up Im just try to use PyQt5 for my robot GUI. im little bit confuse how to use momentary push button which should giving true value when it pressed down and false value when it unpressed. fyi im using python for thi...
PyQt5 - How to make a push button always has true value when click down and false value when it has up
Im just try to use PyQt5 for my robot GUI. im little bit confuse how to use momentary push button which should giving true value when it pressed down and false value when it unpressed. fyi im using python for this. im already try to use "setCheckable" to detecting its state, but it make the button toggled (not momentar...
[ "The clicked signal is always emitted after the mouse button is released in the button rectangle. That's the common convention for a \"click event\" of buttons in almost any reasonable UI toolkit.\nIf you want to know when the button is pressed or released, then you can connect to the pressed and released signals.\...
[ 2 ]
[]
[]
[ "pyqt5", "python", "raspberry_pi" ]
stackoverflow_0074284511_pyqt5_python_raspberry_pi.txt
Q: Combining two serializer into one I have a ListApiView where i list the data on a website and on the same page i could select the records and export to xl and pdf file here right now i am using same serializer called ListingSerializer for exporting the data to file and listing it, for listing the data and exportin...
Combining two serializer into one
I have a ListApiView where i list the data on a website and on the same page i could select the records and export to xl and pdf file here right now i am using same serializer called ListingSerializer for exporting the data to file and listing it, for listing the data and exporting the fields are same except for export...
[ "You can inherit form another serializer. In your example:\nclass ListingSerializer(serializers.ModelSerializer):\n class Meta:\n \n model = Mymodel\n fields = '__all__'\n\nclass ExportSerializer(ListingSerializer):\n date_records_received = serializers.SerializerMethodField()\n\n\n" ]
[ 0 ]
[]
[]
[ "django", "django_models", "django_rest_framework", "django_views", "python" ]
stackoverflow_0074284667_django_django_models_django_rest_framework_django_views_python.txt
Q: Get hrefs from Tags Located in the Divs with a Specific Classes Using BeautifulSoup I need to get hrefs from <a> tags in a website, but not all, but only ones that are in the spans locted in the <div>s with classes arm <html> <body> <div class="arm"> <span> <a href="1">link</a> <a href...
Get hrefs from Tags Located in the Divs with a Specific Classes Using BeautifulSoup
I need to get hrefs from <a> tags in a website, but not all, but only ones that are in the spans locted in the <div>s with classes arm <html> <body> <div class="arm"> <span> <a href="1">link</a> <a href="2">link</a> <a href="3">link</a> </span> </div> <div class="arm"> ...
[ "Try using the find.all() method to obtain the values in a specific tags and class\nI have replicated your HTML file and obtain the values in the span tag. Please see my sample code below.\nReplicated HTML file:\n# Creating the HTML file\nfile_html = open(\"demo.html\", \"w\")\n# Adding the input data to the HTML f...
[ 0, 0 ]
[]
[]
[ "beautifulsoup", "parsing", "python" ]
stackoverflow_0074284552_beautifulsoup_parsing_python.txt
Q: Problem with compiling a hikari discord bot to an exe Recently, I have tried to compile a hikari discord bot to an exe (because many computers may not have a python interpreter installed), I tried pyinstaller, py2exe and autopytoexe though none of them worked. When I ran the exe they all returned the same error me...
Problem with compiling a hikari discord bot to an exe
Recently, I have tried to compile a hikari discord bot to an exe (because many computers may not have a python interpreter installed), I tried pyinstaller, py2exe and autopytoexe though none of them worked. When I ran the exe they all returned the same error message of: "FileNotFoundError: D:\MyDir\dist\library.aip/hik...
[ "did you already try to add 'banner.txt' in the 'Additional Files' menu in Auto Py to Exe\n\n", "To solve this problem I avoided using to exe compilers and instead just included a python interpreter with hikari installed to run the python source code.\n" ]
[ 0, 0 ]
[]
[]
[ "bots", "discord", "filenotfounderror", "python" ]
stackoverflow_0072665715_bots_discord_filenotfounderror_python.txt
Q: How to sort Python strings both alphabetically by prefix and numerically by suffix? I need to sort a list of strings, of the form: ["ccc_3.23", "b_0.00", "b_-1.10", "aa_-2.37", "aa_3.05", "aa_-2.11", "ccc_9.8"] first by prefix, then by suffix, such that the sorted list is: ["aa_-2.37", "aa_-2.11", "aa_3.05", "b_-...
How to sort Python strings both alphabetically by prefix and numerically by suffix?
I need to sort a list of strings, of the form: ["ccc_3.23", "b_0.00", "b_-1.10", "aa_-2.37", "aa_3.05", "aa_-2.11", "ccc_9.8"] first by prefix, then by suffix, such that the sorted list is: ["aa_-2.37", "aa_-2.11", "aa_3.05", "b_-1.17", "b_0.00", "ccc_3.23", "ccc_9.8"] The prefixes only contain standard english lette...
[ "You need to use key in sort\na = [\"ccc_3.23\", \"b_0.00\", \"b_-1.10\", \"aa_-2.37\", \"aa_3.05\", \"aa_-2.11\", \"ccc_9.8\"]\na.sort(key=lambda x: (x.split(\"_\")[0], float(x.split(\"_\")[1])))\na\n# output : ['aa_-2.37', 'aa_-2.11', 'aa_3.05', 'b_-1.10', 'b_0.00', 'ccc_3.23', 'ccc_9.8']\n\n" ]
[ 7 ]
[]
[]
[ "prefix", "python", "sorting", "string", "suffix" ]
stackoverflow_0074284758_prefix_python_sorting_string_suffix.txt
Q: Save distance between sets of coordinates to new column I have a bunch of coordinates in my dataframe that look like this: Start_Lat: 43.11944 Start_Lng: -75.2932 End_Lat: 43.12029 End_lng: -75.2935 I am basically wanting to create a new column in my dataframe that has the distance between the two sets of coordi...
Save distance between sets of coordinates to new column
I have a bunch of coordinates in my dataframe that look like this: Start_Lat: 43.11944 Start_Lng: -75.2932 End_Lat: 43.12029 End_lng: -75.2935 I am basically wanting to create a new column in my dataframe that has the distance between the two sets of coordinates in km (see below example). Distance: 0.0984 This is w...
[ "Have worked this out, here is solution for anyone that is looking:\ndata['km'] = data.apply(lambda x: distance.distance((x['Start_Lat'], x['Start_Lng']), (x['End_Lat'], x['End_Lng'])), axis=1)\n\n" ]
[ 1 ]
[]
[]
[ "coordinates", "distance", "geopy", "latitude_longitude", "python" ]
stackoverflow_0074284423_coordinates_distance_geopy_latitude_longitude_python.txt
Q: Get the current session history only for Python interactive session? This question is specific to using the python -i command (not IPython): how can I limit the exported history to commands from the current session only? Specifically, when I run Python via terminal (python -i) and then type the following commands:...
Get the current session history only for Python interactive session?
This question is specific to using the python -i command (not IPython): how can I limit the exported history to commands from the current session only? Specifically, when I run Python via terminal (python -i) and then type the following commands: from pathlib import Path x = Path('abc') from readlines import write_hist...
[ "Using [Doskey][1]/history we can all previous command. ONLY WORKS ON WINDOWS. You can use readlines if you are using IPYTHON\nimport subprocess\n\ncmd_history = subprocess.check_output([\"doskey\", \"/history\"])\ncmd_history_list = [line.strip() for line in cmd_history.decode(\"utf-8\").splitlines()]\npython_cmd_...
[ 0 ]
[]
[]
[ "python", "python_interactive", "session" ]
stackoverflow_0074284683_python_python_interactive_session.txt
Q: finding specific pattern in string in python I have a String "Everything is fine", and I want to find a string that starts with "Eve" and ends with "ing", middle letters could be any letter. How can I do it in python? A: Assuming this is your string my_string = "Everything is fine" You can do the following my_s...
finding specific pattern in string in python
I have a String "Everything is fine", and I want to find a string that starts with "Eve" and ends with "ing", middle letters could be any letter. How can I do it in python?
[ "Assuming this is your string\nmy_string = \"Everything is fine\"\n\nYou can do the following\nmy_string.split(\" \")\nfor word in my_string.split(\" \"):\n if word[:3] == \"Eve\" and word[-3:] == \"ing\":\n print(word)\n else:\n pass\n\nAlso you can assign all these words in a list like that\nm...
[ 0 ]
[]
[]
[ "python", "string" ]
stackoverflow_0074284605_python_string.txt
Q: How to change text color from a python module (tqdm module) output ? (so not python text editor output) I am using the dark theme in Google Colab which automatically transforms text color from output to white. However, now I am using the progressbar from TQDM module and I get text that is dark colored which is pro...
How to change text color from a python module (tqdm module) output ? (so not python text editor output)
I am using the dark theme in Google Colab which automatically transforms text color from output to white. However, now I am using the progressbar from TQDM module and I get text that is dark colored which is problematic in the dark theme. I was thinking of Colorama but it only changes text color for the text edit (I th...
[ "I was having this issue in Colab, and running the following code in a cell solved it for me:\n# Set the tqdm text color to white.\n\nfrom IPython.display import HTML, display\n\ndef set_css_in_cell_output():\n display(HTML('''\n <style>\n .jupyter-widgets {color: #d5d5d5 !important;}\n ...
[ 0 ]
[ "tqdm==4.64.1\nThe tqdm function has an argument colour\ntqdm(m_db,colour='green')\n\ncomplete code\nfor i in tqdm(range(5), colour=\"green\"):\n print(i)\n\n" ]
[ -1 ]
[ "colors", "python", "text" ]
stackoverflow_0065269314_colors_python_text.txt
Q: how to group a column in table where we need get maximum occurred value in second column in pandas In Pandas I have a table name sec emp1 a emp1 a emp1 b emp2 a emp2 b emp2 c emp2 c i want to extract each name with max count of sec like name sec emp1 a em...
how to group a column in table where we need get maximum occurred value in second column in pandas
In Pandas I have a table name sec emp1 a emp1 a emp1 b emp2 a emp2 b emp2 c emp2 c i want to extract each name with max count of sec like name sec emp1 a emp2 c in pandas in know we can use groupBy but do not know how to get this format. df.groupby(['name','...
[ "Use groupby and agg together.\n>>> df.groupby(['name'], as_index = False)[['sec']].agg(pd.Series.mode) \n name sec\n0 emp1 a\n1 emp2 c\n\n\n", "Rather than .size(),\nyou are looking for .mode().\nhttps://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.mode.html\n", "mode won't work for...
[ 2, 0, 0 ]
[]
[]
[ "group_by", "pandas", "python" ]
stackoverflow_0074284691_group_by_pandas_python.txt
Q: How to make a new column based on condition from multiple columns I have a dataframe contains a few columns where the value is either 0 or 1 A B C D E 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 So how to create a new column "F" where the condition is : if column A,B,C,D,E contains 1 so the value of F will be 1...
How to make a new column based on condition from multiple columns
I have a dataframe contains a few columns where the value is either 0 or 1 A B C D E 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 So how to create a new column "F" where the condition is : if column A,B,C,D,E contains 1 so the value of F will be 1. Here's an example of the expected output A B C D E F...
[ "df['F'] = df.max(axis=1)\n\nor\ndf['F'] = df.any(axis=1).astype(int)\n\n A B C D E F\n0 0 0 0 0 0 0\n1 0 1 0 0 0 1\n2 0 0 1 1 0 1\n3 0 0 0 0 1 1\n\n" ]
[ 2 ]
[]
[]
[ "dataframe", "python" ]
stackoverflow_0074284884_dataframe_python.txt
Q: Cannot import mediapipe - "ModuleNotFoundError: No module named 'mediapipe'" I have installed mediapipe , but I can't import it. pip3 install mediapipe==0.8.4.0 pip3 list mediapipe == 0.8.4 numpy == 1.23.3 opencv-contrib-python == 4.6.0.66 tensorflow == 2.10.0 python --version Python 3.9.6 I try to runn this...
Cannot import mediapipe - "ModuleNotFoundError: No module named 'mediapipe'"
I have installed mediapipe , but I can't import it. pip3 install mediapipe==0.8.4.0 pip3 list mediapipe == 0.8.4 numpy == 1.23.3 opencv-contrib-python == 4.6.0.66 tensorflow == 2.10.0 python --version Python 3.9.6 I try to runn this in the VS Code editor on Mac(Intel) import cv2 import mediapipe as mp and I get...
[ "As far as I know, the Python interpreter in VSCode must be set to the correct version 3.9.6. Simply Ctrl+Shift+P and search for Python: Select Interpreter\n\n" ]
[ -2 ]
[]
[]
[ "macos", "mediapipe", "python" ]
stackoverflow_0074132887_macos_mediapipe_python.txt
Q: Is it possible to use the Python Embeddable package as the vscode interperter? I have the vscode python extension, which requires a Python interpreter. When trying to use the Python installer, it asks for the admin password which I don't have. However, the embeddable comes with a Python executable, so I figured I ...
Is it possible to use the Python Embeddable package as the vscode interperter?
I have the vscode python extension, which requires a Python interpreter. When trying to use the Python installer, it asks for the admin password which I don't have. However, the embeddable comes with a Python executable, so I figured I could just use that. But when setting it to use the python.exe that comes in the emb...
[ "Of course it is possible to use an embeddable package as an interpreter.\nFirst download python 3.11 embeddable package from the official website( Here is the windows system. ),\n\nand then unzip it to your computer. Older systems may require additional download and use of an unzip tool.\n\nNote that the path shou...
[ 0 ]
[]
[]
[ "python", "visual_studio_code" ]
stackoverflow_0074280408_python_visual_studio_code.txt
Q: Interrupt ThreadPoolExecutor How can I immediately stop a concurrent.futures.ThreadPoolExecutor and discard any pending operations when a script is interrupted, as in the example below: import requests from concurrent.futures import ThreadPoolExecutor, as_completed def get_parallel(arguments_list: list[dict]): ...
Interrupt ThreadPoolExecutor
How can I immediately stop a concurrent.futures.ThreadPoolExecutor and discard any pending operations when a script is interrupted, as in the example below: import requests from concurrent.futures import ThreadPoolExecutor, as_completed def get_parallel(arguments_list: list[dict]): try: with ThreadPoolExe...
[ "You can't signal individual threads in python and even if you could, there's no guarantee that requests didn't create its own threads as workers. You can kill processes, so you could delegate the request to a subprocess and kill it when you get a keyboard interrupt. The cleanest way to do this is to manage your ow...
[ 1, 1 ]
[]
[]
[ "concurrent.futures", "python" ]
stackoverflow_0069691136_concurrent.futures_python.txt
Q: how to check if a file exists based on the files in a directory and indicate which are missing? how do I check which files are missing from the directory based on a txt of the files I should have? E.G this is the list of files I should have A B C D E F G H I But in my directory I only have A.npy B.npy C.npy D.n...
how to check if a file exists based on the files in a directory and indicate which are missing?
how do I check which files are missing from the directory based on a txt of the files I should have? E.G this is the list of files I should have A B C D E F G H I But in my directory I only have A.npy B.npy C.npy D.npy So I want to do a script that can produce a result.txt like this: A [exists] B [exists] C [ex...
[ "Your program works for me after fixing the following two issues:\nIssue 1\nlof = [x[:len(x) - 4] for x in lof[0] if x[0] == 'P']\n\nI don't think you want to only list files that start with the letter 'P'. Perhaps you left this in by mistake after doing some debugging or something. To get all file names remove the...
[ 1, 0 ]
[]
[]
[ "file", "io", "python" ]
stackoverflow_0074284823_file_io_python.txt
Q: when this code didn't run,the next line code begin to run How to control this line code finished running, the next line begin to run. import flask import os def start_predictor(): os.system("python ok.py") os.system("python finish.py") if __name__ == "__main__": torch.multiprocessing.set_start_method(...
when this code didn't run,the next line code begin to run
How to control this line code finished running, the next line begin to run. import flask import os def start_predictor(): os.system("python ok.py") os.system("python finish.py") if __name__ == "__main__": torch.multiprocessing.set_start_method("spawn", True) predictor_server = mp.Process(target=start_p...
[]
[]
[ "use subprocess\np = subprocess.Popen('test.exe')\np.wait()\n\n" ]
[ -1 ]
[ "python", "pytorch" ]
stackoverflow_0074285015_python_pytorch.txt
Q: Python Decorators | How the arguments of a function pass through a wrapper function In this decorators video by Corey Schafer he said the display_info function wouldn't run because it takes two arguments but wrapper_function takes 0 arguments. def decorator_function(original_function): def wrapper_function(): ...
Python Decorators | How the arguments of a function pass through a wrapper function
In this decorators video by Corey Schafer he said the display_info function wouldn't run because it takes two arguments but wrapper_function takes 0 arguments. def decorator_function(original_function): def wrapper_function(): print('wrapper executed this before {}'.format(original_function.__name__)) ...
[ "The decorator is similar with making hamburger, the only different in hamburger is stuffing, but all the hamburger will have the bread on the top and bottom. You can image the stuffing is display_info and bread is the code inside wrapper_function except your customized function and decorator_function is the hambur...
[ 0 ]
[]
[]
[ "decorator", "python", "python_decorators", "wrapper" ]
stackoverflow_0074284942_decorator_python_python_decorators_wrapper.txt
Q: np.float64 and dtype=object can not be serialized i have the below posted list and it contais lists, so it is a list of lists, and i have a webservice that returns return jsonify(resultsDict). the problem i am facing is when i run the App i recieve either of the error messages posted below. as shown in the code be...
np.float64 and dtype=object can not be serialized
i have the below posted list and it contais lists, so it is a list of lists, and i have a webservice that returns return jsonify(resultsDict). the problem i am facing is when i run the App i recieve either of the error messages posted below. as shown in the code below, i tried to set dtype=np.float64 and dtype=object, ...
[ "My suggestion is to use make lists equal in size first (if they don't differ by orders of magnitude) as in this example - List of lists into numpy array\nIn this way you will have an easier time deserializing it into list of lists. Also You can use external libraries like pickle if you want.\n", "If I try to mak...
[ 0, 0 ]
[]
[]
[ "json", "json_deserialization", "numpy", "python", "serialization" ]
stackoverflow_0074284982_json_json_deserialization_numpy_python_serialization.txt
Q: Trying to convert Multiple Py File into One EXE File PYQT5 I am trying to convert multiple py files ( main.py check.py free.py) into one exe file. I am using PYQT5. I have tired using AUTO PY TO EXE and I am not able to convert multiple file into 1 exe file. I have tried adding path to Additional Files but no luck...
Trying to convert Multiple Py File into One EXE File PYQT5
I am trying to convert multiple py files ( main.py check.py free.py) into one exe file. I am using PYQT5. I have tired using AUTO PY TO EXE and I am not able to convert multiple file into 1 exe file. I have tried adding path to Additional Files but no luck still. It does give me 1 file but however the functionaly doesn...
[ "I was able to make your project to work with pyinstaller. Here is a step by step for what you need to do to make it work for you.\n\ncreate a virtual enviornment py -m venv venv && venv\\scripts\\activate\ninstall your dependencies pip install PyQt5 pyinstaller\nwe need to make some changes to your login_fillin.p...
[ 0 ]
[]
[]
[ "auto_py_to_exe", "pyinstaller", "pyqt5", "python" ]
stackoverflow_0074284788_auto_py_to_exe_pyinstaller_pyqt5_python.txt
Q: Error loading psycopg2 module: DLL load failed while importing _psycopg: The specified module could not be found raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: DLL load failed while importing _psycopg: The specified mo...
Error loading psycopg2 module: DLL load failed while importing _psycopg: The specified module could not be found
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: DLL load failed while importing _psycopg: The specified module could not be found. i have installed letest postgres setup psycopg2 installed
[ "I just solve this error by installing second latest python version and to install PostgreSQL use pip install postgres this will install psycopg2 & psycopg2-binary\n", "Try to install psycopg2 with:\n pip install psycopg2-binary`\n\nsee psycopg2\n", "pip install psycopg2\n\nThis worked for me\n", "The way to ...
[ 1, 0, 0, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0064427613_django_python.txt
Q: Several error working with blogger/google API using python and service account auth I'm trying to access blogger API using the official Google python library and a service account with a JSON key file made at the Google Developer console. I'm using Linux Debian. google-api-python-client=2.65.0 The thing is that I'...
Several error working with blogger/google API using python and service account auth
I'm trying to access blogger API using the official Google python library and a service account with a JSON key file made at the Google Developer console. I'm using Linux Debian. google-api-python-client=2.65.0 The thing is that I'm getting this traceback: Traceback (most recent call last): File "/path/to/myproject/l...
[ "if you check the documentation Authorizing requests and identifying your application you will find that it states that you can use Oauth2 for authorizing a user to the blogger api and api keys. There is no mention of using service account authorization with this api.\nTo my knowledge as i tried about five years a...
[ 1 ]
[]
[]
[ "google_api", "google_api_python_client", "python" ]
stackoverflow_0074283197_google_api_google_api_python_client_python.txt
Q: Finding Element with Random ID [Python/Selenium] What the problem is: I'm new to Selenium and I'm trying to find an element on a webpage. The background is I want to write a script so that it can help me create instance on Oracle cloud. On the page where I have to select Compartment, I need to input my root name....
Finding Element with Random ID [Python/Selenium]
What the problem is: I'm new to Selenium and I'm trying to find an element on a webpage. The background is I want to write a script so that it can help me create instance on Oracle cloud. On the page where I have to select Compartment, I need to input my root name. I just can't find the input box. I beleive the eleme...
[ "It is inside an iframe, I checked my Oracle cloud account, try this, its working:\nWebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.ID, \"sandbox-compute-container\")))\n\ndriver.find_element(By.XPATH, \".//*[starts-with(@id,'active_compartment_select-')]//a\").click()\n\n", "You are...
[ 1, 0 ]
[]
[]
[ "python", "selenium", "web_scraping" ]
stackoverflow_0074284203_python_selenium_web_scraping.txt
Q: Running cells with "python 3.9.6 64-bit' requires ipykernnel installed or requires an update I just recently installed vs code (version 1.59.0) on my work computer (Windows). I installed python 3.9.6 extension. Because of high security, I'm unable to install extensions via pip install, I have to go to VS code mark...
Running cells with "python 3.9.6 64-bit' requires ipykernnel installed or requires an update
I just recently installed vs code (version 1.59.0) on my work computer (Windows). I installed python 3.9.6 extension. Because of high security, I'm unable to install extensions via pip install, I have to go to VS code marketplace and download VSIX files and then install packages via VSIX fiel!! .py scripts are running ...
[ "Afaik python interpreter in VSCode must be set to the correct version 3.9.6. Simply Ctrl+Shift+P and search for Python: Select Interpreter \n" ]
[ 0 ]
[]
[]
[ "ipython", "jupyter_notebook", "offline", "python", "visual_studio_code" ]
stackoverflow_0068719634_ipython_jupyter_notebook_offline_python_visual_studio_code.txt
Q: Discord.py - Bot token failing I'm currently trying to create a bot for Discord. For some reason the token gives me this error: 2022-11-02 04:42:10 INFO discord.client logging in using static token Traceback (most recent call last): File "main.py", line 26, in <module> client.run(os.getenv("bot_key")) ...
Discord.py - Bot token failing
I'm currently trying to create a bot for Discord. For some reason the token gives me this error: 2022-11-02 04:42:10 INFO discord.client logging in using static token Traceback (most recent call last): File "main.py", line 26, in <module> client.run(os.getenv("bot_key")) File "/home/runner/discord-moni-bot-...
[ "\nIt is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page.\n*Part of the error that you shown from the code.\n\nThe problem is you haven't enabled some permissions in the developer portal, not because of the TOKEN.\nFirst y...
[ 0 ]
[]
[]
[ "discord", "discord.py", "python" ]
stackoverflow_0074284467_discord_discord.py_python.txt
Q: Is it possible to detect that a user exists or not on my.forms.app using a python? Hey so i created a code where i can detect whether a website exists or not, this is the code that i use to detect that. exist=[] url = [] for b in websearch: try: request = requests.get(b) if request.status_code...
Is it possible to detect that a user exists or not on my.forms.app using a python?
Hey so i created a code where i can detect whether a website exists or not, this is the code that i use to detect that. exist=[] url = [] for b in websearch: try: request = requests.get(b) if request.status_code == 200: exist.append(b) print('Exist') except: prin...
[ "You can use your browser's network inspector to see what's happening in cases that aren't as clear-cut.\nhttps://my.forms.app/SOMETHINGRANDOMHERE makes a request to https://api.forms.app/user/infobyname/SOMETHINGRANDOMHERE, which returns a HTTP 204 No Content response if the user doesn't exist.\nFor a valid userna...
[ 0 ]
[]
[]
[ "jupyter_notebook", "python", "request" ]
stackoverflow_0074285200_jupyter_notebook_python_request.txt
Q: How to transform number that include alphabet to a new numerical order in pandas columns? I am trying to convert some columns that include number and alphabet at the same time. I want to convert to simple numerical value such as int. I don't want to just transform randomly because they are isbn involved. I want to...
How to transform number that include alphabet to a new numerical order in pandas columns?
I am trying to convert some columns that include number and alphabet at the same time. I want to convert to simple numerical value such as int. I don't want to just transform randomly because they are isbn involved. I want to able to match again. I want to transform that matching as below. d = {'id': [156972, 102154, 2...
[ "Use:\n#random shuffle order of rows\ndf1 = df.sample(frac=1)\n\n#create mapping dictionary by id\na, b = pd.factorize(df1['id'])\nd = dict(zip(b, a))\n\n#map original column\ndf['id'] = df['id'].map(d)\n\n" ]
[ 1 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074285193_pandas_python.txt
Q: Why 'series' object is not callable? I have an assignment that needs to assign df_confirmed_local to a DataFrame of confirmed cases that are local or epidemiologically linked with a local case, but when I run my code, it raises an error. df_confirmed_local = df_covid.loc [ (df_covid["Confirmed/probable"] == "Confi...
Why 'series' object is not callable?
I have an assignment that needs to assign df_confirmed_local to a DataFrame of confirmed cases that are local or epidemiologically linked with a local case, but when I run my code, it raises an error. df_confirmed_local = df_covid.loc [ (df_covid["Confirmed/probable"] == "Confirmed") & (df_covid["Case classificatio...
[ "Explanation:\nAs mentioned by the answer by @ArunJose, and the comment by @Minh-Long Luu, you have a boolean condition missing between the 2nd and 3rd condition, however it's an |.\n(column1 == foo) & (column2 == bar) | (column2 == baz)\n\nEach column is a pandas.Series object. When used in a boolean expression, i...
[ 2 ]
[]
[]
[ "python" ]
stackoverflow_0074278764_python.txt
Q: How to use a for loop to computer elements of an array? `import numpy as np import matplotlib.pyplot as plt import scipy c=299792458 #speed of light in nanometers per second h=6.62607015e-34 #plank's constant in m^2 kg per s kB=1.380649e-23 #Boltzmann's constant in m^2 kg per s^2 K π=np.pi def F(λ,n): re...
How to use a for loop to computer elements of an array?
`import numpy as np import matplotlib.pyplot as plt import scipy c=299792458 #speed of light in nanometers per second h=6.62607015e-34 #plank's constant in m^2 kg per s kB=1.380649e-23 #Boltzmann's constant in m^2 kg per s^2 K π=np.pi def F(λ,n): return ((2*π*h*c**2)/λ**5)*(1/(np.exp((h*c)/(λ*kB*n))-1)) def ...
[ "every for-loop iteration you rewrite mU name so after for-loop is worked you can get only mU that was created in the last for-loop iteration. \nif you need to get all mU from every loop you need to create some list before the loop and append mU on every loop iteration to that list. \nand finally you get what you n...
[ 1, 1 ]
[]
[]
[ "arrays", "for_loop", "python", "sorting" ]
stackoverflow_0074285175_arrays_for_loop_python_sorting.txt
Q: How to solve a "429: Too Many Requests" when running discord.py bot on repl.it? My code (see below) was running fine, but then this error popped up and doesn't go away: "http.py", line 293, in static_login data = await self.request(Route('GET', '/users/@me') File "/opt/virtualenvs/python3/lib/python3.8/site-...
How to solve a "429: Too Many Requests" when running discord.py bot on repl.it?
My code (see below) was running fine, but then this error popped up and doesn't go away: "http.py", line 293, in static_login data = await self.request(Route('GET', '/users/@me') File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 209, in request raise HTTPException(r, data) disc...
[ "Other than avoiding the error, there's a way to get around it. If discord.errors.HTTPException: 429 appears in the console on replit, just use the command kill 1 in the shell. This command completely exits the script, and when you click run again it will run from a different IP Address, bypassing the Discord rate ...
[ 5, 0 ]
[ "This worked perfect. If it keeps spamming that you're being rate limited then just run kill 1 again and it should be fine\n" ]
[ -2 ]
[ "discord", "discord.py", "python" ]
stackoverflow_0066724687_discord_discord.py_python.txt
Q: I want to change my categorical variables into numeric form using get_dummies function by using for loop on categorical columns I have dataset which have categorical and numeric features . I want to convert my categorical features into numeric form using for loop which iterate through only categorical variables an...
I want to change my categorical variables into numeric form using get_dummies function by using for loop on categorical columns
I have dataset which have categorical and numeric features . I want to convert my categorical features into numeric form using for loop which iterate through only categorical variables and convert them into numeric form. I tried this for i in df_balanced.columns[:-1]: if (df_balanced[i].dtype == 'object'): ...
[ "Use:\n#get DataFrame with categorical (non numeric columns)\ndf1 = df_balanced.iloc[:, :-1].select_dtypes(object)\n#remove categorical and join dummies\ndf = df.drop(df1.columns, axis=1).join(pd.get_dummies(df1, drop_first = True))\n\n" ]
[ 0 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074285123_pandas_python.txt
Q: installing urllib in Python3.6 I would like to import urllib to use the function 'request'. However, I encountered an error when trying to do so. I tried pip install urllib but still had the same error. I am using Python 3.6. Really appreciate any help. i do import urllib.request using this code: import urllib.req...
installing urllib in Python3.6
I would like to import urllib to use the function 'request'. However, I encountered an error when trying to do so. I tried pip install urllib but still had the same error. I am using Python 3.6. Really appreciate any help. i do import urllib.request using this code: import urllib.request, urllib.parse, urllib.error fh...
[ "urllib is a standard library, you do not have to install it. Simply import urllib\n", "urllib is a standard python library (built-in) so you don't have to install it. just import it if you need to use request by:\nimport urllib.request\n\nif it's not work maybe you compiled python in wrong way, so be kind and gi...
[ 54, 7, 5, 2, 0, 0 ]
[]
[]
[ "python", "python_3.x", "urllib" ]
stackoverflow_0047730259_python_python_3.x_urllib.txt
Q: How to calculate wavelet energy-to-Shannon entropy ratio to select best mother discrete wavelet in python? I'm doing a wavelet analysis to sensor data, however, I realise that there are a lot of wavelet families to select from. I have read an article that says: "The method firstly uses a criterion of maximum energ...
How to calculate wavelet energy-to-Shannon entropy ratio to select best mother discrete wavelet in python?
I'm doing a wavelet analysis to sensor data, however, I realise that there are a lot of wavelet families to select from. I have read an article that says: "The method firstly uses a criterion of maximum energy-to-Shannon entropy ratio to select the appropriate wavelet base for signal analysis.". So, I would like to kno...
[ "Best guess assuming the text meant : np.max(Total Energy/Total Entropy)|wavelet\nimport pywt\nimport numpy as np\n\n#series - input data\n#wave - current wavelet\ndata=pywt.wavedec(series,wave)\nS=0\nEtot=0\nfor d in data:\n E=d**2\n P=E/np.sum(E)\n S+=-np.sum(P*np.log(P))\n Etot+=np.sum(E)\nratio=Et...
[ 1, 1 ]
[]
[]
[ "python", "wavelet" ]
stackoverflow_0057382428_python_wavelet.txt
Q: MongoDB $push until max array size Overview We have a Mongo database collecting time series data from multiple different stream channels. This data is stored using a paging pattern where each page document holds a subset of the overall timeline (currently 3600 points per page). For example, we may have 10,000 data...
MongoDB $push until max array size
Overview We have a Mongo database collecting time series data from multiple different stream channels. This data is stored using a paging pattern where each page document holds a subset of the overall timeline (currently 3600 points per page). For example, we may have 10,000 data points divided into 3 pages with capaci...
[ "There is no option to do a single update with the current structure, while it sounds like you could benefit from a schema redesign I understand the difficulty involved in such a migration so I let's see what are our options given the current state of things:\n\nI'll start with what I think is the best approach, ju...
[ 0 ]
[]
[]
[ "mongodb", "python", "tornado_motor" ]
stackoverflow_0074283641_mongodb_python_tornado_motor.txt
Q: Finding Blendshape from Target Maya Python API I'm trying to find a blendshape deformer from a target mesh in the python maya api. I'm pretty sure I have to iterate through the dependency graph to get the blendshape. This is what i'm trying: import maya.OpenMaya as OpenMaya import maya.OpenMayaAnim as OpenMayaAnim...
Finding Blendshape from Target Maya Python API
I'm trying to find a blendshape deformer from a target mesh in the python maya api. I'm pretty sure I have to iterate through the dependency graph to get the blendshape. This is what i'm trying: import maya.OpenMaya as OpenMaya import maya.OpenMayaAnim as OpenMayaAnim #Name of our targetmesh. targetMesh = "pSphere1" ...
[ "you don't want the future flag if you're working from the deformable object:\ntargetMesh = \"pSphere1\" \nblendshapes = cmds.ls(*cmds.listHistory(targetMesh) or [], type= 'blendShape')\n\nTo get the actual shapes, you'd add\nsource_shapes = cmds.ls(*cmds.listHistory(*blendshapes) or [], type= 'mesh', ni=True)\...
[ 1, 1, 0 ]
[]
[]
[ "api", "maya", "python" ]
stackoverflow_0023500202_api_maya_python.txt
Q: How to get current value of oracle sequence in ctl template I'm trying to ingest 3 csv into 3 three tables A,B,C respectively. Primary key of A is generated using SCHEMEA.SEQ_TAB_REC_ID.NEXTVAL and B, C has foreign key column which is referring to A's primary key I tried to put the direct sql query select SEQ_TAB...
How to get current value of oracle sequence in ctl template
I'm trying to ingest 3 csv into 3 three tables A,B,C respectively. Primary key of A is generated using SCHEMEA.SEQ_TAB_REC_ID.NEXTVAL and B, C has foreign key column which is referring to A's primary key I tried to put the direct sql query select SEQ_TAB_REC_ID.CURRVAL FROM dual; in the ctl. But it does not work Then...
[ "Simply put, you can not. Sequence value should first be fetched (in this session) so that you could check its current value.\nFor example:\nSQL> create sequence seq_tab_rec_id;\n\nSequence created.\n\nIf you try to find its current value:\nSQL> select seq_tab_rec_id.currval from dual;\nselect seq_tab_rec_id.currva...
[ 0 ]
[]
[]
[ "ctl", "currval", "oracle", "python" ]
stackoverflow_0074284861_ctl_currval_oracle_python.txt
Q: LEFT ON Case When in Pandas i wanted to ask that if in SQL I can do like JOIN ON CASE WHEN, is there a way to do this in Pandas? disease = [ {"City":"CH","Case_Recorded":5300,"Recovered":2839,"Deaths":2461}, {"City":"NY","Case_Recorded":1311,"Recovered":521,"Deaths":790}, {"City":"TX","Case_Recorded":1991,"Recover...
LEFT ON Case When in Pandas
i wanted to ask that if in SQL I can do like JOIN ON CASE WHEN, is there a way to do this in Pandas? disease = [ {"City":"CH","Case_Recorded":5300,"Recovered":2839,"Deaths":2461}, {"City":"NY","Case_Recorded":1311,"Recovered":521,"Deaths":790}, {"City":"TX","Case_Recorded":1991,"Recovered":1413,"Deaths":578}, {"City":"...
[ "Use:\n#get City without duplicates\ndf1 = pd.DataFrame(disease)[['City']].drop_duplicates()\n\n#create DataFrame from region dictionary\nregion = {\"North\": [\"AT\"], \"West\":[\"TX\",\"LA\"]}\ndf2 = pd.DataFrame([(k, x) for k, v in region.items() for x in v], \n columns=['Region','City'])\n\n#...
[ 1, 0 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074285210_pandas_python.txt
Q: No module found error while importing python in notebook I want to acess m_rcnn.py file in jupyter notebook. The folder structure is as follows collab_mask_rcnn(working directory). Inside this workinhg directory i have a folder name maskrcnn_colab and inside this maskrcnn_colab folder i have another folder named m...
No module found error while importing python in notebook
I want to acess m_rcnn.py file in jupyter notebook. The folder structure is as follows collab_mask_rcnn(working directory). Inside this workinhg directory i have a folder name maskrcnn_colab and inside this maskrcnn_colab folder i have another folder named mrcnn_demo where i have all the python file like m_rcnn.py, con...
[ "I think you use sys.path.insert . Something like this:\nfrom m_rcnn import *\nimport sys\nsys.path.insert(1,'C:/Users/BIUTeamUser3/Desktop/collab_mask_rcnn/maskrcnn_colab/mrcnn_demo')\n\n\n\n", "You might just try it like this:\nfrom maskrcnn_colab.mrcnn_demo.m_rcnn import *\n\n" ]
[ 0, 0 ]
[]
[]
[ "jupyter_notebook", "mask_rcnn", "python" ]
stackoverflow_0074275302_jupyter_notebook_mask_rcnn_python.txt
Q: (Python) Can 'array' be a variable name? In the following example 1: <example 1> import numpy as np np.array([0,1,2,3,4]) Is array after np. a method function? If so, can array be used as a variable name? Please check the the following example 2? <example 2> import numpy as np array = np.arange(5) print...
(Python) Can 'array' be a variable name?
In the following example 1: <example 1> import numpy as np np.array([0,1,2,3,4]) Is array after np. a method function? If so, can array be used as a variable name? Please check the the following example 2? <example 2> import numpy as np array = np.arange(5) print(array) Are 'array' in example 1 and example ...
[ "You can run this line to see which keywords are not allowed in python:\nhelp(\"keywords\")\n\nAs you can see array is not one of them, so you can use it as a variable name.\nHowever array in np.array() is the method name (there is a dot before it, which it means it is part of numpy library). So in your example 2 \...
[ 0 ]
[]
[]
[ "naming_conventions", "numpy", "python", "variables" ]
stackoverflow_0074283587_naming_conventions_numpy_python_variables.txt
Q: How to Display Time (not static) in python? Alright,the problem is i'm trying to build a personal assistant with my amateur skills. I want to display the time which should be running and not be static. A: This is what you wanted ? create a endless loop (Since you didn't mention in what situation the loop will en...
How to Display Time (not static) in python?
Alright,the problem is i'm trying to build a personal assistant with my amateur skills. I want to display the time which should be running and not be static.
[ "This is what you wanted ? create a endless loop (Since you didn't mention in what situation the loop will end, I assume it will run infinitely until you manually end it) and print() with end='\\r' (replace prev print) and pause and refresh every second\nimport time \nimport datetime \n\nwhile True:\n now = date...
[ 2 ]
[]
[]
[ "datetime", "python" ]
stackoverflow_0074285376_datetime_python.txt
Q: shifting elements of list to the left by the specified shift amount in python how to create a function that copies every value in the original list to a new list where the position of every value in the new list is shifted to the left by the specified shift amount e.g. [2,3,4,5] woule become [4,5,2,3] How can I cr...
shifting elements of list to the left by the specified shift amount in python
how to create a function that copies every value in the original list to a new list where the position of every value in the new list is shifted to the left by the specified shift amount e.g. [2,3,4,5] woule become [4,5,2,3] How can I create this function WITHOUT using any builtin functions?
[ "Solution\na = [2, 3, 4, 5]\n\n\ndef shift_left(arr: list, amount: int) -> list:\n amount %= len(arr) # (1)\n return arr[amount:] + arr[:amount] # (2)\n\n\nfor i in range(len(a) * -2, len(a) * 2):\n print(i, shift_left(a, i))\n\noutput:\n-8 [2, 3, 4, 5]\n-7 [3, 4, 5, 2]\n-6 [4, 5, 2, 3]\n-5 [5, 2, 3, 4]\...
[ 0 ]
[]
[]
[ "indexing", "list", "python", "range" ]
stackoverflow_0074285367_indexing_list_python_range.txt
Q: python-How to solve KeyError: 2? I have a dict which is formatted as {int:[]} When I was trying to set value to a key-value pair where the value list is NULL, I got KeyError: 2 tags = {} tags.setdefault(int,[]) for tag_id in (db.session.query(PostTagRel).filter(PostTagRel.id == post_id).first().tag_id.split(',')):...
python-How to solve KeyError: 2?
I have a dict which is formatted as {int:[]} When I was trying to set value to a key-value pair where the value list is NULL, I got KeyError: 2 tags = {} tags.setdefault(int,[]) for tag_id in (db.session.query(PostTagRel).filter(PostTagRel.id == post_id).first().tag_id.split(',')): tag = db.session.query(Ta...
[ "In order to set a general default value for all keys, you can use defaultdict:\nfrom collections import defaultdict\n\nd = defaultdict(list) \nd[0].append(1)\n\n", "It might be because of index formatting not properly done: just try\ndf.reset_index(inplace = True)\n" ]
[ 7, 0 ]
[]
[]
[ "dictionary", "keyerror", "python" ]
stackoverflow_0035391086_dictionary_keyerror_python.txt
Q: What does this error message mean in Python? I made an email spam bot a while ago for fun. (Just as a test and to mess with friends) I tried to run it today and it wouldn't work. Any ideas why and how to fix? I've made sure that this API has access to my email. Edit: Error Message is Traceback (most recent call l...
What does this error message mean in Python?
I made an email spam bot a while ago for fun. (Just as a test and to mess with friends) I tried to run it today and it wouldn't work. Any ideas why and how to fix? I've made sure that this API has access to my email. Edit: Error Message is Traceback (most recent call last): File "C:\Users\user\OneDrive\Desktop\Code\Sp...
[ "\nUsername and Password not accepted.\n\nDo to the removal of less secure apps you can not use the gmail users actual password when connecting to the smtp server.\nYou must either enable 2fa on the account and configure an apps password, or switch to using Xoauth2.\n" ]
[ 0 ]
[]
[]
[ "email", "gmail", "python", "python_3.x", "smtplib" ]
stackoverflow_0074282841_email_gmail_python_python_3.x_smtplib.txt
Q: Change logging "print" function to "tqdm.write" so logging doesn't interfere with progress bars I have a simple question: How do I change the built-in Python logger's print function to tqdm.write such that logging messages do not interfere with tqdm's progress bars? Thanks! A: You need a custom logging handler: ...
Change logging "print" function to "tqdm.write" so logging doesn't interfere with progress bars
I have a simple question: How do I change the built-in Python logger's print function to tqdm.write such that logging messages do not interfere with tqdm's progress bars? Thanks!
[ "You need a custom logging handler:\nimport logging\nimport tqdm\n\nclass TqdmLoggingHandler(logging.Handler):\n def __init__(self, level=logging.NOTSET):\n super().__init__(level)\n\n def emit(self, record):\n try:\n msg = self.format(record)\n tqdm.tqdm.write(msg)\n ...
[ 45, 37, 4, 2, 2, 0 ]
[]
[]
[ "logging", "python", "tqdm" ]
stackoverflow_0038543506_logging_python_tqdm.txt
Q: tqdm and print / logging doesn't work properly (no linebreak for first logging / print statement) Here is a minimal reproducible example: import logging from tqdm import tqdm for i in tqdm(range(1000)): for _ in range(2000): a = i+8 if i % 100 == 0: logging.warning("test") This outputs th...
tqdm and print / logging doesn't work properly (no linebreak for first logging / print statement)
Here is a minimal reproducible example: import logging from tqdm import tqdm for i in tqdm(range(1000)): for _ in range(2000): a = i+8 if i % 100 == 0: logging.warning("test") This outputs this: 0%| | 0/1000 [00:00<?, ?it/s]WARNING:root:test WARNING:root:test WARNING:root:test WARNI...
[ "You can clear the status bar by calling the clear method of the tqdm object before writing output to stdout or stderr.\nTo make the call to the clear method happen automatically for each output, you can create a context manager that patches both sys.stdout and sys.stderr with a wrapper function that calls the clea...
[ 1 ]
[]
[]
[ "logging", "printing", "python", "tqdm" ]
stackoverflow_0074222161_logging_printing_python_tqdm.txt
Q: Function of "[tool.setuptools.packages] find = {}" in pyproject.toml The GitLab instructions for packaging a Python project for the package registry instruct users to create a pyproject.toml file with the following contents: [build-system] requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [p...
Function of "[tool.setuptools.packages] find = {}" in pyproject.toml
The GitLab instructions for packaging a Python project for the package registry instruct users to create a pyproject.toml file with the following contents: [build-system] requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] name = "mypypipackage" version = "0.0.1" authors = [ { name="E...
[ "It is a setuptools custom discovery directive, using here the pyproject.toml syntax.\n\nIf the automatic discovery does not work for you (e.g., you want to include in the distribution top-level packages with reserved names such as tasks, example or docs, or you want to exclude nested packages that would be otherw...
[ 3 ]
[]
[]
[ "pypi", "python", "python_packaging", "setuptools" ]
stackoverflow_0074284075_pypi_python_python_packaging_setuptools.txt
Q: get specific list by value python I have a list of dictionary looks like this. charts = [[{'select': 'scatter-form'}], [{'select': 'line-form'}]] I want to get the list by the value of 'select' key. For example: scatterform = [{'select': 'scatter-form'}] lineform = [{'select': 'line-form'}] this one is not worki...
get specific list by value python
I have a list of dictionary looks like this. charts = [[{'select': 'scatter-form'}], [{'select': 'line-form'}]] I want to get the list by the value of 'select' key. For example: scatterform = [{'select': 'scatter-form'}] lineform = [{'select': 'line-form'}] this one is not working because of some error list indices m...
[ "New answer:\nSince the original post is edited, I updated my answer.\nFirst, If you certain that the 'select' value is unique and not missing,\ncharts = [[{'select': 'scatter-form'}], [{'select': 'line-form'}]]\n\nscatterform = None\nlineform = None\nfor chart in charts:\n if chart[0]['select'] == 'scatter-form...
[ 3 ]
[]
[]
[ "python" ]
stackoverflow_0074285535_python.txt
Q: Python vs C: different outputs I have a small program that converts a base 10 number into a kind of a base 36 number. Here's the Python code, and it works as expected. def numToKey(num): start = 0x04; i = 0; for i in range(0,num): start+=1 return start; def largeNumToKeyboard(num): a =...
Python vs C: different outputs
I have a small program that converts a base 10 number into a kind of a base 36 number. Here's the Python code, and it works as expected. def numToKey(num): start = 0x04; i = 0; for i in range(0,num): start+=1 return start; def largeNumToKeyboard(num): a = num / 1296; ar = num % 1296; ...
[ "In the C code you should use int types. char types only have a range from 0 to 255.\nchar a = num / 1296;\nchar ar = num % 1296;\nchar b = ar / 36;\nchar c = ar % 36; the C code \n\n", "Problem is you're using char types in the void largeNumToKeyboard(int num) function, and the values you're testing can potentia...
[ 3, 3, 0 ]
[]
[]
[ "c", "c++", "python" ]
stackoverflow_0016862356_c_c++_python.txt