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: ModuleNotFoundError: No module named 'myapplication' I am getting a module not found error in a fastapi project even thought the path is correct, the files are as follows models.py from sqlalchemy import Boolean, Column, ForeignKey, Integer, String from sqlalchemy.orm import relationship from myapplication.app.da...
ModuleNotFoundError: No module named 'myapplication'
I am getting a module not found error in a fastapi project even thought the path is correct, the files are as follows models.py from sqlalchemy import Boolean, Column, ForeignKey, Integer, String from sqlalchemy.orm import relationship from myapplication.app.database import Base class User(Base): __tablename__ =...
[ "To consider myapplication as a module there should be a __init__.py file in that directory.\nBased on your project structure, you could put the import statement as below using relative positioning:\nfrom ..app.database import Base\n\n" ]
[ 0 ]
[]
[]
[ "fastapi", "python" ]
stackoverflow_0074272438_fastapi_python.txt
Q: Why does this code get a "ValueError: too many values to unpack (expected 2)" error? I am doing this for my teacher and most of this code works great. Only at the very end (" lastf.write(key, value)") I get the error "ValueError: too many values to unpack (expected 2)" import json # --1-- file = open("C:\\Us...
Why does this code get a "ValueError: too many values to unpack (expected 2)" error?
I am doing this for my teacher and most of this code works great. Only at the very end (" lastf.write(key, value)") I get the error "ValueError: too many values to unpack (expected 2)" import json # --1-- file = open("C:\\Users\\PycharmProjects\\p5.txt", 'w') for i in range (4): a = input("enter a sentence")...
[ "file.write('takes an argument /n will add a new line')\nyoure trying to write two items, are you trying to write something like,\nkey1, value1,\nkey2, value2 ?\n", "you can use something like file.write(f\"{key}:{value}\\n\")\n" ]
[ 0, 0 ]
[]
[]
[ "python", "unpack", "valueerror" ]
stackoverflow_0074197233_python_unpack_valueerror.txt
Q: How do I do this? I can't find logic here You have K toys numbered 1 to K and N boxes numbered 1 to N. You put the toys in the boxes in the following order: first toy in the first box, second toy in the second box, so up to N-th toy in the Nth box, the next toy in (N-1)-th box, the next toy in (N-2)-th box and so ...
How do I do this? I can't find logic here
You have K toys numbered 1 to K and N boxes numbered 1 to N. You put the toys in the boxes in the following order: first toy in the first box, second toy in the second box, so up to N-th toy in the Nth box, the next toy in (N-1)-th box, the next toy in (N-2)-th box and so on up to the first box, then the next toy in th...
[ "It's quite simple. Except the first turn needs N toys (say 1st to N-th toy into 1st to Nth box), all turn will just need N-1 toys (ex: 2nd turn take N-1 toys for from (N-1)th box to 1st box).\n\nSo basic we let (K-1) (to define that first turn needs N toys) devided (N-1). Then if the result is even then the toys i...
[ 0 ]
[]
[]
[ "python", "python_3.x" ]
stackoverflow_0074271642_python_python_3.x.txt
Q: Loop scrapes the same page 20 times instead of iterating through range I'm trying to scrape IMDB for a list of the top 1000 movies and get some details about them. However, when I run it, instead of getting the first 50 movies and going to the next page for the next 50, it repeats the loop and makes the same 50 en...
Loop scrapes the same page 20 times instead of iterating through range
I'm trying to scrape IMDB for a list of the top 1000 movies and get some details about them. However, when I run it, instead of getting the first 50 movies and going to the next page for the next 50, it repeats the loop and makes the same 50 entries 20 times in my database. # Dataframe template data = pd.DataFrame(colu...
[ "Delete 'start' variable inside 'getPageContent' function. It assigns 'start=1' every time.\n#Get page data function\ndef getPageContent(start=1):\n url = 'https://www.imdb.com/search/title/?title_type=feature&year=1950-01-01,2019-12-31&sort=num_votes,desc&start='+str(start)\n r = requests.get(url)\n bs = bsp(r....
[ 1, 0 ]
[]
[]
[ "beautifulsoup", "dataframe", "pandas", "python" ]
stackoverflow_0074270977_beautifulsoup_dataframe_pandas_python.txt
Q: aws lambda - failed to find libmagic I'm using in my lambda function the magic library to determine the file`s type. I first deployed it to a local container to check that everything works. My DockerFile : FROM lambci/lambda:build-python3.8 WORKDIR /app RUN mkdir -p .aws COPY requirements.txt ./ COPY credentials...
aws lambda - failed to find libmagic
I'm using in my lambda function the magic library to determine the file`s type. I first deployed it to a local container to check that everything works. My DockerFile : FROM lambci/lambda:build-python3.8 WORKDIR /app RUN mkdir -p .aws COPY requirements.txt ./ COPY credentials /app/.aws/ RUN mv /app/.aws/ ~/.aws/ RUN ...
[ "While using filetype as suggested by other answers is much simpler, that library does not detect as many file types as magic does.\nYou can make python-magic work on aws lambda with python3.8 by doing the following:\n\nAdd libmagic.so.1 to a lib folder at the root of the lambda package. This lib folder will be aut...
[ 9, 3, 1, 0 ]
[]
[]
[ "amazon_web_services", "aws_lambda", "python" ]
stackoverflow_0061921935_amazon_web_services_aws_lambda_python.txt
Q: How to call an InlineKeyboardButton by id anytime the button is pressed I am trying to write a python telegram bot that works like a betting platform. It has a list of matches and I want that anytime a match is selected from that list, it calls the match option by id and then call the bet function of that match th...
How to call an InlineKeyboardButton by id anytime the button is pressed
I am trying to write a python telegram bot that works like a betting platform. It has a list of matches and I want that anytime a match is selected from that list, it calls the match option by id and then call the bet function of that match then the user has to select which team he wish to bet on. Then when he clicks o...
[ "May be to any button add callback filter:\nfrom aiogram.utils.callback_data import CallbackData\n\ncb_inline = CallbackData(\"post\", 'action', \"data\")\nkeyboard = InlineKeyboardMarkup(\n inline_keyboard= [\n InlineKeyboardButton(text='MyText', callback_data=cb_inline.new(action='myact', data='MyText')...
[ 0 ]
[]
[]
[ "aiogram", "python", "telegram_bot" ]
stackoverflow_0074261577_aiogram_python_telegram_bot.txt
Q: Scraping after select from drop down list I'm trying to scraping data form the following web site: https://shafafiyah.socpa.org.sa/EmployeeDetails.aspx The issue is the table that I need is not showing, and I think that because I need to click from drop down list before scraping I'm trying the below scraping but...
Scraping after select from drop down list
I'm trying to scraping data form the following web site: https://shafafiyah.socpa.org.sa/EmployeeDetails.aspx The issue is the table that I need is not showing, and I think that because I need to click from drop down list before scraping I'm trying the below scraping but its return null import requests from bs4 impor...
[ "The data comes from a POST request that you need to mimic.\nHere's how:\nimport json\n\nimport pandas as pd\nimport requests\nfrom bs4 import BeautifulSoup\n\nheaders = {\n \"User-Agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:104.0) Gecko/20100101 Firefox/104.0\",\n \"Origin\": \"https://shafaf...
[ 1, 0 ]
[]
[]
[ "beautifulsoup", "python", "web_scraping" ]
stackoverflow_0074251882_beautifulsoup_python_web_scraping.txt
Q: Error in anyjson setup command: use_2to3 is invalid #25 3.990 × python setup.py egg_info did not run successfully. #25 3.990 │ exit code: 1 #25 3.990 ╰─> [1 lines of output] #25 3.990 error in anyjson setup command: use_2to3 is invalid. #25 3.990 [end of output] This is a common error which the ...
Error in anyjson setup command: use_2to3 is invalid
#25 3.990 × python setup.py egg_info did not run successfully. #25 3.990 │ exit code: 1 #25 3.990 ╰─> [1 lines of output] #25 3.990 error in anyjson setup command: use_2to3 is invalid. #25 3.990 [end of output] This is a common error which the most common solution to is to downgrade setuptools to bel...
[ "Downgrading setuptools worked for me\npip install \"setuptools<58.0.0\"\n\nAnd then\npip install django-celery\n\n", "Installing setuptools 57.5.0 solved the same issue for me.\npip install setuptools~=57.5.0\n\n", "Installing a version of setuptools lower than 58.0.0 soled the issue\npip install \"setuptools<...
[ 35, 12, 1 ]
[]
[]
[ "docker", "dockerfile", "python", "python_3.x" ]
stackoverflow_0072414481_docker_dockerfile_python_python_3.x.txt
Q: Delete the empty list from a main list I want to delete the empty list from a main list. Input is: my_list = [[''],[''],s-13,s-12] Output: my_modified_list = [,,s-13,s-12] I tried with this but when I put the list in df in pandas, its not working my_modified_list = data[sublist for sublist in my_list of any(subl...
Delete the empty list from a main list
I want to delete the empty list from a main list. Input is: my_list = [[''],[''],s-13,s-12] Output: my_modified_list = [,,s-13,s-12] I tried with this but when I put the list in df in pandas, its not working my_modified_list = data[sublist for sublist in my_list of any(sublist)] Finally this is my probable solution ...
[ "May be:\n my_list = [[''], [''], 's - 13', 's - 12']\n new_list = [a for a in my_list if a[0]]\n print(new_list)\n\n" ]
[ 0 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074272704_pandas_python.txt
Q: Python Export Dictionary to CSV I'm new in Python and I've been trying to create csv file and save each result in a new row. The results consist of several rows and each line should be captured in csv. However, my csv file separate each letter into new row. I also need to add new key values for the filename, but I...
Python Export Dictionary to CSV
I'm new in Python and I've been trying to create csv file and save each result in a new row. The results consist of several rows and each line should be captured in csv. However, my csv file separate each letter into new row. I also need to add new key values for the filename, but I dont know how to get the image filen...
[ "Few things I changed.\n\nw is enough, since t for text mode is default\nno need to close the csv when using a context manager\nno need for zip and str(n) for n in row. Just join the 2 values of the dictionary\n\nUPDATED\nwith open('glaresss_result.csv','w') as f: \n f.write(\",\".join([*res1] + ['filename']) + ...
[ 1, 0 ]
[]
[]
[ "csv", "export_to_csv", "jupyter_notebook", "python" ]
stackoverflow_0074272257_csv_export_to_csv_jupyter_notebook_python.txt
Q: im a newbie learning python help me with this error where it says traceback name error every time i am completely a newbie and learning python in vscode i dont understand why im getting this message help me to fix it ho = input('what is your name') print(ho) error Traceback (most recent call last): File "/Users...
im a newbie learning python help me with this error where it says traceback name error every time
i am completely a newbie and learning python in vscode i dont understand why im getting this message help me to fix it ho = input('what is your name') print(ho) error Traceback (most recent call last): File "/Users/sar/Desktop/python/csp1.py", line 1, in <module> ho = input('what is your name') File "<string>"...
[ "Try to check with the python version for python 3.8\n#for string input\nho = str(input('Enter your name:'))\nprint(ho)\n#for number input\nho = str(input('Enter your name:'))\nprint(ho)\n" ]
[ 0 ]
[]
[]
[ "input", "python", "traceback" ]
stackoverflow_0074272602_input_python_traceback.txt
Q: when I want to see my admin penal in django it give me error not only admin in some urls it give me in some not this happen when I put to live db admin.py: admin.site.register(models.User) admin.site.register(models.Teacher) admin.site.register(models.Student) admin.site.register(models.CourseCategory) admin.site....
when I want to see my admin penal in django it give me error not only admin in some urls it give me in some not this happen when I put to live db
admin.py: admin.site.register(models.User) admin.site.register(models.Teacher) admin.site.register(models.Student) admin.site.register(models.CourseCategory) admin.site.register(models.Course) admin.site.register(models.Chapter) admin.site.register(models.Section) admin.site.register(models.StudentCourseEnrollment) adm...
[ "You need to add the ModelAdmin, Documentation\n", "stylesheet block should be outside the link tag of html.\nIn the template replace this:\n<link rel=\"stylesheet\" href=\"{% block stylesheet %} {% static \"admin/css/base.css\" %} {% endblock %}\">\n\nwith this:\n{% block stylesheet %}\n<link rel=\"stylesheet\" ...
[ 1, 1 ]
[]
[]
[ "django", "django_admin", "django_settings", "django_templates", "python" ]
stackoverflow_0074272595_django_django_admin_django_settings_django_templates_python.txt
Q: Proper way of streaming JSON with Django i have a webservice which gets user requests and produces (multiple) solution(s) to this request. I want to return a solution as soon as possible, and send the remaining solutions when they are ready. In order to do this, I thought about using Django's Http stream response....
Proper way of streaming JSON with Django
i have a webservice which gets user requests and produces (multiple) solution(s) to this request. I want to return a solution as soon as possible, and send the remaining solutions when they are ready. In order to do this, I thought about using Django's Http stream response. Unfortunately, I am not sure if this is the m...
[ "Try decoding with something like \nfor example \n\n\n\nimport json\njson.dumps( {key: val} {key: val}, separators=('}', ':')) #check it\n\n\n\n", "The solution is on the client side (eg: browser). You need to interpret the JSON result when it comes. By definition of a stream you never know when it finished, so ...
[ 0, 0 ]
[]
[]
[ "django", "json", "python" ]
stackoverflow_0050491360_django_json_python.txt
Q: How to extract delivery time from an email with Python? I'm currently trying to automate incoming emails with python. I'm using the IMAP_TOOLS library. I've already managed to get the necessary values, but I need the time when the email response arrived, but I can't get this information from imap_tools import Mail...
How to extract delivery time from an email with Python?
I'm currently trying to automate incoming emails with python. I'm using the IMAP_TOOLS library. I've already managed to get the necessary values, but I need the time when the email response arrived, but I can't get this information from imap_tools import MailBox, AND from datetime import date data_atual = date.today()...
[ "The IMAP standard does not expose this information directly.\nWhat you can examine is:\n\nThe Date: header gets injected by the sender (typically automatically by their email client) and indicates the system time on the sending computer (or, in some circumstances, if this header was not added by the sender, the MT...
[ 1 ]
[]
[]
[ "automation", "gmail", "gmail_imap", "imap_tools", "python" ]
stackoverflow_0074270428_automation_gmail_gmail_imap_imap_tools_python.txt
Q: Is it possible to stream JSON in Django with StreamingHTTPResponse or in any other way? I'm wondering if it's possible to correctly stream JSON in Django? I've tried to use StreamingHTTPResponse but what I'm sending is incorrect JSON format - expected [json], sending [json][json]..[json], each is separate array. I...
Is it possible to stream JSON in Django with StreamingHTTPResponse or in any other way?
I'm wondering if it's possible to correctly stream JSON in Django? I've tried to use StreamingHTTPResponse but what I'm sending is incorrect JSON format - expected [json], sending [json][json]..[json], each is separate array. I kind of understand the idea - we cannot send [json ... json... json] because it will be inco...
[ "Here is some working code to send JSON stream with django:\nfrom django.http import StreamingHttpResponse\n\n def download_logs(self, request):\n \"\"\"\n :param request: Django HTTP Request\n\n :return: Django HTTP Response\n \"\"\"\n def event_stream():\n while Tr...
[ 0 ]
[]
[]
[ "django", "django_rest_framework", "httpresponse", "json", "python" ]
stackoverflow_0062729902_django_django_rest_framework_httpresponse_json_python.txt
Q: How can I get my column to drop decimals unless it's necessary I have a column that is currently in dollars and my prof wants us to convert it so that it's showin inn 10,000's (for example 150000 will be 15, 30000 will be 3, 15000 will be 1.5). I was able to convert it but I don't know how to get it to only show t...
How can I get my column to drop decimals unless it's necessary
I have a column that is currently in dollars and my prof wants us to convert it so that it's showin inn 10,000's (for example 150000 will be 15, 30000 will be 3, 15000 will be 1.5). I was able to convert it but I don't know how to get it to only show the decimal if it's necessary (like the 15000 being 1.5). Does anyone...
[ "One way to do it is looping through the series and format them in this manner.\nThere may be other efficient solutions out there.\nfor i in range(len(medianIncome1)):\n if medianIncome1[i].split('.')[1] == '0':\n medianIncome1[i]=round(float(medianIncome1[i]))\n\n", "Applying this option will work to show yo...
[ 0, 0, 0 ]
[]
[]
[ "pandas", "python" ]
stackoverflow_0074271728_pandas_python.txt
Q: django stream a dictionary multiple times w/o breaking JSON I want to stream a response using Django. In order to do so, I have a view like this: def flights(request, query): req_obj = Flights.RequestObject(query) return StreamingHttpResponse(req_obj.make_response(), content_type="application/json") In ord...
django stream a dictionary multiple times w/o breaking JSON
I want to stream a response using Django. In order to do so, I have a view like this: def flights(request, query): req_obj = Flights.RequestObject(query) return StreamingHttpResponse(req_obj.make_response(), content_type="application/json") In order to produce the data for the stream, I have a generator functio...
[ "Have you tried something like \nreq_obj.update(req_obj.make_response())\n\nwhich will update your initial dict with the values newly yielded from your method?\n", "The solution is on the client side (eg: browser). You need to interpret the JSON result when it comes. By definition of a stream you never know when ...
[ 0, 0 ]
[]
[]
[ "django", "json", "python", "stream" ]
stackoverflow_0050469948_django_json_python_stream.txt
Q: How do I add a time delay to a signal in python? This is my first question here on stackoverflow, bear with me please. I get a dictionary-like list with time and values for each timestamp and based on those values I need to create a lower bound and higher bound with time-delay. I got the lower bound to work but I'...
How do I add a time delay to a signal in python?
This is my first question here on stackoverflow, bear with me please. I get a dictionary-like list with time and values for each timestamp and based on those values I need to create a lower bound and higher bound with time-delay. I got the lower bound to work but I'm struggling with the higher bound. The signal that I ...
[ "You didn't specify the delay, so I will outline a general solution. For reporting m time points from n events, it will be O(m + n log(n)).\nFirst we need the idea of events. An event has:\nstart\nend\nvalue\n\nWe will start with a list of events for observed values. Those look like Event(start, start+duration, ...
[ 2 ]
[]
[]
[ "algorithm", "python", "signal_processing" ]
stackoverflow_0074264526_algorithm_python_signal_processing.txt
Q: hasattr for nested attributes I need something like this (pseudocode): if hasattr(object, 'detail.infotext') I mean I want to check if object has attribute details and if it has, then if details has a attribute named infotext I could do it like this: if hasattr(object, 'detail'): if hasattr(object.detail, 'in...
hasattr for nested attributes
I need something like this (pseudocode): if hasattr(object, 'detail.infotext') I mean I want to check if object has attribute details and if it has, then if details has a attribute named infotext I could do it like this: if hasattr(object, 'detail'): if hasattr(object.detail, 'infotext'): do something But...
[ "I know this isn't really what you want to do, but it's more pythonic anyway (if you know the names of the attributes you're looking for explicitly):\ntry:\n do something with object.detail.infotext\nexcept AttributeError:\n do something else\n\n", "Assuming you want to actually use your attribute values, ope...
[ 6, 4, 0, 0, 0, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0024779483_python.txt
Q: Mediawiki api returning http response code instead of json I am following some example code in the mediawiki api (see link at the bottom) to get a response in json format that looks something like the following: "login": { "lguserid": 21, "result": "Success", "lgusername": "William" } Un...
Mediawiki api returning http response code instead of json
I am following some example code in the mediawiki api (see link at the bottom) to get a response in json format that looks something like the following: "login": { "lguserid": 21, "result": "Success", "lgusername": "William" } Unfortunately, I am not getting anything similar to that and inste...
[ "You have to use response.json() to get a json object :\nR = S.get(url=URL, params=PARAMS_0)\nDATA = R.json()\n\n" ]
[ 1 ]
[]
[]
[ "json", "mediawiki", "python" ]
stackoverflow_0074268092_json_mediawiki_python.txt
Q: How to export plots from matplotlib with transparent background? I am using matplotlib to make some graphs and unfortunately I cannot export them without the white background. In other words, when I export a plot like this and position it on top of another image, the white background hides what is behind it rath...
How to export plots from matplotlib with transparent background?
I am using matplotlib to make some graphs and unfortunately I cannot export them without the white background. In other words, when I export a plot like this and position it on top of another image, the white background hides what is behind it rather than allowing it to show through. How can I export plots with a tra...
[ "Use the matplotlib savefig function with the keyword argument transparent=True to save the image as a png file.\nIn [30]: x = np.linspace(0,6,31)\n\nIn [31]: y = np.exp(-0.5*x) * np.sin(x)\n\nIn [32]: plot(x, y, 'bo-')\nOut[32]: [<matplotlib.lines.Line2D at 0x3f29750>] \n\nIn [33]: savefig('demo.png', t...
[ 255, 4, 1 ]
[]
[]
[ "matplotlib", "plot", "python", "transparency" ]
stackoverflow_0015857647_matplotlib_plot_python_transparency.txt
Q: Using pyarrow how do you append to parquet file? How do you append/update to a parquet file with pyarrow? import pandas as pd import pyarrow as pa import pyarrow.parquet as pq table2 = pd.DataFrame({'one': [-1, np.nan, 2.5], 'two': ['foo', 'bar', 'baz'], 'three': [True, False, True]}) table3 = pd.DataFrame({'s...
Using pyarrow how do you append to parquet file?
How do you append/update to a parquet file with pyarrow? import pandas as pd import pyarrow as pa import pyarrow.parquet as pq table2 = pd.DataFrame({'one': [-1, np.nan, 2.5], 'two': ['foo', 'bar', 'baz'], 'three': [True, False, True]}) table3 = pd.DataFrame({'six': [-1, np.nan, 2.5], 'nine': ['foo', 'bar', 'baz']...
[ "I ran into the same issue and I think I was able to solve it using the following:\nimport pandas as pd\nimport pyarrow as pa\nimport pyarrow.parquet as pq\n\n\nchunksize=10000 # this is the number of lines\n\npqwriter = None\nfor i, df in enumerate(pd.read_csv('sample.csv', chunksize=chunksize)):\n table = pa.T...
[ 42, 19, 14, 2, 2 ]
[]
[]
[ "pandas", "parquet", "pyarrow", "python" ]
stackoverflow_0047113813_pandas_parquet_pyarrow_python.txt
Q: I have a string which is '3050070202_Level2'. I want to remove the '_Level2'. As in, my desired output is just '3050070202' input = '3050070102_Level2' desired _output = '3050070202' I tried using the str.strip(), but doing so will remove the 2 from the desired output as well A: Try this: desired_output = inpu...
I have a string which is '3050070202_Level2'. I want to remove the '_Level2'. As in, my desired output is just '3050070202'
input = '3050070102_Level2' desired _output = '3050070202' I tried using the str.strip(), but doing so will remove the 2 from the desired output as well
[ "Try this:\ndesired_output = input.split(\"_\")[0]\n\nThe split() function splits your string at the given character sequence (in this case of length 1 and just the character _) and returns a list of splits. With [0] you index the first split which is your desired string.\nBonus: If you want to convert the resultin...
[ 1 ]
[]
[]
[ "python", "split", "string" ]
stackoverflow_0074272922_python_split_string.txt
Q: FastAPI sqlmodel get all rows from the database I have a FastAPI application that needs to provide GET route to get all Items from a Postgres 13 database. The Item is defined and added from another app. The Item has a model like this: class ItemDb(SQLModel, table=True): __tablename__ = "items" id: str = Fi...
FastAPI sqlmodel get all rows from the database
I have a FastAPI application that needs to provide GET route to get all Items from a Postgres 13 database. The Item is defined and added from another app. The Item has a model like this: class ItemDb(SQLModel, table=True): __tablename__ = "items" id: str = Field( default_factory=uuid.uuid4, primary_key=...
[ "The Item class isn't an ORM model (it doesn't have table=True), so you can't use it in database queries. Using ItemDb should resolve the issue.\n" ]
[ 1 ]
[]
[]
[ "fastapi", "postgresql", "python", "sqlmodel" ]
stackoverflow_0074264639_fastapi_postgresql_python_sqlmodel.txt
Q: How do I tell conda/mamba to use windows/linux/osx channels that are different from the system OS? I would like to help someone solve their problem with installing a particular mamba environment: New mamba environment force torch CPU and I don't know why However, they use Windows, and I am on macOS. How can I tell...
How do I tell conda/mamba to use windows/linux/osx channels that are different from the system OS?
I would like to help someone solve their problem with installing a particular mamba environment: New mamba environment force torch CPU and I don't know why However, they use Windows, and I am on macOS. How can I tell mamba to use pytorch/win-64 and conda-forge/win-64 channels instead of osx-arm subchannels? I know I ca...
[ "The CONDA_SUBDIR variable works well for this. For example,\nCONDA_SUBDIR=win-64 mamba create -dn foo -c pytorch -c conda-forge pytorch\n\n", "One simply needs to add the subdirectory to the channel, like -c conda-forge/win-64 and use --override-channels as well to make sure the default channels are not used.\nT...
[ 1, 0 ]
[]
[]
[ "conda", "cross_platform", "mamba", "python", "virtual_environment" ]
stackoverflow_0074238095_conda_cross_platform_mamba_python_virtual_environment.txt
Q: TypeError: element_to_be_clickable() takes 1 positional argument but 2 were given [Selenium | Python] The script below is intended to go to the page and download relevant financial statements of publicly-traded companies. from selenium import webdriver from selenium.webdriver.chrome.service import Service ...
TypeError: element_to_be_clickable() takes 1 positional argument but 2 were given [Selenium | Python]
The script below is intended to go to the page and download relevant financial statements of publicly-traded companies. from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.ui import Web...
[ "Instead of\nwait.until(EC.element_to_be_clickable(By.CSS_SELECTOR, \"#searchButton\")).click()\n\nand\nwait.until(EC.element_to_be_clickable(By.XPATH, \"/html/body/main/div[2]/div/div/div[2]/div/dl/dd[5]/div[1]/a/text()\")).click()\n\nIt should be\nwait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, \"#searchB...
[ 0 ]
[]
[]
[ "python", "selenium", "selenium_webdriver", "webdriverwait", "xpath" ]
stackoverflow_0074270599_python_selenium_selenium_webdriver_webdriverwait_xpath.txt
Q: Simplify this condition a = [34,56,23,68] b = [76,78324,1234] dict1 = {34:76,56:1234} for i in dict1: if (a,b)!=(i,dict1[i]): print('yes') else: print('no') What does this condition check => (a,b)!=(i,dict1[i]) ? Also, what are the conditions when we will get no as result? If key and val...
Simplify this condition
a = [34,56,23,68] b = [76,78324,1234] dict1 = {34:76,56:1234} for i in dict1: if (a,b)!=(i,dict1[i]): print('yes') else: print('no') What does this condition check => (a,b)!=(i,dict1[i]) ? Also, what are the conditions when we will get no as result? If key and value present in dict1 match wit...
[ "Here an answer to the question instead of suggestions what the condition is actually supposed to be given in the other answers:\nHow does this condition work => (a,b)!=(i,dict1[i])?\nThis condition compares a tuple of two lists a and b with a tuple of two integers being key and value in dict1 and will be always Tr...
[ 0 ]
[]
[]
[ "conditional_statements", "dictionary", "python" ]
stackoverflow_0074272761_conditional_statements_dictionary_python.txt
Q: Python - Memory limit exceeded during Google App Engine deployment I am creating a Python project and deploying it to Google App Engine. When I use the deployed link in another project, I get the following error message in Google Cloud Logging: Exceeded hard memory limit of 256 MB with 667 MB after servicing 0 req...
Python - Memory limit exceeded during Google App Engine deployment
I am creating a Python project and deploying it to Google App Engine. When I use the deployed link in another project, I get the following error message in Google Cloud Logging: Exceeded hard memory limit of 256 MB with 667 MB after servicing 0 requests total. Consider setting a larger instance class in app.yaml. So, ...
[ "First, I store larger files from local to cloud. Then I successfully deployed the code to Google App Engine without any errors.\n" ]
[ 1 ]
[]
[]
[ "google_app_engine", "google_app_engine_python", "google_cloud_platform", "limit", "python" ]
stackoverflow_0074111323_google_app_engine_google_app_engine_python_google_cloud_platform_limit_python.txt
Q: Getting lyrics from genius api gives error So I am working on a discord bot that will search for the lyrics using the lyricsgenius api. However when I try to use genius.search_lyrics(arg) where arg is the lyrics the user is trying to find. It gives me an error: requests.exceptions.HTTPError: 403 Client Error: Forb...
Getting lyrics from genius api gives error
So I am working on a discord bot that will search for the lyrics using the lyricsgenius api. However when I try to use genius.search_lyrics(arg) where arg is the lyrics the user is trying to find. It gives me an error: requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://genius.com/api/search/lyr...
[ "for anyone facing the same error, there's a github issue here\nand there seems to be no work arounds, so don't use lyricsgenius api\n" ]
[ 0 ]
[]
[]
[ "discord", "discord.py", "genius_api", "python" ]
stackoverflow_0072078610_discord_discord.py_genius_api_python.txt
Q: How to check that there is no `1` touching a border in a 2D-list of `0` and `1` I need to consider a swimming pool "legitimate". For the given list, the function should return "illegitimate". However, my code returns "legitimate", even though I haven't done anything to the data. This is the code that I tried and I...
How to check that there is no `1` touching a border in a 2D-list of `0` and `1`
I need to consider a swimming pool "legitimate". For the given list, the function should return "illegitimate". However, my code returns "legitimate", even though I haven't done anything to the data. This is the code that I tried and I was expecting/should return "illegitimate" before trying to modify the list. pool = ...
[ "Solution\nYou could start off by checking if any element in the first and last sub-list is non-zero. Any non-zero integer i when passed to bool(i) will evaluate to True and only zero is \"falsy\" (see Truth Value Testing). This allows us to simply use the built-in any function for checking those two lists. If it ...
[ 1 ]
[]
[]
[ "for_loop", "if_statement", "list", "nested_loops", "python" ]
stackoverflow_0074272036_for_loop_if_statement_list_nested_loops_python.txt
Q: How can I judge an array dimension is (p, ) in a if sentence in Python? I found in Python there are two ways to represent the dimension of a '1D' array, namely (p, ) and (p, 1), in which 'p' is number of elements in an array. How can I determine if an argument is the former case or the latter case? The following i...
How can I judge an array dimension is (p, ) in a if sentence in Python?
I found in Python there are two ways to represent the dimension of a '1D' array, namely (p, ) and (p, 1), in which 'p' is number of elements in an array. How can I determine if an argument is the former case or the latter case? The following is an example: import numpy as np x = np.array([1, 2, 3]) print(x.shape) # (3,...
[ "You can use:\nlen(x.shape) == 1\n\n", "You can use ndim:\nx.ndim #1\nx2.ndim #2\n\n" ]
[ 1, 1 ]
[]
[]
[ "numpy", "python", "python_3.x" ]
stackoverflow_0074273112_numpy_python_python_3.x.txt
Q: Import "dateutil" could not be resolved from source I'm using Visual Studio Code to write a small script and part of it involves using dateutil to parse a string and see if a date exists. Very straight forward, but for some reason, import dateutil just doesn't work. I've read around and I've tried every suggestion...
Import "dateutil" could not be resolved from source
I'm using Visual Studio Code to write a small script and part of it involves using dateutil to parse a string and see if a date exists. Very straight forward, but for some reason, import dateutil just doesn't work. I've read around and I've tried every suggestion I've ran into Making sure that pip -V and python -V cor...
[ "I have had this error a couple of times the last months.\nFor me, the issue has been connected to the Python interpreter in use\n(I believe this is only an issue if you are using a virtual environment)\nThe solution has been to replace the venv interpreter (recommended) with the global interpreter of the same vers...
[ 0 ]
[]
[]
[ "python" ]
stackoverflow_0072624237_python.txt
Q: How to print test results in teardown using autouse fixtures in pytest I am new to pytest and I am trying to understand fixtures. I want to print the result of my testcase (pass or fail) in teardown of the fixture. The fixture should be use the auto use feature . Upon running the testcase if the testcase has faile...
How to print test results in teardown using autouse fixtures in pytest
I am new to pytest and I am trying to understand fixtures. I want to print the result of my testcase (pass or fail) in teardown of the fixture. The fixture should be use the auto use feature . Upon running the testcase if the testcase has failed. The print statement should say pass or fail if the test cases has failed ...
[ "I agree with Community's comment but, if all you want is to access the results of the tests in the teardown part of the fixture, it is documented: https://docs.pytest.org/en/latest/example/simple.html#making-test-result-information-available-in-fixtures\n(Also, your question may be a duplicate of How to use test r...
[ 0 ]
[]
[]
[ "fixtures", "pytest", "python", "selenium" ]
stackoverflow_0074257347_fixtures_pytest_python_selenium.txt
Q: Django simple jwt authentication returning an weird error even if with default settings in settings.py file Hello django simple jwt users, while implementing django simple jwt authentication token generation I've encountered with an issue - the default project configurations returning errors and asking I am using ...
Django simple jwt authentication returning an weird error even if with default settings in settings.py file
Hello django simple jwt users, while implementing django simple jwt authentication token generation I've encountered with an issue - the default project configurations returning errors and asking I am using python version 3.10 and latest version of simple jwt auth lib. from jwt import InvalidAlgorithmError, InvalidT...
[ "You need to check the package and python version.\nI have tried with python2.7 it's working.\nIt seems to be deprecated or moved to the latest version of python.\n\n" ]
[ 0 ]
[]
[]
[ "django", "django_rest_framework", "django_rest_framework_simplejwt", "jwt", "python" ]
stackoverflow_0074272969_django_django_rest_framework_django_rest_framework_simplejwt_jwt_python.txt
Q: Connect to Kafka from another docker container This is my compose setup: version: "3" services: zoo: image: confluentinc/cp-zookeeper:7.2.1 hostname: zoo container_name: zoo ports: - "2181:2181" environment: ZOOKEEPER_CLIENT_PORT: 2181 ZOOKEEPER_SERVER_ID: 1 ZOOKEEPER...
Connect to Kafka from another docker container
This is my compose setup: version: "3" services: zoo: image: confluentinc/cp-zookeeper:7.2.1 hostname: zoo container_name: zoo ports: - "2181:2181" environment: ZOOKEEPER_CLIENT_PORT: 2181 ZOOKEEPER_SERVER_ID: 1 ZOOKEEPER_SERVERS: zoo:2888:3888 kafka: image: conflue...
[ "It seems you are missing the network in your docker-compose. Try to create a network in this way. You can learn more about networks from docker doc\nedit\nI tried your code and I found that the problem is just the kafka port number you are trying to connect to. You have to use the INTERNAL port (19092) and not the...
[ 0 ]
[]
[]
[ "apache_kafka", "docker", "docker_compose", "python" ]
stackoverflow_0074272850_apache_kafka_docker_docker_compose_python.txt
Q: Flask update a global variable with value from Redis I have a python flask app with a global variable reading some data from Redis. I have another process that's updating data in Redis independently, and it will ping the flask app (i.e. endpoint /reload-redis-data) to tell flask app to update that global variable ...
Flask update a global variable with value from Redis
I have a python flask app with a global variable reading some data from Redis. I have another process that's updating data in Redis independently, and it will ping the flask app (i.e. endpoint /reload-redis-data) to tell flask app to update that global variable with the latest data in Redis. There are 3 files involved:...
[ "So, your function.py file is rendered once when the server starts, and after that, only the function f() is rendered when /test is called. Since you only import the variable a once in the function.py script and that is also rendered only when the server starts, the script does not check if it is updated in the uti...
[ 1 ]
[]
[]
[ "flask", "global_variables", "python", "redis" ]
stackoverflow_0074239500_flask_global_variables_python_redis.txt
Q: Attempting secure socket communication between client and server and getting An operation was attempted on something that is not a socket error I am attempting to piece together a secure socket client server communication solution. I do not have experience in doing so, so have cobbled together what I believe are r...
Attempting secure socket communication between client and server and getting An operation was attempted on something that is not a socket error
I am attempting to piece together a secure socket client server communication solution. I do not have experience in doing so, so have cobbled together what I believe are relevant sections. The idea is that the Server waits for connections, the client creates a connection that is secure and then communication can take p...
[ "Ok, It seems like I was close, but had a couple of tweaks to do.\nThe solution of:\nSSL/TLS client certificate verification with Python v3.4+ SSLContext\nand the commenters here, helped me get over the finish line.\nServer code:\nimport socket\nimport os\nfrom socket import AF_INET, SOCK_STREAM, SO_REUSEADDR, SOL_...
[ 0 ]
[]
[]
[ "python", "sockets", "ssl" ]
stackoverflow_0074269888_python_sockets_ssl.txt
Q: Is there a way when using pd.read_csv to get type of value datetime.datetime not timestamp? When I using parse_dates in read_csv, the type of date col is loaded as timestamp. I want a datetime.datetime object, not a timestamp. Is there any way? Do I need to convert from timestamp to datetime.datetime? A: Here ...
Is there a way when using pd.read_csv to get type of value datetime.datetime not timestamp?
When I using parse_dates in read_csv, the type of date col is loaded as timestamp. I want a datetime.datetime object, not a timestamp. Is there any way? Do I need to convert from timestamp to datetime.datetime?
[ "Here is how to convert timestamp to datetime:\ndf['date'] = pd.to_datetime(df['date'], unit='s')\n\nIf the timestamp shows the datetime as seconds use unit='s'. Otherwise:\ndf['date'] = pd.to_datetime(df['date'], infer_datetime_format=True)\n\n" ]
[ 0 ]
[]
[]
[ "dataframe", "datetime", "pandas", "python" ]
stackoverflow_0074273152_dataframe_datetime_pandas_python.txt
Q: does a instance expire once used? I'm new-ish to Python and know enough to make things happen but still learning some of the core concepts. So todays question is ... when i make a instance of something. is it a temporary thing that vanishes after its been used or does it sit in memory taking up space ? The reason ...
does a instance expire once used?
I'm new-ish to Python and know enough to make things happen but still learning some of the core concepts. So todays question is ... when i make a instance of something. is it a temporary thing that vanishes after its been used or does it sit in memory taking up space ? The reason i went down this thought process is i h...
[ "Python is garbage collected. This means that a garbage collector engine automatically checks for unused objects and frees them up in memory. This has its pros and cons. The pro is that you don’t have to bother about memory leaks (loss of available memory because the space for unused objects isn’t freed up, so you’...
[ 0 ]
[]
[]
[ "instance", "python" ]
stackoverflow_0074273054_instance_python.txt
Q: Python conversion between coordinates Are there functions for conversion between different coordinate systems? For example, Matlab has [rho,phi] = cart2pol(x,y) for conversion from cartesian to polar coordinates. Seems like it should be in numpy or scipy. A: Using numpy, you can define the following: import nump...
Python conversion between coordinates
Are there functions for conversion between different coordinate systems? For example, Matlab has [rho,phi] = cart2pol(x,y) for conversion from cartesian to polar coordinates. Seems like it should be in numpy or scipy.
[ "Using numpy, you can define the following:\nimport numpy as np\n\ndef cart2pol(x, y):\n rho = np.sqrt(x**2 + y**2)\n phi = np.arctan2(y, x)\n return(rho, phi)\n\ndef pol2cart(rho, phi):\n x = rho * np.cos(phi)\n y = rho * np.sin(phi)\n return(x, y)\n\n", "The existing answers can be simplified:...
[ 126, 23, 17, 14, 11, 5, 3, 3, 0, 0 ]
[ "Thinking about it in general, I would strongly consider hiding coordinate system behind well-designed abstraction. Quoting Uncle Bob and his book:\nclass Point(object)\n def setCartesian(self, x, y)\n def setPolar(self, rho, theta)\n def getX(self)\n def getY(self)\n def getRho(self)\n def setThe...
[ -5 ]
[ "coordinate_systems", "python" ]
stackoverflow_0020924085_coordinate_systems_python.txt
Q: What does a backslash at the end of a line mean? In this exercise i was supposed to capitalise everything that needs to be capitalised like the "I"s or the first letter of a new sentence etc.. In my attempt i tried to use "=", but python doesn't allow that. So i just looked at the solutions. In the following solut...
What does a backslash at the end of a line mean?
In this exercise i was supposed to capitalise everything that needs to be capitalised like the "I"s or the first letter of a new sentence etc.. In my attempt i tried to use "=", but python doesn't allow that. So i just looked at the solutions. In the following solution the author uses " + \ " (with comment), can someon...
[ "New lines often signal the end of a statement to the python interpreter. \nThere are however a few exceptions to this rule:\nSemicolon\nx=5; y=6; z=x+y; print(z);\n\nIn the code above, the semicolon (;) is used to signal the end of a statement, and thus allows multiple statements to be written on a single line.\nN...
[ 1 ]
[]
[]
[ "python", "syntax" ]
stackoverflow_0074272692_python_syntax.txt
Q: How do I get these tags in hover element using Python + Selenium I'm using Python and Selenium to parse a web page. I want to get the numbers 45, 77, and 298 from this element: <li id="guru" rel="popover-srs" title="" data-content="<ul><li>Radicals<span>45</span></li><li>Kanji<span>77</span></li><li>Vocabulary<sp...
How do I get these tags in hover element using Python + Selenium
I'm using Python and Selenium to parse a web page. I want to get the numbers 45, 77, and 298 from this element: <li id="guru" rel="popover-srs" title="" data-content="<ul><li>Radicals<span>45</span></li><li>Kanji<span>77</span></li><li>Vocabulary<span>298</span></li></ul>" data-original-title="<div class='srs-logo gur...
[ "The data you are looking for is inside the data-content attribute of that element, not a text content.\nWhat you can do here is to get the data-content attribute value and then to extract these values form there.\nSomething like the following:\ndata_content = driver.find_element(By.ID, 'guru')get_attribute(\"data-...
[ 1 ]
[]
[]
[ "getattribute", "python", "python_3.x", "selenium", "selenium_webdriver" ]
stackoverflow_0074270271_getattribute_python_python_3.x_selenium_selenium_webdriver.txt
Q: Trying to write data to specific column using pandas dataframes ` import pandas as pd import numpy as np import csv header = ["Blues", "Jazz", "Rock", "Country", "Pop", "Rap", "Metal", "Classical"] with open("music.csv", "w") as SectorCSV: csvwriter = csv.writer(SectorCSV, lineterminator = "\n") print("C...
Trying to write data to specific column using pandas dataframes
` import pandas as pd import numpy as np import csv header = ["Blues", "Jazz", "Rock", "Country", "Pop", "Rap", "Metal", "Classical"] with open("music.csv", "w") as SectorCSV: csvwriter = csv.writer(SectorCSV, lineterminator = "\n") print("Creating Sector.csv") csvwriter.writerow(header) df = ["Beethoven...
[ "I'm this is what you are excepting\ndf = pd.DataFrame()\ndf['columnname'] = [\"Beethoven\", \"Mozart\", \"Adele\", \"Beyonce\", \"Nirvana\", \"Eminem\", \"Metallica\", \"Bach\"]\ndf.to_csv(\"Sector.csv\", index=False, columns=header, mode=\"a\")\n\n" ]
[ 1 ]
[]
[]
[ "csv", "dataframe", "export_to_csv", "pandas", "python" ]
stackoverflow_0074273269_csv_dataframe_export_to_csv_pandas_python.txt
Q: Python Kivi ScrollView not scrolling with StackLayout I was trying to add a ScrollView to my code along with a StackLayout but it is not working. It should have been enabling the user to scroll but it just shows the upper part/the part that fits into the screen and refuses to scroll further. Here is the code: clas...
Python Kivi ScrollView not scrolling with StackLayout
I was trying to add a ScrollView to my code along with a StackLayout but it is not working. It should have been enabling the user to scroll but it just shows the upper part/the part that fits into the screen and refuses to scroll further. Here is the code: class ScrollViewExample(ScrollView): def __init__(self, **k...
[ "Let's keep this as simple as possible.\nWhen you set height in __init__ to its minimum_height, it sets the initial available height. But when the actual height changes (depending on window or parent), it does nothing. In order to listen to this changes you need to track the changes with a event listener i.e. a cal...
[ 0 ]
[]
[]
[ "kivy", "python" ]
stackoverflow_0074267506_kivy_python.txt
Q: Word Conversion to Numbers in Dynamic way Dears, I'm converting words to numbers than removing vowels, it's working fine except when word are starting with vowel the program stops working ...sounds logic since the tool is removing vowel each time it encouter one of the letters from this list: {'a','e','i','o','u'}...
Word Conversion to Numbers in Dynamic way
Dears, I'm converting words to numbers than removing vowels, it's working fine except when word are starting with vowel the program stops working ...sounds logic since the tool is removing vowel each time it encouter one of the letters from this list: {'a','e','i','o','u'} , can we get ride of this issue by any trick o...
[ "The filter_out is a dictionary but you are trying to use it as a list. Make it ['d','t'] instead of {'d','t'}\nimport PySimpleGUI as sg\n\nalphabet = {'a':'1','b':'2','c':'3','d':'4','e':'5','f':'6','g':'7','h':'8','i':'9','j':'10',\n'k':'11','l':'12','m':'13','n':'14','o':'15','p':'16','q':'17','r':'18','s':'19',...
[ 0 ]
[]
[]
[ "list", "numbers", "pysimplegui", "python", "string" ]
stackoverflow_0074273202_list_numbers_pysimplegui_python_string.txt
Q: How the request.data can used for switching the django class view? I am trying to use single API to call the different class based view. Actually planning to solve this by using another function. Is this pythonic way? My Urls.py from django.urls import path from masterdata import views from rest_framework.urlpatte...
How the request.data can used for switching the django class view?
I am trying to use single API to call the different class based view. Actually planning to solve this by using another function. Is this pythonic way? My Urls.py from django.urls import path from masterdata import views from rest_framework.urlpatterns import format_suffix_patterns urlpatterns = [ path('AAA/', view...
[ "You can use different request methods (GET, POST, DELETE, PUT etc) in sinlge APIView.\nAlternately you can pass a variable in request params to validate and call the specific function. Ideally it also depend on the approach you are using the the project size also.\nFor help you can see this link.\nhttps://testdri...
[ 0 ]
[]
[]
[ "django", "django_models", "django_rest_framework", "django_views", "python" ]
stackoverflow_0074273219_django_django_models_django_rest_framework_django_views_python.txt
Q: Use search function on a website with Python Requests(ebay) I'm trying to create a Python program using the Requests library that searches ebay for an item that they enter. Rather than hard-coding the url, is it possible to use requests library to perform an Ebay search (or a search on any website)? A: I believe...
Use search function on a website with Python Requests(ebay)
I'm trying to create a Python program using the Requests library that searches ebay for an item that they enter. Rather than hard-coding the url, is it possible to use requests library to perform an Ebay search (or a search on any website)?
[ "I believe what you want here is to input a text in a search element. According to realpython: \n\nThe requests library is the de facto standard for making HTTP requests in Python.\n\nI would recommend to use selenium to control the website's source code such as inputting a text in an element and press a button on ...
[ 1, 0, 0 ]
[]
[]
[ "python", "python_requests" ]
stackoverflow_0056014847_python_python_requests.txt
Q: How to scrape multiple pages with the same URL - Python 3 https://hk.centanet.com/findproperty/en/list/transaction?gclid=Cj0KCQjwnbmaBhD-ARIsAGTPcfVae1prjf_9aKh0dbnaBbzYvi3VhKn4qEXDAQJMS6ZvOiet8GLqzaAaAqH_EALw_wcB&q=3qoOuFNgwUeioKQCtZ9KFA I'm trying to web scrape a table with Python and I want to scrape all data i...
How to scrape multiple pages with the same URL - Python 3
https://hk.centanet.com/findproperty/en/list/transaction?gclid=Cj0KCQjwnbmaBhD-ARIsAGTPcfVae1prjf_9aKh0dbnaBbzYvi3VhKn4qEXDAQJMS6ZvOiet8GLqzaAaAqH_EALw_wcB&q=3qoOuFNgwUeioKQCtZ9KFA I'm trying to web scrape a table with Python and I want to scrape all data in 417 pages in this website. Since the web_url does not change...
[ "You can make the pagination from payload data following the offset key as data is loaded from API as POST method as json format.\nExample:\nimport requests\nimport pandas as pd\n\napi_url= 'https://hk.centanet.com/findproperty/api/Transaction/Search'\nheaders={\n 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win...
[ 2 ]
[]
[]
[ "beautifulsoup", "python", "python_requests", "urllib", "web_scraping" ]
stackoverflow_0074272852_beautifulsoup_python_python_requests_urllib_web_scraping.txt
Q: Unable to build blender I am trying to build blender so that I can use it directly from python and was going through this tutorial and I got stuck on the very first make command giving me CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message): Could NOT find PythonLibsUnix...
Unable to build blender
I am trying to build blender so that I can use it directly from python and was going through this tutorial and I got stuck on the very first make command giving me CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message): Could NOT find PythonLibsUnix (missing: PYTHON_LIBRARY PYT...
[ "For compilation, you have to point to Python3:\ncmake -DPYTHON_LIBRARY=/usr/bin/python3.4m -DPYTHON_INCLUDE_DIR=/usr/include/python3.4m ..\n\n", "This will solve your issue \nsudo apt-get build-dep blender\n\nsimilar compile time dependency problems for other applications can be solved by doing this build-dep t...
[ 6, 3, 1, 1, 0, 0 ]
[]
[]
[ "blender", "compilation", "compiler_errors", "python" ]
stackoverflow_0034064313_blender_compilation_compiler_errors_python.txt
Q: add a column in python with rows number I have a dataset like these state sex birth player QLD m 1993 Dave QLD m 1992 Rob Now I would like to create an additional row, which is the id. ID is equal to the row number but + 1 df = df.assign(ID=range(len(df))) But unfortunately the first ID is zero, how can I fix...
add a column in python with rows number
I have a dataset like these state sex birth player QLD m 1993 Dave QLD m 1992 Rob Now I would like to create an additional row, which is the id. ID is equal to the row number but + 1 df = df.assign(ID=range(len(df))) But unfortunately the first ID is zero, how can I fix that the first ID begins with 1 an...
[ "You can try this:\nimport pandas as pd\n\ndf['ID'] = pd.Series(range(len(df))) + 1\n\n" ]
[ 0 ]
[]
[]
[ "python" ]
stackoverflow_0074272884_python.txt
Q: No module named 'py4j.java_collections' when running exe created using pyinstaller I created an exe file for my pySpark script using pyinstaller. But when i run the exe, I am facing "No module named 'py4j.java_collections'" error. pyinstaller version - 3.5 python version - Python 3.7.1 Spark version - 2.4.3 OS - ...
No module named 'py4j.java_collections' when running exe created using pyinstaller
I created an exe file for my pySpark script using pyinstaller. But when i run the exe, I am facing "No module named 'py4j.java_collections'" error. pyinstaller version - 3.5 python version - Python 3.7.1 Spark version - 2.4.3 OS - Windows 10 I am creating the exe using pyinstaller -F myscript.py command to create the ...
[ "For someone who is still trying to figure out the solution.\nI ran into exact same issue. On inspecting the py4j/java_gateway.py file, there is an import statement __import__(\"py4j.java_collections\") because of which pyinstaller is unable to detect that import by default while building the executable and hence m...
[ 1 ]
[]
[]
[ "exe", "pyinstaller", "pyspark", "python" ]
stackoverflow_0057712179_exe_pyinstaller_pyspark_python.txt
Q: How to get data labels on a Seaborn pointplot? I have two arrays like so: Soldier_years = [1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870] num_records_yob = [7, 5, 8, 9, 15, 17, 23, 19, 52, 55, 73, 73, 107, 137, 65, 182, 228, 257, 477, 8...
How to get data labels on a Seaborn pointplot?
I have two arrays like so: Soldier_years = [1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870] num_records_yob = [7, 5, 8, 9, 15, 17, 23, 19, 52, 55, 73, 73, 107, 137, 65, 182, 228, 257, 477, 853, 2303] I'm trying to get these into a Seaborn po...
[ "you can do it this way:\n[ax.text(p[0], p[1]+50, p[1], color='g') for p in zip(ax.get_xticks(), num_records_yob)]\n\n\n", "For future reference that will want a more general answer I suggest this code:\nymin, ymax = ax.get_ylim()\ncolor=\"#3498db\" # choose a color\nbonus = (ymax - ymin) / 50 # still hard coded ...
[ 15, 1, 1 ]
[]
[]
[ "matplotlib", "pandas", "pointplot", "python", "seaborn" ]
stackoverflow_0037106828_matplotlib_pandas_pointplot_python_seaborn.txt
Q: Pandas Read HTML wont scrape the clickable image For reference I am scraping this website: https://apps.proni.gov.uk/Val12B/SearchResults.aspx The table looked like this: I am trying to scrape this table along with the clickable links on the PRONI REFERENCE header. my code is: table_elements = driver.find_element...
Pandas Read HTML wont scrape the clickable image
For reference I am scraping this website: https://apps.proni.gov.uk/Val12B/SearchResults.aspx The table looked like this: I am trying to scrape this table along with the clickable links on the PRONI REFERENCE header. my code is: table_elements = driver.find_elements_by_xpath(".//table[@id='gvSearchResults']") for i in...
[ "I don't think the image link is anywhere on the page. Clicking the \"hyperlink\" takes you to a page where you can view hundreds of images one-by-one, but the link in the address bar is the same for all rows - the pages on this site all seem to be rendered after a series of requests and redirects, so a simple link...
[ 1 ]
[]
[]
[ "beautifulsoup", "pandas", "python", "selenium", "web_scraping" ]
stackoverflow_0074232047_beautifulsoup_pandas_python_selenium_web_scraping.txt
Q: Django ORM Group By with Foreign Keys user is a foreign key on tournament. select u.id, u.display_name, count(t.id) from tournament t join user u on t.user_id = u.id where date(t.start_date)> '2022-07-01' group by u.display_name, u.id How can I make the above SQL query work with django's ORM? A: In the majo...
Django ORM Group By with Foreign Keys
user is a foreign key on tournament. select u.id, u.display_name, count(t.id) from tournament t join user u on t.user_id = u.id where date(t.start_date)> '2022-07-01' group by u.display_name, u.id How can I make the above SQL query work with django's ORM?
[ "In the majority of cases trying to translate an sql query into Django ORM syntax isn't the way to go.\nFrom what i understand, you want to count tournaments, filtered with a date, bound to an user.\nTry something like:\nUserModel.objects.annotate(tournament_count=Count(\"tournament\", filter=Q(start_date__gt=my_da...
[ 0 ]
[]
[]
[ "django", "django_orm", "django_queryset", "python", "sql" ]
stackoverflow_0074272271_django_django_orm_django_queryset_python_sql.txt
Q: How to retrieve rows based on mismatched condition on particular columns? I need to do the following tasks. I have 9 columns along with the original label. Each of those 9 columns consists of a probability value. Each 3 value is a prediction by a particular model. I have a total of 3 classifier models and there ar...
How to retrieve rows based on mismatched condition on particular columns?
I need to do the following tasks. I have 9 columns along with the original label. Each of those 9 columns consists of a probability value. Each 3 value is a prediction by a particular model. I have a total of 3 classifier models and there are 3 classes. Now I have to apply the max rule. For each class I have to pick th...
[ "Try this.\ndf_mismatch = df.loc[~(df['Class'] == df['pred'])]\n\n" ]
[ 1 ]
[]
[]
[ "database", "pandas", "python" ]
stackoverflow_0074273347_database_pandas_python.txt
Q: returned non-zero exit status 120 I wrote a piece of code that was supposed to run the airflow list_dags command via subprocess. dags_raw = subprocess.check_output( 'airflow list_dags', shell=True ).split() I get the following error message File "/usr/lib/python3.7/subprocess.py", line 411, in che...
returned non-zero exit status 120
I wrote a piece of code that was supposed to run the airflow list_dags command via subprocess. dags_raw = subprocess.check_output( 'airflow list_dags', shell=True ).split() I get the following error message File "/usr/lib/python3.7/subprocess.py", line 411, in check_output **kwargs).stdout File "...
[ "Maybe this link could help you.\n\nChanged in version 3.6: If an error occurs in the cleanup after the Python interpreter has caught SystemExit (such as an error flushing buffered data in the standard streams), the exit status is changed to 120.\n\nCheck first if you can invoke airflow list_dags with no error in P...
[ 0 ]
[]
[]
[ "airflow", "exit_code", "python", "python_3.x", "subprocess" ]
stackoverflow_0074273394_airflow_exit_code_python_python_3.x_subprocess.txt
Q: Resample pandas time series 30 mins for 9:15 as start time I am trying to resample OHLC data to 30 mins. The market data starts at at 9:15 and I would like the resampled time to have 9:15-9:45 and so on. But I am able to get the data resampled as 9:00-9:30 Paste Bin link to 1 min market data pd.DataFrame(download...
Resample pandas time series 30 mins for 9:15 as start time
I am trying to resample OHLC data to 30 mins. The market data starts at at 9:15 and I would like the resampled time to have 9:15-9:45 and so on. But I am able to get the data resampled as 9:00-9:30 Paste Bin link to 1 min market data pd.DataFrame(download_data).set_index('date'['close'].resample('30T').ohlc() As you ...
[ "There is one more way of doing it, you can use the base argument of resample:\npd.DataFrame(download_data).set_index('date'['close'].resample('30T', base=15).ohlc()\n\n", "Solution is add parameter loffset in resample:\n\nloffset : timedelta\nAdjust the resampled time labels\n\ndf = (pd.DataFrame(download_data)\...
[ 3, 1, 1, 0, 0 ]
[]
[]
[ "pandas", "python", "resampling" ]
stackoverflow_0053149168_pandas_python_resampling.txt
Q: PyQt5 Keyboard shortcut for QTableWidget stops working when table is cleared I have a QTableWidget that I want to attach a shortcut to to advance to the next cell when the Enter/Return key is pressed using the code I found below. I reuse the table a couple of times so I call the clear() method in between populatin...
PyQt5 Keyboard shortcut for QTableWidget stops working when table is cleared
I have a QTableWidget that I want to attach a shortcut to to advance to the next cell when the Enter/Return key is pressed using the code I found below. I reuse the table a couple of times so I call the clear() method in between populating the table for its various uses. The code below works fine for the first round, b...
[ "Ok, so instead of using del to unassign the shortcut, I used the .deleteLater() method to more \"formally\" delete the objects. That seems to have worked. I still think it is necessary to store the created shortcut objects in order to unassign them later.\n" ]
[ 0 ]
[]
[]
[ "pyqt5", "python", "qshortcut", "qtablewidget" ]
stackoverflow_0074273480_pyqt5_python_qshortcut_qtablewidget.txt
Q: How to know the name of the thread inside it I have created multiple threads using for loop and I need to read the name of the thread inside the thread. How do I do that? I used threading.Thread.name but returns some memory address of the thread object. here is part of my code: def catch_sharp_fall(update, context...
How to know the name of the thread inside it
I have created multiple threads using for loop and I need to read the name of the thread inside the thread. How do I do that? I used threading.Thread.name but returns some memory address of the thread object. here is part of my code: def catch_sharp_fall(update, context, x): global access_token, watchlist, bot, cha...
[ "When you do threading.Thread.name, you're retrieving name on the Thread type itself, not on the thread object for the current thread. You need to look it up on the current thread object:\nthreading.current_thread().name\n\n", "You can use threading.current_thread().name, t1.name and t2.name as shown below:\nimpo...
[ 3, 0 ]
[]
[]
[ "python", "python_multithreading" ]
stackoverflow_0070209352_python_python_multithreading.txt
Q: SQL want efficient query to SELECT columnA, columnB FROM table1 WHERE both columnA, columnB are in columnC FROM table2 WHERE columndD > value I'm searching for a more efficient method to accomplish something that I've already solved with a few different SQL statements. The problem: I have two tables a transaction...
SQL want efficient query to SELECT columnA, columnB FROM table1 WHERE both columnA, columnB are in columnC FROM table2 WHERE columndD > value
I'm searching for a more efficient method to accomplish something that I've already solved with a few different SQL statements. The problem: I have two tables a transactions table, and an accounts table The transactions table has columns that look like: acct_sending acct_receiving amount tx_datetime 100 101 1...
[ "You must join transactions to 2 copies of accounts and aggregate:\nSELECT MIN(t.acct_sending, t.acct_receiving) sender,\n MAX(t.acct_sending, t.acct_receiving) receiver,\n COUNT(*) count\nFROM transactions t \nINNER JOIN accounts a1 ON a1.account = t.acct_sending AND a1.balance > 10\nINNER JOIN account...
[ 0 ]
[]
[]
[ "count", "group_by", "python", "sql", "sqlite" ]
stackoverflow_0074270749_count_group_by_python_sql_sqlite.txt
Q: Saving data transformer for AzureML model I have an Azure Machine Learning training pipeline that uses scikit-learn's MinMaxScaler in the pre-processing step. What is the best way to save the MinMaxScaler (or any other transformer) so that it can later be used during inference. Ideally I would like to link the tra...
Saving data transformer for AzureML model
I have an Azure Machine Learning training pipeline that uses scikit-learn's MinMaxScaler in the pre-processing step. What is the best way to save the MinMaxScaler (or any other transformer) so that it can later be used during inference. Ideally I would like to link the transformer with the model. One idea that I had wa...
[ "When we create an AutoML, after getting the results, we need to create the registration for the model. Click on the register model to get the properties of the model and about complete information of the model.\n\n\n\n\nWe are getting the properties here and use these properties to get the model information. By de...
[ 0 ]
[]
[]
[ "azure_ml_pipelines", "azuremlsdk", "machine_learning", "python", "scikit_learn" ]
stackoverflow_0074128392_azure_ml_pipelines_azuremlsdk_machine_learning_python_scikit_learn.txt
Q: Does mypy not allow you to define the same variable twice? I've started using Mypy on my code, and I've got the following snippet here: class BPDataStore(): def __init__(self, path: pathlib.Path): self.path: pathlib.Path = path if self.path.exists(): with self.path.open("r") as F: ...
Does mypy not allow you to define the same variable twice?
I've started using Mypy on my code, and I've got the following snippet here: class BPDataStore(): def __init__(self, path: pathlib.Path): self.path: pathlib.Path = path if self.path.exists(): with self.path.open("r") as F: self._bpdata: list[dict] = json.loads(F.read()) ...
[ "The Python interpreter does not care about annotations either way (so long as they are syntactically correct), which is why this \"works\" as you said.\nBut defining a variable more than once is generally not type safe. In this case it technically doesn't matter, because the definitions are identical, but I think ...
[ 1 ]
[]
[]
[ "mypy", "python", "python_typing" ]
stackoverflow_0074271960_mypy_python_python_typing.txt
Q: Delete a row by index from pytorch tensor I have a pytorch tensor of size torch.Size([4, 3, 2]) tensor([[[0.4003, 0.2742], [0.9414, 0.1222], [0.9624, 0.3063]], [[0.9600, 0.5381], [0.5758, 0.8458], [0.6342, 0.5872]], [[0.5891, 0.9453], [0.8859, 0.6552], [0.5120, 0.5384]], ...
Delete a row by index from pytorch tensor
I have a pytorch tensor of size torch.Size([4, 3, 2]) tensor([[[0.4003, 0.2742], [0.9414, 0.1222], [0.9624, 0.3063]], [[0.9600, 0.5381], [0.5758, 0.8458], [0.6342, 0.5872]], [[0.5891, 0.9453], [0.8859, 0.6552], [0.5120, 0.5384]], [[0.3017, 0.9407], [0.4887, 0.8097], ...
[ "The operation below selects all but one \"row\":\nimport torch\n\ntorch.manual_seed(2021)\n\nrow = 2\nx = torch.rand((4, 3, 2))\n\nnew_x = x[torch.arange(1, x.shape[0]+1) != row, ...]\n\nprint(new_x.shape)\n# >>> torch.Size([3, 3, 2])\n\nprint(x)\n# > tensor([[[0.1304, 0.5134],\n# > [0.7426, 0.7159],\n# >...
[ 2, 2, 0, 0 ]
[]
[]
[ "python", "pytorch" ]
stackoverflow_0069132963_python_pytorch.txt
Q: How do I create a calculated column in Pandas I want to create a new column, BSI. The formula: BSI = ln((1+nPd)/(1+nNd)) d = date nP: sum of Positive Predictions nN: sum of Negative Predictions In essence, I want to group the pred_rate column by date, Get the sum of positive predictions (1) and negative predict...
How do I create a calculated column in Pandas
I want to create a new column, BSI. The formula: BSI = ln((1+nPd)/(1+nNd)) d = date nP: sum of Positive Predictions nN: sum of Negative Predictions In essence, I want to group the pred_rate column by date, Get the sum of positive predictions (1) and negative predictions (0) for each group Perform the BSI calculatio...
[ "Having a df as such:\ndf=pd.DataFrame(\n {\n 'date':[\n '2019-12-14'\n ,'2019-12-14'\n ,'2019-12-15'\n ,'2019-12-15'\n ,'2019-12-15'\n ,'2019-12-16'\n ,'2019-12-16'\n ,'2019-12-16'\n ,'2019-12-16'\n ...
[ 0 ]
[]
[]
[ "group_by", "pandas", "python" ]
stackoverflow_0074273532_group_by_pandas_python.txt
Q: How to sum cell data from multiple CSV files into a single parquet? QUESTION: Is there a more efficient way of summing corresponding data entries from a handful of large CSV files (5-20 files, 600MB each) into a single parquet? All CSV files have the exact same format. I am currently working on a program that gen...
How to sum cell data from multiple CSV files into a single parquet?
QUESTION: Is there a more efficient way of summing corresponding data entries from a handful of large CSV files (5-20 files, 600MB each) into a single parquet? All CSV files have the exact same format. I am currently working on a program that generates images from math equations (think fractal flames). There are two p...
[ "You can use the dataset API in PyArrow to point to a system of CSV (or Parquet) files and convert them into a single Parquet file directly.\nimport pyarrow.dataset as ds\n\ntable = ds.dataset(\"C:\\Users\\Path\\to\\input\", format=\"parquet\")\nds.write_dataset(table, \"C:\\Users\\Path\\to\\output\", format = \"pa...
[ 2 ]
[]
[]
[ "c++", "file_transfer", "parquet", "pyarrow", "python" ]
stackoverflow_0074272379_c++_file_transfer_parquet_pyarrow_python.txt
Q: Show a random number every second in Kivy I'm trying to create a button, when pressed it shows a random integer in a range from 1-10 each second continuously for 10 seconds.I'm completely new to kivy, but I've searched related questions on the internet, so please be gentle. Currently the the label text only shows ...
Show a random number every second in Kivy
I'm trying to create a button, when pressed it shows a random integer in a range from 1-10 each second continuously for 10 seconds.I'm completely new to kivy, but I've searched related questions on the internet, so please be gentle. Currently the the label text only shows the last number. Kivy waits for the for loop to...
[ "\nWhile the for loop is taking place, kivy gui will die out...\n\nApparently that's not true. Your callback do_button_click runs on the same thread as the GUI but sequentially. That's why once the execution of the callback finished, it then renders the final result in the GUI. To execute that separately you can us...
[ 0 ]
[]
[]
[ "kivy", "kivy_language", "python", "python_3.x", "user_interface" ]
stackoverflow_0074271640_kivy_kivy_language_python_python_3.x_user_interface.txt
Q: Trying to split single excel file into multiple based on month using date and time column using python I have a excel file contains multiple rows with date. I want to make 12 separate file for each month. Can anyone suggest me how to do that using python? I tried to do manually using excel sheets, However its taki...
Trying to split single excel file into multiple based on month using date and time column using python
I have a excel file contains multiple rows with date. I want to make 12 separate file for each month. Can anyone suggest me how to do that using python? I tried to do manually using excel sheets, However its taking long when I am using more than 100k rows.
[ "You can try Below:\nimport pandas as pd\n\ndf = pd.read_excel('Data.xlsx')\nprint(df)\n\n# date data\n#2019-01-14 1\n#2019-02-14 2\n#2019-03-14 3\n#2019-03-15 4\n#2019-04-16 5\n#2019-07-17 6\n#2019-05-18 7\n#2019-06-19 8\n#2019-08-20 9\n#2019-09-21 0\n#2019-11-22 10...
[ 0 ]
[]
[]
[ "excel", "python" ]
stackoverflow_0074268630_excel_python.txt
Q: disable zarr.open() output in console I have unwanted outputs in the console from zarr.open() method. It does not have 'verbose-like' parameter. How can I get rid of those input console ? I'm currently trying to open .ims files (Imaris pictures) thus using the zarr library through this tutorial . Here is my code: ...
disable zarr.open() output in console
I have unwanted outputs in the console from zarr.open() method. It does not have 'verbose-like' parameter. How can I get rid of those input console ? I'm currently trying to open .ims files (Imaris pictures) thus using the zarr library through this tutorial . Here is my code: from imaris_ims_file_reader.ims import ims ...
[ "The reader code itself is printing these values. From https://github.com/CBI-PITT/imaris_ims_file_reader/blob/master/imaris_ims_file_reader/ims_zarr_store.py#L131\n def _fromfile(self,index):\n print(index)\n array = self.ims[\n self.ResolutionLevelLock,\n index[0][0]:index[0...
[ 0 ]
[]
[]
[ "console_output", "python", "zarr" ]
stackoverflow_0074261848_console_output_python_zarr.txt
Q: using selenium with python to google href " Getting this error NoSuchElementException: Message: no such element: Unable to locate element: " using selenium with python to google href or click on the links to open them but Getting this error NoSuchElementException: Message: no such element: Unable to locate element...
using selenium with python to google href " Getting this error NoSuchElementException: Message: no such element: Unable to locate element: "
using selenium with python to google href or click on the links to open them but Getting this error NoSuchElementException: Message: no such element: Unable to locate element: " This is the Code I wrote to do it. url = "https://www.google.com/search?q="+text_fetch # The Dutch Dress in Orange—Why? driver.get(url) ...
[ "Instead of '//*[@id=\"rso\"]/div[1]/div/div/div[1]/div/a' this XPath should work: //*[@id=\"rso\"]//a[@data-ved][@ping]. I tested that on other random inputs and it worked.\nAlso, instead of hardcoded sleeps time.sleep(7) WebDriverWait expected_conditions explicit waits should be used.\nThis coded worked:\nfrom se...
[ 1 ]
[]
[]
[ "python", "selenium", "selenium_chromedriver", "webdriverwait", "xpath" ]
stackoverflow_0074272528_python_selenium_selenium_chromedriver_webdriverwait_xpath.txt
Q: List of lists (or numpy array): extracting data via SQL-like methods? The problem: given a (large) Python list-of-lists, or, semi-equivalently, a numpy array, extract information from the array in a SQL-like manner, i.e., as if the array were a database. For example: given a 4-column by (large) N-row array, extrac...
List of lists (or numpy array): extracting data via SQL-like methods?
The problem: given a (large) Python list-of-lists, or, semi-equivalently, a numpy array, extract information from the array in a SQL-like manner, i.e., as if the array were a database. For example: given a 4-column by (large) N-row array, extract the rows where the first column is equal to X. In SQL this would be: SELE...
[ "This might not be exactly what you are looking for, but I hope it can be helpful either way. :) I wrote a loop implementation that should be more efficient than the one you provided since we only loop through the column twice. We use a dictionary to keep track of the number of times a specific value in the first c...
[ 1 ]
[]
[]
[ "data_structures", "numpy", "python", "search", "sql" ]
stackoverflow_0074270653_data_structures_numpy_python_search_sql.txt
Q: FastAPI inputs check format and execute according method for that given format I am using FastAPI for Machine Learning model deployment in two cases based on the nature of the data we feed as inputs (features) which it an array of json. Thus, if inputs are matching method1 we execute the according model to it othe...
FastAPI inputs check format and execute according method for that given format
I am using FastAPI for Machine Learning model deployment in two cases based on the nature of the data we feed as inputs (features) which it an array of json. Thus, if inputs are matching method1 we execute the according model to it otherwise we apply method2 and execute the trained model for this case. How can I achiev...
[ "You can create a pydantic scheme as a dependency, that includes all the possible fields (Optional) for both data types and check incoming data by special field into it. Also you can use different routes. Could you show JSON samples?\n" ]
[ 1 ]
[]
[]
[ "api", "fastapi", "machine_learning", "pydantic", "python" ]
stackoverflow_0074265837_api_fastapi_machine_learning_pydantic_python.txt
Q: PyGAD is not receiving integer parameters according to documentation I am trying to use PyGAD to optimize hyper-parameters in ML models. According to documentation The gene_space parameter customizes the space of values of each gene ... list, tuple, numpy.ndarray, or any range like range, numpy.arange(), or numpy...
PyGAD is not receiving integer parameters according to documentation
I am trying to use PyGAD to optimize hyper-parameters in ML models. According to documentation The gene_space parameter customizes the space of values of each gene ... list, tuple, numpy.ndarray, or any range like range, numpy.arange(), or numpy.linspace: It holds the space for each individual gene. But this space is ...
[ "There're 2 issues I've spotted here:\n\npygad.GA does not derive the numerical type out of the relevant gene values of \"gene_space\" and simply convert all the numerical values into 'float'. \nIn order to fix this, the \"gene_type\" parameter must be used to specify the respected types of gene values.\nhttps://py...
[ 2 ]
[]
[]
[ "genetic_algorithm", "machine_learning", "numpy", "pygad", "python" ]
stackoverflow_0074165018_genetic_algorithm_machine_learning_numpy_pygad_python.txt
Q: Strugling to scrape titles with scrapy I am currently trying to scrape a title via Scrapy's shell. https://cineb.art/movies is the website, the title is located in : <h3 class="film-name"> When i type response.css("film-name").get() i get nothing in return fetch('https://cineb.art/movies') 2022-11-01 12:17:24...
Strugling to scrape titles with scrapy
I am currently trying to scrape a title via Scrapy's shell. https://cineb.art/movies is the website, the title is located in : <h3 class="film-name"> When i type response.css("film-name").get() i get nothing in return fetch('https://cineb.art/movies') 2022-11-01 12:17:24 [scrapy.core.engine] DEBUG: Crawled (200)...
[ "there is an \"a\" tag under \"h3\" tag and you need to get text\nresponse.css(\"h3.film-name a::text\").get()\n\n" ]
[ 0 ]
[]
[]
[ "python", "scrapy", "web_scraping" ]
stackoverflow_0074273786_python_scrapy_web_scraping.txt
Q: What is the python-poetry config file after 1.2.0 release? I have been using python-poetry for over a year now. After poetry 1.2.0 release, I get such an info warning: Configuration file exists at ~/Library/Application Support/pypoetry, reusing this directory. Consider moving configuration to ~/Library/Preferenc...
What is the python-poetry config file after 1.2.0 release?
I have been using python-poetry for over a year now. After poetry 1.2.0 release, I get such an info warning: Configuration file exists at ~/Library/Application Support/pypoetry, reusing this directory. Consider moving configuration to ~/Library/Preferences/pypoetry, as support for the legacy directory will be removed...
[ "Looks like it is as simple as copy/pasting to the new directory.\nI got the same error after upgrading to Poetry 1.2. So I created a pypoetry folder in the new Preferences directory, copy/pasted the config.toml to it, and just to be safe, I renamed the original folder to:\n~/Library/Application Support/pypoetry_b...
[ 12, 3, 1 ]
[]
[]
[ "python", "python_poetry" ]
stackoverflow_0073597456_python_python_poetry.txt
Q: Custom fixed bar width in Plotly Express, Python 3 I am trying to deal with axis labels overlapping by having the axis width dynamical in my horizontal bar plot: fig = px.bar(df, orientation='h') fig.update_layout( yaxis_nticks = len(df.columns), height = len(df.columns)*30, ).update_xaxes(autom...
Custom fixed bar width in Plotly Express, Python 3
I am trying to deal with axis labels overlapping by having the axis width dynamical in my horizontal bar plot: fig = px.bar(df, orientation='h') fig.update_layout( yaxis_nticks = len(df.columns), height = len(df.columns)*30, ).update_xaxes(automargin = True, ).update_yaxes(automargin = True) Fo...
[ "Figured it out. The bar width can be specified in update_traces:\nfig = px.bar(df, orientation='h').update_traces(width = 0.7)\n\nHoping this helps some one.\n" ]
[ 0 ]
[]
[]
[ "plot", "plotly", "python" ]
stackoverflow_0074273249_plot_plotly_python.txt
Q: Problems while printing numbers in Python I'm making a program that prints all the prime numbers from a number that the user enters. Everything is working but I'm just having trouble printing the numbers. def math(user): for num in range (user + 1): if num > 1: for i in range(2,num): if (num % ...
Problems while printing numbers in Python
I'm making a program that prints all the prime numbers from a number that the user enters. Everything is working but I'm just having trouble printing the numbers. def math(user): for num in range (user + 1): if num > 1: for i in range(2,num): if (num % i) == 0: break else: pr...
[ "I do not think the [duplicate] answer will help much OP until they first get to the proper logical steps to reach the [duplicate] question.\nA bit like suggested, you could print the beginning of your answer first (or store as a string) and then calculate your list of result and concatenate the whole things at the...
[ 0 ]
[]
[]
[ "loops", "primes", "printing", "python" ]
stackoverflow_0074271011_loops_primes_printing_python.txt
Q: how to check is staff is True before login into dashboard which i have created by myself in Django? I have created a dashboard and in my dashboard superuser creates the username, password, and all this thing but in my dashboard, I want to check first the username is staff or not before login into the dashboard. ho...
how to check is staff is True before login into dashboard which i have created by myself in Django?
I have created a dashboard and in my dashboard superuser creates the username, password, and all this thing but in my dashboard, I want to check first the username is staff or not before login into the dashboard. how to do that? can anyone help me from django.shortcuts import redirect, render from django.contrib import...
[ "You can check the status after authenticate if it returns not None as\nfrom django.shortcuts import redirect, render\nfrom django.contrib import auth, messages\nfrom orderkitchen.models import kitchenData \nfrom django.contrib.auth.models import User\n\ndef login_dashboard(request):\n\n if request.method == 'PO...
[ 1, 0, 0 ]
[]
[]
[ "django", "django_models", "django_views", "python", "view" ]
stackoverflow_0070912940_django_django_models_django_views_python_view.txt
Q: How to convert a function to a recursive function Hey guys I don't know if I can ask this but I'm working on the original files in google collab and I wrote a function that sums all the sizes of the file import os def recls_rtsize(argpath): sumsize = 0 for entry in os.scandir(argpath): path= argpath+'/'+e...
How to convert a function to a recursive function
Hey guys I don't know if I can ask this but I'm working on the original files in google collab and I wrote a function that sums all the sizes of the file import os def recls_rtsize(argpath): sumsize = 0 for entry in os.scandir(argpath): path= argpath+'/'+entry.name size= os.path.getsize(path) sumsize+=...
[ "Recursive function is the function which calls itself. For example if You are trying to calculate the sum of all files inside some directory You can just loop through files of that directory and summarize the sizes of the files. If directory You are checking for has subdirectories, then you can just put a conditio...
[ 1, 0, 0 ]
[]
[]
[ "python", "recursion" ]
stackoverflow_0074273660_python_recursion.txt
Q: multiple python lists to table rows in HTML I have multiple lists created in python. I am trying to convert these lists into HTML rows. week = ['1','2'] date = ['2022-10-01','2022-10-09'] My HTML table should look like below: Week Date 1 2022-10-01 2 2022-10-09 what I tried so far: {% for val ...
multiple python lists to table rows in HTML
I have multiple lists created in python. I am trying to convert these lists into HTML rows. week = ['1','2'] date = ['2022-10-01','2022-10-09'] My HTML table should look like below: Week Date 1 2022-10-01 2 2022-10-09 what I tried so far: {% for val in data %} <tr> <td> {% for item in val.we...
[ "You can use dictionary comprehension to convert the two lists into a dictionary where the key would be the week number and the value would be the corresponding date. You can loop over the dictionary as key and value using the items attribute in the template.\n# views.py\nweek = [1, 2]\ndate = ['2022-10-01','2022-1...
[ 1, 1 ]
[]
[]
[ "html", "python" ]
stackoverflow_0074273675_html_python.txt
Q: ModuleNotFoundError: No module named 'pymongo' i'm trying to run following script: import pymongo client = pymongo.MongoClient() mydb = ["Games"] mycol = ["pcgames"] data = {"Title": "Hollow Knight", "rating": 10} mycol.insert_one(data) but i'm getting following error: Traceback (most recent call last): File...
ModuleNotFoundError: No module named 'pymongo'
i'm trying to run following script: import pymongo client = pymongo.MongoClient() mydb = ["Games"] mycol = ["pcgames"] data = {"Title": "Hollow Knight", "rating": 10} mycol.insert_one(data) but i'm getting following error: Traceback (most recent call last): File "c:\users\brend\onedrive - ict medien produktive u...
[ "I think you haven't installed pymongo in your system.\nYou can do so by using the following command:\npython -m pip install pymongo\n\n" ]
[ 0 ]
[]
[]
[ "mongodb", "pymongo", "python" ]
stackoverflow_0074195087_mongodb_pymongo_python.txt
Q: In PyCharm how can I move the text to the left? I don't like it in the center I would like to see all the code text on the left when I open PyCharm. I don't like that the code is all placed in the center. I would like to move it to the left. How can I? There are no spaces before the code. It happens to all PyCharm...
In PyCharm how can I move the text to the left? I don't like it in the center
I would like to see all the code text on the left when I open PyCharm. I don't like that the code is all placed in the center. I would like to move it to the left. How can I? There are no spaces before the code. It happens to all PyCharm files. The same files, if imported into another editor, have the code positioned o...
[ "Seems like the distraction free (view-)mode is active. \nTry View > Appearance > Exit Distraction free mode.\n", "This is what a plain Python file looks like in a fairly standard installation of PyCharm.\n\nNote how there's no ruler over the editor, where yours appears to have one, and the gutter is coloured dif...
[ 2, 0 ]
[]
[]
[ "pycharm", "python", "python_3.x" ]
stackoverflow_0074272667_pycharm_python_python_3.x.txt
Q: missing 1 required positional argument: 'after' so i've made a private bot in only two servers and what i wanted it to do is to automatically change his profile picture whenever the server he was in changes. but when i try to trigger the command by changing the server's icon, it just says: File "C:\Users\AcerAspi...
missing 1 required positional argument: 'after'
so i've made a private bot in only two servers and what i wanted it to do is to automatically change his profile picture whenever the server he was in changes. but when i try to trigger the command by changing the server's icon, it just says: File "C:\Users\AcerAspire\AppData\Roaming\Python\Python301\site-package\disc...
[ "As you already show in your type hints, both before and after are already discord.Guild objects. Instead of ctx.guild just use before to get the guild before the update, or after for the guild after the update. So after.icon_url should work fine. You already had it in the equality check.\n@bot.event\nasync def on_...
[ 0 ]
[]
[]
[ "bots", "discord", "discord.py", "python" ]
stackoverflow_0074271346_bots_discord_discord.py_python.txt
Q: When testing code with pyspark dataframe: how to mock up .repartition() chained function? I have code using pyspark library and I want to test it with pytest However, I want to mock up .repartition() method on dataframes when running tests Suppose that code I want to test is a pyspark chained function like below ...
When testing code with pyspark dataframe: how to mock up .repartition() chained function?
I have code using pyspark library and I want to test it with pytest However, I want to mock up .repartition() method on dataframes when running tests Suppose that code I want to test is a pyspark chained function like below def transform(df: pyspark.sql.DataFrame): return ( df .repartition("id") ...
[ "Please chain calls like below. See here similar one\n@mock.patch(\"pyspark.sql.DataFrame\")\ndef test_transform(df: Mock):\n expected_df = \"expected value\"\n df.repartition.return_value.groupby.return_value.sum.return_value = expected_df\n df_output = transform(df)\n assert df_output == expected_df\n...
[ 1 ]
[]
[]
[ "pyspark", "pytest", "python", "python_unittest", "python_unittest.mock" ]
stackoverflow_0074240568_pyspark_pytest_python_python_unittest_python_unittest.mock.txt
Q: How to fix these errors for my program because its saying can't open file 'd:\\pythion proj\\import requests.py': [Errno 2] No such file or directory This is the porblem that I am expriecing and I am very confused on how I can fix it. Exception has occurred: ConnectionError [Errno 2] No such file or directory: 'd:...
How to fix these errors for my program because its saying can't open file 'd:\\pythion proj\\import requests.py': [Errno 2] No such file or directory
This is the porblem that I am expriecing and I am very confused on how I can fix it. Exception has occurred: ConnectionError [Errno 2] No such file or directory: 'd:\\pythion projLOVE' File "D:\pythion proj\import requests.py", line 14, in read_file with open(LOVE, 'rb') as _file: During handling of the above ex...
[ "The error is obvious, file does not exist. The LOVE path, d:\\\\pythion projLOV doesn't exist in your computer.\n" ]
[ 0 ]
[]
[]
[ "python", "speech_recognition" ]
stackoverflow_0074273929_python_speech_recognition.txt
Q: Python tk - hide console window I have prepared some tk application. It could be really simple like: from tkinter import * # create root window root = Tk() # root window title and dimension root.title("Welcome to GeekForGeeks") # Set geometry (widthxheight) root.geometry('350x200') # all widgets will be here...
Python tk - hide console window
I have prepared some tk application. It could be really simple like: from tkinter import * # create root window root = Tk() # root window title and dimension root.title("Welcome to GeekForGeeks") # Set geometry (widthxheight) root.geometry('350x200') # all widgets will be here # Execute Tkinter root.mainloop() I...
[ "All right, to solve above problem install:\npip install pywin32\n\nand add code before running your tk gui application:\nimport win32gui\nimport win32.lib.win32con as win32con\n\nthe_program_to_hide = win32gui.GetForegroundWindow()\nwin32gui.ShowWindow(the_program_to_hide , win32con.SW_HIDE)\n\nThen you can run th...
[ 0, 0, 0 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0074033555_python_tkinter.txt
Q: How to create a session using Fastapi so when a user login we can use it's id for multipurpose. I mean we can fetch id from session only I need to use one id in different api's using session in fast API. In simple word I have an API called "/api/cce/user/{id} & /api/cce/users/{id}/subscriptions/{cloud_id} so once ...
How to create a session using Fastapi so when a user login we can use it's id for multipurpose. I mean we can fetch id from session only
I need to use one id in different api's using session in fast API. In simple word I have an API called "/api/cce/user/{id} & /api/cce/users/{id}/subscriptions/{cloud_id} so once a user get's logged in I need to store that in one session so that I can use it i.e {id} for above api's.. in FastApi..
[ "API stops being API when you use sessions.\nYou can use JWT authentication in this case, not session.\nOtherwise you'd best build websocket architecture.\nSee official FastAPI docs https://fastapi.tiangolo.com/advanced/websockets/\n" ]
[ 0 ]
[]
[]
[ "fastapi", "python" ]
stackoverflow_0074260587_fastapi_python.txt
Q: Cover only directly called code from test function in pytest coverage I need to cover only code that is called directly from test function, every nested method call must be marked as missed. This must help me ensure that every unit/method has his own test. Example: test function calls method A and method A calls m...
Cover only directly called code from test function in pytest coverage
I need to cover only code that is called directly from test function, every nested method call must be marked as missed. This must help me ensure that every unit/method has his own test. Example: test function calls method A and method A calls method B inside. After that I want to have A method marked as covered and me...
[ "Coverage.py doesn't have a way to do this. There's discussion about marking which product functions are intended to be covered by each test as a possible future feature: https://github.com/nedbat/coveragepy/issues/696\n" ]
[ 0 ]
[]
[]
[ "coverage.py", "pytest", "pytest_cov", "python" ]
stackoverflow_0074262676_coverage.py_pytest_pytest_cov_python.txt
Q: Trying to iterate through arrays and annotate them I'm plotting graphs and I want to plot the values of the peaks which I've found using scipy. Now i have 2 numpy arrays that are the x values and y values of each peak. I want to go through these peaks and annotate all that are between the chosen x limits (xlim) as...
Trying to iterate through arrays and annotate them
I'm plotting graphs and I want to plot the values of the peaks which I've found using scipy. Now i have 2 numpy arrays that are the x values and y values of each peak. I want to go through these peaks and annotate all that are between the chosen x limits (xlim) as I plot both the full x and a zoom in of the peaks. I've...
[ "As said in comments, you are directly iterating over the values of x and y, so no need to index:\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nx = [1.5293, 2.9786, 8.6734, 11.944, 13.309, 13.337, 14.591]\ny = [3978.072, 1391.799, 1739.091, 218146.734, 29643.477, 29680.311, 965.577]\nxlim = [11.5, 12.5]\n...
[ 2 ]
[]
[]
[ "arrays", "matplotlib", "numpy", "python" ]
stackoverflow_0074273700_arrays_matplotlib_numpy_python.txt
Q: Geoseries is converted to pandas.Series unexpectedly I was practicing Intriduction of Geopandas's Getting Started. I followed the steps and found that the GeoSeries, created by .boundary, was converted to pandas.Series automatically when appending it to a GeoDataframe. The codes are listed: import geopandas as gd ...
Geoseries is converted to pandas.Series unexpectedly
I was practicing Intriduction of Geopandas's Getting Started. I followed the steps and found that the GeoSeries, created by .boundary, was converted to pandas.Series automatically when appending it to a GeoDataframe. The codes are listed: import geopandas as gd path_to_data = gd.datasets.get_path('nybb') gdf = gd.read...
[ "It is automatically converted to pandas dataframe unless you otherwise specify so.\nreference\n" ]
[ 1 ]
[]
[]
[ "geopandas", "pandas", "python" ]
stackoverflow_0069357958_geopandas_pandas_python.txt
Q: What are thread names used for in Python? I find that each thread has its own name such as Thread-1, Thread-2 and test_thread as shown below: thread1 = threading.Thread(target=test) thread2 = threading.Thread(target=test) thread3 = threading.Thread(target=test, name="test_thread") print(thread1.name) # "Thread-1"...
What are thread names used for in Python?
I find that each thread has its own name such as Thread-1, Thread-2 and test_thread as shown below: thread1 = threading.Thread(target=test) thread2 = threading.Thread(target=test) thread3 = threading.Thread(target=test, name="test_thread") print(thread1.name) # "Thread-1" print(thread2.name) # "Thread-2" print(thread3...
[ "As the documentation says:\n\nA string used for identification purposes only. It has no semantics. Multiple threads may be given the same name.\n\nOther libraries could have an use for a thread's name (and you can get it with threading.currentThread().name), even if the computer doesn't care.\nE.g. logging support...
[ 1 ]
[]
[]
[ "multithreading", "python", "python_3.x", "python_multithreading" ]
stackoverflow_0074274044_multithreading_python_python_3.x_python_multithreading.txt
Q: extracting data from the file read not working I have a midx file that has a format the same as an XML file. I am reading this file as: f = open('visus8.midx', 'r') regexCommand = re.compile("/\/(\S\w*)*.JPG/im") for line in f: matches = regexCommand.findall(str(line)) print(matches) The file has <dataset...
extracting data from the file read not working
I have a midx file that has a format the same as an XML file. I am reading this file as: f = open('visus8.midx', 'r') regexCommand = re.compile("/\/(\S\w*)*.JPG/im") for line in f: matches = regexCommand.findall(str(line)) print(matches) The file has <dataset url="/home/siddharth/Desktop/testing/VisusSlamFiles...
[ "You could use a capture group and make the pattern a bit more specific without using repeated groups at all:\n<dataset\\b[^<>]* filenames=\"(\\S+\\.JPG)\"\n\nRegex demo\nExample\nimport re\n\npattern = r'<dataset\\b[^<>]* filenames=\"(\\S+\\.JPG)\"'\ns = \"....\"\nprint(re.findall(pattern, s))\n\nOutput\n['/home/s...
[ 1, 1 ]
[]
[]
[ "parsing", "python", "regex" ]
stackoverflow_0074273550_parsing_python_regex.txt
Q: FileNotFoundError: [Errno 2] No such file or directory But I already have the file and directory I've created this project structure, I've written a py file under lines - Report - rep - common - config - Lines - static - templates as follows import yaml def read_conf(env='default'): dat...
FileNotFoundError: [Errno 2] No such file or directory But I already have the file and directory
I've created this project structure, I've written a py file under lines - Report - rep - common - config - Lines - static - templates as follows import yaml def read_conf(env='default'): data_list = {} # 存储配置 with open(r"../config/database.yaml", 'r', encoding='utf-8') as ymlfile: ...
[ "You might want try to change the relative path to absolute path.\nimport os\ndirname = os.path.dirname(__file__)\nfilename = os.path.join(dirname, 'relative/path/to/file/you/want')\n\nRelative paths in Python\n" ]
[ 0 ]
[]
[]
[ "path", "python" ]
stackoverflow_0074274077_path_python.txt
Q: How do i get the number of documents in an index in Marqo i would like to know if there is a way to get the number of documents i have added to an index in marqo, i have been adding docmunts to two different index but right now i don't know how many documents i have added to each. i tried doing this: import marqo ...
How do i get the number of documents in an index in Marqo
i would like to know if there is a way to get the number of documents i have added to an index in marqo, i have been adding docmunts to two different index but right now i don't know how many documents i have added to each. i tried doing this: import marqo mq = marqo.Client(url='http://localhost:8882') first_index = ...
[ "you can use the get_stats() method for that eg;\nfirst_index_stats = mq.index(\"first-index\").get_stats()\n\nsecond_index_stats = mq.index(\"second-index\").get_stats()\n\nprint(first_index_stats)\nprint(second_index_stats)\n\noutput;\n{'numberOfDocuments': the_number_of_documents_added}\n{'numberOfDocuments': th...
[ 0 ]
[]
[]
[ "marqo", "python" ]
stackoverflow_0074274054_marqo_python.txt
Q: creating new text with multiplier chars using functions I want to create new string based on string given by user, but every char in the string have to be multiplied by number also given by user. How to do it the correct way? def get_text(message: str) -> str: return input(f'{message}') def get_multiplier(num...
creating new text with multiplier chars using functions
I want to create new string based on string given by user, but every char in the string have to be multiplied by number also given by user. How to do it the correct way? def get_text(message: str) -> str: return input(f'{message}') def get_multiplier(number: str) -> int: return int(input(f'{number}:\n')) de...
[ "Using a list comprehension is one correct way to do it, it's concise and easy to understand:\ndef get_multiplied_text(message: str, number: str) -> list:\n return [c * number for c in message]\n\nIf you want to return a string:\ndef get_multiplied_text(message: str, number: str) -> str:\n return ''.join([c *...
[ 0 ]
[]
[]
[ "char", "function", "python" ]
stackoverflow_0074274110_char_function_python.txt
Q: Include column index name instead of suffix names when joining pd.DataFrame's with same columns Assume I have the following two pd.DataFrame's first = pd.DataFrame(data={'col': ['bla', 'blub'], 'a': [1, 2], 'b': [3, 4]}) second = pd.DataFrame(data={'col': ['bla', 'blub'], 'a': [5, 6], 'b': [7, 8]}) which creates ...
Include column index name instead of suffix names when joining pd.DataFrame's with same columns
Assume I have the following two pd.DataFrame's first = pd.DataFrame(data={'col': ['bla', 'blub'], 'a': [1, 2], 'b': [3, 4]}) second = pd.DataFrame(data={'col': ['bla', 'blub'], 'a': [5, 6], 'b': [7, 8]}) which creates these two # first col a b -------------- 0 bla 1 3 1 blub 2 4 # second col ...
[ "Let's do concat along axis=1 and use keys parameter to add additional column level\npd.concat([first.set_index('col'), second.set_index('col')], keys=('first', 'second'), axis=1)\n\nResult\n first second \n a b a b\ncol \nbla 1 3 5 7\nblub 2 4 6 8\n\n"...
[ 1 ]
[]
[]
[ "dataframe", "merge", "pandas", "python" ]
stackoverflow_0074273970_dataframe_merge_pandas_python.txt
Q: Bookeh failed to validate StaticLayoutProvider(id='5785', ...).graph_layout I am in a very wired situation. So, I am trying to visualize a graph using Bokeh. The graph has nodes as nodes IDs, which are connected by sticks that have length and also IDs. For example, I have the following DataFrame of sticks: import ...
Bookeh failed to validate StaticLayoutProvider(id='5785', ...).graph_layout
I am in a very wired situation. So, I am trying to visualize a graph using Bokeh. The graph has nodes as nodes IDs, which are connected by sticks that have length and also IDs. For example, I have the following DataFrame of sticks: import pandas as pd import networkx as nx d = {'Node 1': [56416, 56416], 'Node 2': [764...
[ "It's a speculation only since there is no reproducible code, but one potential source of the error is the float node IDs. This could happen because of a missing value somewhere in the data frame. A quick fix would be to run:\ndf = df.dropna().astype({'Node 1': 'int', 'Node 2': 'int'})\n# the rest of your code, sta...
[ 0 ]
[]
[]
[ "bokeh", "graph", "networkx", "python" ]
stackoverflow_0074273670_bokeh_graph_networkx_python.txt
Q: Error: TypeError: Voxel.__init__() got an unexpected keyword argument 'position' I am trying to make minecraft in ursina but whenever I run it, it says: TypeError: Voxel.__init__() got an unexpected keyword argument 'position' This is my code from ursina import * from ursina.prefabs.first_person_controller import...
Error: TypeError: Voxel.__init__() got an unexpected keyword argument 'position'
I am trying to make minecraft in ursina but whenever I run it, it says: TypeError: Voxel.__init__() got an unexpected keyword argument 'position' This is my code from ursina import * from ursina.prefabs.first_person_controller import FirstPersonController app = Ursina() player = FirstPersonController() Sky() block = ...
[ "There's a typo in Voxel's initializer declaration:\ndef __init__(self, positon = (0,0,0)):\n\nYou have positon (instead of position).\nCorrect that, and you should be fine:\ndef __init__(self, position=(0, 0, 0)):\n\n" ]
[ 1 ]
[]
[]
[ "python", "ursina" ]
stackoverflow_0074273623_python_ursina.txt
Q: How to plot pdf at the same graph as the histogram I wrote a function to plot a histogram of the following data(shortened) data_1 = [0.68417915 0.53041328 0.05499373 0.32483917 0.30501979 0.12136537 0.22964997 0.5837272 0.06000122 0.69908738 0.15690346 0.20363323 0.10390346 0.98658757 0.98359924 0.29493355 0.7...
How to plot pdf at the same graph as the histogram
I wrote a function to plot a histogram of the following data(shortened) data_1 = [0.68417915 0.53041328 0.05499373 0.32483917 0.30501979 0.12136537 0.22964997 0.5837272 0.06000122 0.69908738 0.15690346 0.20363323 0.10390346 0.98658757 0.98359924 0.29493355 0.72561782 0.75613625 0.69628136 0.71322217 0.63060554 0.9...
[ "There are several methods to estimate the pdf from the samples.\nOne way is to use kernel density estimation, which can be done easily with sns.kdeplot.\nAnother way is to fit parameters of a known distribution, e.g. with scikit-learn GaussianMixture if you have reasons to think your data is gaussian.\nimport matp...
[ 0 ]
[]
[]
[ "matplotlib", "python", "scipy", "statistics" ]
stackoverflow_0074273349_matplotlib_python_scipy_statistics.txt
Q: How to define a generic function to derive multiple new columns from a given column name? I have been trying to derive two columns from a given column name through a python function. Below is the code snippet: from pyspark.sql.functions import substring def deriveCol(source_col_name, col1, col2): df.select(s...
How to define a generic function to derive multiple new columns from a given column name?
I have been trying to derive two columns from a given column name through a python function. Below is the code snippet: from pyspark.sql.functions import substring def deriveCol(source_col_name, col1, col2): df.select(source_col_name, substring(source_col_name, 1, 4).alias(col1), substring(source_col_name, 5, 2)....
[ "As the first step I have created a true date column out of string. Having the date column we can apply methods year, month and quarter.\ndef derive_col(source_col_name, col1, col2, col3):\n date_col = F.to_date(source_col_name, 'yyyyMMdd')\n df = df.select(\n *[c for c in df.columns if c != source_col...
[ 2 ]
[]
[]
[ "apache_spark", "date", "multiple_columns", "pyspark", "python" ]
stackoverflow_0074273852_apache_spark_date_multiple_columns_pyspark_python.txt
Q: How to get my turtle program to restart based on user input I have been developing a fairly simple turtle program which essentially just draws snowflakes of a random size, shape, and colour. The amount is based on user input. What I would like to do with the program is add an input section at the end that asks the...
How to get my turtle program to restart based on user input
I have been developing a fairly simple turtle program which essentially just draws snowflakes of a random size, shape, and colour. The amount is based on user input. What I would like to do with the program is add an input section at the end that asks the user whether they would like to end the program or restart it. I...
[ "Solved! Thanks to the advice from the user https://stackoverflow.com/users/6243352/ggorlen\nThis is my complete code now that it works.\nimport time\nimport sys\nimport turtle\nimport random\nrestart = True\nwhile restart == True:\n n = int(input(\"How many snowflakes do you want?: \"))\n screen = turtle.Screen()\...
[ 0 ]
[]
[]
[ "python", "python_3.x", "python_turtle", "turtle_graphics" ]
stackoverflow_0073933358_python_python_3.x_python_turtle_turtle_graphics.txt