Python Questions
Ad
PyDev Interactive Console for Eclipse , import <modulename> throws ImportError
I have created a pythonproject in eclipse luna. i am trying to run python module via pydev interactive console, but a
Can't import package "No module named <modulename>"
I am currently using flask/blueprint to make my simple app more modular. my directories look like this: jobscraperapp/
Python Modules (modulename referenced before assignment)
I have a vm.py in the same directory as the main() script (getdata.py). in getdata.py, i
Is a Python dictionary an example of a hash table?
One of the basic data structures in python is the dictionary, which allows one to record "keys" for looking up "values" of any type. is this
Python CGI internal error login.html login.cgi
I'm currently trying to create a simple login in page to my actual local webpage that i'm running with on a virtual machine with ubuntu. i
django.template.exceptions.TemplateDoesNotExist: registration/login.html
Here's my files: views.py from django.shortcuts import render from django.urls import reverse_lazy
Django: Can I prevent logged in users from accessing login.html?
I have two general questions: as per the title, is there a way to make users who have an active session running that try to
Django - change site_header when using `admin/login.html` template as a normal login template
I am trying to use django's admin/login.html template as my login template for normal user. thing is it displays "django
django 1.9 and registration/login.html
I'm working on a django 1.9 project. with django 1.7.7, login functionnalities was working, but now all the time i have :
login.html cannot be rendered when using django authentication system
I am using django default authentication system to do the login and logout. however, when the login button is clicked, my template
Ad
Django doesn't seem to detect my login.html, block problem?
I'm creating a web app with django 1.2.4. i am using contrib.auth.views.login, i have followed every step but it seems i have forgotten
sklearn cross validation : The least populated class in y has only 1 members, which is less than n_splits=10
I'm working in a machine learning project and i'm stuck with this warning when i try to use cross validation to know how many neighbours do i need
`ValueError: The least populated class in y has only 1 member, which is too few` in PyCaret
I have a problem, working with pycaret. previously i did not have any problems. but it started when i oversampled data and saved it, using
Stratified Shuffle Split ValueError: The least populated class in y has only 1 member, which is too few
I'm struggling to get my stratified shuffle split to work. i have two sets of data, features and labels and i'm trying
StratifiedShuffleSplit: ValueError: The least populated class in y has only 1 member, which is too few.
I'm using the stratifiedshufflesplit cross validator for predicting the house prices in the boston dataset. when i run the below sample code.
Scikit-learn: "The least populated class in y has only 1 member"
I am trying to do a random forest regression using scikit-learn. the first step after loading the data using pandas is to split the data into a
XgBoost : The least populated class in y has only 1 members, which is too few
Im using xgboost implementation on sklearn for a kaggle's competition. however, im getting this 'warning' message : $ python script1.py
Search for host with MAC-address using Python
I'd like to search for a given mac address on my network, all from within a python script. i already have a map of all the active ip addresses in
What is causing my 'test.txt' file being sent from Python to my gmail account to come across as "Untitled" when I receive it in my email inbox?
I am sending a file called test.txt as an attachment below through the python program. it successfully sends but when i receive it in
get r"D:\test.txt" or "D:\\test.txt" from glob.glob("D\\*.txt")
I want to get r"d:\test.txt" or "d:\\test.txt" from glob.glob list. i tried as follows.
Errno 2 No such file or directory: '/storage/test.txt'
I am trying to create a bottle server that allows the user to save a file to the server (i know this has a big security hole, adding an auth
Ad
Have an error FileNotFoundError: [Errno 2] No such file or directory: 'test.txt'
F = open("test.txt") ^ filenotfounderror: [errno 2] no such file or directory: 'test.txt' i have that text
IOError: [Errno 22] invalid mode ('r') or filename: 'c:\\Python27\test.txt'
What is wrong with the following: test_file=open('c:\\python27\test.txt','r')
I'm getting "[errno 22] Invalid argument: 'test.txt\r'
I'm experimenting with a python program that will allow you to edit text files, i will use this feature later on in other programs, but i get the
name 'Child1' is not defined
I am very new to python programming i have a code thats shows the below error child_=child1() nameerror: name 'child1' is not
Finding a public facing IP address in Python?
How can i find the public facing ip for my net work in python?
Making a beta code for a public django site
I'm about to put a beta version of the site i'm working on up on the web. it needs to have a beta code to restrict access. the site is written in
What's the best Django search app?
I'm building a django project that needs search functionality, and until there's a django.contrib.search, i have to choose a search
Django customized user model.... where does user.model(...) come from?
So, i am working my way through the jungle of the django documentation in order to create an online classifieds app. since users are supposed to
File modification times not equal after calling shutil.copystat(file1, file2) under Windows
I run the following code with python 2.7.5. under windows: import os, shutil, stat, time with open('test.txt', 'w') as f: pass #
How to add empty lines between lines in text.txt document?
The purpose of the code is to add an empty line between lines in text.txt document and write some words in those empty lines. i tried looping
python open() gives me error while opening files having a space in naming(i.e. example text.txt)
When i use open() in python it says filenotfound, only when i try to open files with spacing in naming, (for e.g.
Ad
Aligning sentences in a text.txt file using open() function and str.join and split method
I am trying to modify (align sentences in a document) a text in a file using python. i tried the following approach with no success. i don't care
How to prevent writing into txt file the same words using open(text.txt,a)?
I have a question regarding appending to text file. i have written a script and what this script does is that it will read the url in json format
In django how to send json object using XMLHttpRequest in javascript
Please help me with how to send json object and receive it it views.py in django. my script: var obj={
How to check set of files conform to a naming scheme
I have a bunch of files (tv episodes, although that is fairly arbitrary) that i want to check match a specific naming/organisation scheme..
Proper way of cancelling accept and closing a Python processing/multiprocessing Listener connection
(i'm using the pyprocessing module in this example, but
Can I use chart modules with wxpython?
Is it possible to use any chart modules with wxpython? and are there any good ones out there? i'm thinking of the likes of pycha
how to parse a sitemap.xml file using scrapy's XmlFeedSpider?
I am trying to parse sitemap.xml files using scrapy, the sitemap files are like the following one with just much more
Static files in Flask - robot.txt, sitemap.xml (mod_wsgi)
Is there any clever solution to store static files in flask's application root directory. robots.txt and sitemap.xml are expected to be found in
imagefield(upload_to = 'myfolder') not save image in folder - 'myfolder' in django
Form html: <form action='/register/' method = 'post'>{% csrf_token %} ... <label>avatar:
python 2.7, using Counter on open('file.txt')
I got a good answer before for a similar problem but i didnt consider the scalability of the question that i asked. i had trouble with the text
Django - 'ContactForm' object has no attribute 'get'
I get the follow error no matter what way i do achieve my forms. this happens when i go to the url of my form. forms.py
Ad
How to resolve a NameError: global name 'ContactForm' is not defined
I create a contact form in flask, but it's not working. it gives the error nameerror: global name 'contactform' is not defined the custom
Get File Object used by a CSV Reader/Writer Object
Is there any way to access the file object used by a csv writer/reader object after it has been instantiated? i openned up the csv module, and it
Some internals of Django auth middleware
In the django.contrib.auth middleware i see the code: class authenticationmiddleware(object): def process_request(self,
Django Project structure, recommended structure to share an extended auth "User" model across apps?
I'm wondering what the common project/application structure is when the user model extended/sub-classed and this resulting user model is shared
Django - how to remove cached results from previous form posts?
I've got a django form which contains a dictionary of strings. i've given the form a submit button and a preview button. when the preview button
can cherrypy receive multipart/mixed POSTs out of the box?
We're receiving some post data of xml + arbitrary binary files (like images and audio) from a device that only gives us multipart/mixed
Adding Cookie to ZSI Posts
I've added cookie support to soappy by overriding httptransport. i need functionality beyond that of soappy, so i was planning on moving to zsi,
Best way to open a socket in Python
I want to open a tcp client socket in python. do i have to go through all the low-level bsd create-socket-handle / connect-socket stuff or is
How do I get the external IP of a socket in Python?
When i call socket.getsockname() on a socket object, it returns a tuple of my machine's internal ip and the port. however, i would
how to find exact match and 5 vocab before and after it in python
I have below dataframe in python, text = provide written informed consent healthy male or female age between 31 to 59 years fluent
Rearranging data from a table in python to correlate columns
I got a table that look like this: code year
Ad
Pandas interpolation function fails to interpolate after replacing values with .nan
I am working with the pandas function, and i am trying to interpolate a missing value after removing a value that isn't numeric. however, i am
How to achieve memory coalescing when iterating over non-square 2D arrays?
I'm struggling to figure out memory coalescence in cuda. in order evaluate the performance difference between coalesced and uncoalesced memory
Split number into groups by magnitude
Given an input 34567890 i want an output: [34, 567, 890] i can do it with some modulo math and floor
Split pandas dataframe into multiple dataframes with list of lists as mask
I have a pandas dataframe tat looks something like this a bb 1 foo.bar 2 foo.bar 3 foo.foo 4 foo.bar 5 foo.bar 6 foo.foo
How to reduce scale in python decimal value
I have a decimal value as decimal('3.10e-7'). how to convert it to decimal('3.1e-7)? i have some function (which
Is there a standard way to convert JSON to Dataframe? Or do different cases require different solutions?
I am trying to understand how to convert a url that consists of json, to a dataframe. i'm testing this sample code. import requests
Is it okay to use the method of a class as contextmanager?
So, here is a simple code: from contextlib import contextmanager class a: def
Create a descending list of instances of different values in a pandas dataframe
I need to filter through a pandas dataframe, and sort one of the columns, returning the number of instances of each value in descending order.
Python Merging files after a name fragment
I have two folders when i have dynamic quantity files. for example: in folder "a" i've files: filename_1.txt
Defining a list of values within a class
I know that this is a simple question, but i don't know what this is called and i can't find any details online... using python
Add missing rows for each Client - Python / Pandas
I have df with weeks, months and years. week = ['01/03/2022 - 01/09/2022', '01/10/2022 - 01/16/2022', '01/17/2022 - 01/23/2022',
Ad
Pandas data frame adding a column based on data from 2 other columns
I have a data frame. one column is called fractal. it has 0's or 1's in which the 1's represents a fractal. here is the output of
Python - How to sort date string in a Data Frame?
I have a df pandas.core.series.series such that: 0 11/8/16 1 11/8/16 2 6/12/16 3 10/11/15 4
How to delete every 0.2-th row in a pandas dataframe?
Df_o = pd.dataframe(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']) i would like to
pandas groupby with length of lists
I need display in dataframe columns both the user_id and length of content_id which is a list object. but struggling to do using groupby. please
Convert a numpy bool array to int
I have a numpy array (dtype bool) representing an array of bits. for example, the array np.array([true, false, false], dtype=bool)
Grouping columns, then deleting values based on null column values
I am reposting since my last question was poorly worded. i have a table that looks like the following:
How to delete from a dataframe by condition python
I have a dataframe in pandas with columns questions and answers | question | answer | | -------- | ------ | | www | 123 | |
How to detect which random did I chose from only one list with random.choice()?
How can i detect which random number has been chosen from the list? list = [3, 7, 5, 6, 3, 4, 1, 6] random = random.choice(list)
Replace characters with a space within a column while maintaining original value (In Pandas)
I have a dataset, where, in one column i would like to replace the '.' with a ' ' or space. note - the date is an object type
What is the error show underline in this Python code
I'm just a beginner in python. do you know why it's underline here?
Is there a better way to create index for headings and sub-headings of a document in python?
I have a list of headings and subheadings of a document. test_list = ['heading', 'heading','sub-heading', 'sub-heading', 'heading',
Ad
How can I handle only the first part of my value list of a dictionary in Python?
I have a dictionary which has a list of values and i want to use only the first value of each pair before the first comma. is that possible?
Counting symbols (pandas dataframe)
I am not able to spot the issue in the code below: class features_extract: def countdots(name): return
How can I use make_blobs with a dataframe?
I am new to machine learning and trying to do some exercises to figure some stuff out. i am reading a csv file into a dataframe as
Delete all dataframe rows that are associated with condition
Say i have this dataframe: df = {'id' : [1, 1, 1, 1, 1, 1, 1, 2, 2], 'x':[76.551, 79.529, 78.336,77, 76.02, 79.23, 77.733,
How to generate all possible combinations from list elements in Python having Pandas DataFrames in list?
Good afternoon! i have a list of lists in python. example: mylist = [['a', 'b', 'c'], [1, 2], [df1, df2]]
Storing the id attribute of all elements using CssSelector in a list using Selenium
The python selenium code i have here takes us to a page with some datasets i'm interested in scraping. here's my code. import time,
Why won't my conversion from str to list and then conversion to int work?
Lower = "abcdefghijklmnopqrstuvwxyz" upper = "abcdefghijklmnopqrstuvwxyz" nums =
from requests_html import ModuleNotFoundError: No module named 'requests_html'
[enter image description here][1] [1]: https://i.stack.imgur.com/pt031.png instagram.py license pipfile readme.md
Pandas dataframe column wise calculation
I have below dataframe columns: index(['location' 'dec-2021_x', 'jan-2022_x', 'feb-2022_x', 'mar-2022_x', 'apr-2022_x',
Unpack a list of dictionaries to an object in Python
I am not sure how to ask this as i'm not sure if i'm using the proper key words. i have a dictionaries in a variable x. i unpack (is
How to find frequency of every element row wise in a 2D matrix?
I am having a 2d-list as temp=[[0.5, 0.5, 2.0], [0.5, 0.5, -1.0, -1.0, -1.0], [0.5, 0.5, 2.0, -0.25], [-1.0, 2.0, -1.0, -1.0], [2.0, -1.0, -1.0,
Ad
Apply peicewise function for each element in a DataFrame
I have a pandas dataframe of the type: 1 2 3 4 1 2 5 6 ... i have a list of functions of the same length as one of
Webscrape a table with BeautifulSoup
I'm trying to get the tables (and then the tr and td contents) with requests and beautifulsoup from this link:
Classes in Python - when to use parentheses
Class example: def __init__(self, sides, name): self.sides = sides self.name = name why are the
Selenium Web Scraping lenght of a movie
I'm trying to get the lenght of a movie using webscraping but it doesn't work. i have the following code: lenght =
copying the elements of a list to another list with a condition in python
I have a list, say list_1 = [5,12,22,37,65,100], now i want to copy the elements of this list to another list say list_2
Image not printing to screen using 'Blit' Pygame
I am trying to make an undertale like game in python - however i have a problem. when i try to 'blit' an image to the screen it doesn't show. i am
Python program ends even if the condition are not met
The condition is that the program will end: -if the balance is less than or equal to zero. -if the balance is greather than or equal to 200.
File not found error on creating a new file and writing in it
I am trying to create a new file and write on it . but when i am doing something like this i am getting file not found error. seems i am missing
how to make a scatter plot on jupyter notebook python
I need to make a scatter plot and i am not sure how to do this.
Spotify API authorization code flow error: "grant_type parameter is missing" (Python)
I'm following the docs
Ad
Pandas read_csv: decimal and delimiter is the same character
Recently i'm struggling to read an csv file with pandas pd.read_csv. the problem is, that in the csv file a comma is used both as decimal point
Python Tkinter grid inside grid?
I am trying to create a 2d map, and each map cell has another 5x5 cell. i am able to generate the following 2d map:
Ad
Blog Categories
Ad