I would like create authentication in Django. I'm trying to do everything according to this. Unfortunately, at this moment I have two problems. Firstly, when I try to add from rest_framework.authtoken import views I have conflict with from companies
Let's say I have a list test = ["a","bb","ph","phi","phi_ph"] where a member of test can either contain the string ph, the string phi, a combination of these two, or none of them. How can I filter this lis
I'm running pyspark on an Amazon EMR cluster. I have a very simple test script to see if I can write data to s3 using spark-submit ... from pyspark import SparkContext sc = SparkContext() numbers = sc.parallelize(range(100)) numbers.saveAsTextFile("s
I have a nested list containing strings and integers that I'm trying to save into a txt file but I'm having trouble with formatting. array = [(string1, int1),(string2, int2),(string3, int3),...(string_n, int_n)] with open("output.txt", "w&q
I'm running a python script in pyspark and got the following error: NameError: name 'spark' is not defined I looked it up and found that the reason is that spark.dynamicAllocation.enabled is not allowed yet. According to Spark's documentation (https:
I'm reading a csv file to dataframe datafram = spark.read.csv(fileName, header=True) but the data type in datafram is String, I want to change data type to float. Is there any way to do this efficiently?If you want to do the casting when reading the
How do you check if a Django object is None in js? I currently have a variable person that stores a Django object or None. In my js I have: if ({{person}} != None) { execute_function({{person}}) } What seems to be the issue here?John Smiths answer ma
I'm trying to break the loop once Enter is pressed, while writing data to a file. This is what I have so far. I also don't want to limit the number of time the loop is run either... (example output is below) def main(): myfile = open('friends.txt','w
I want to push some values into array using Python. Maybe next time when i update the array ,it will insert some values exists ,so it will got some duplicate values. I want to know is there anyway to avoid duplicate values. Should I use db.collection
I'm using Django-Angular and trying to post a form and obtain data in back-end..I'm able to achieve this but found that the page is reloading while saving the form. How can we achieve the same without page render? forms.py def home(request): if 'appl
I'm new to programming, especially Python. If it helps I'm trying the Udacity free class located here: https://www.udacity.com/course/viewer#!/c-ud088/l-3621198668/m-3612388742 I'm at the 1:14 timestamp in that video. The differences are, that I have
I have the following code: data = open(filename).readlines() result = {} for d in data: res[d[0:11]] = d Each line in data looks like so and there are 251 with 2 different "keys" in the first 11 characters: 205583620002008TAVG 420 M 400 M 1140 M
This question already has an answer here: Get the cartesian product of a series of lists? 10 answers I have a problem like this. I have two lists, A and B, where A=[[1,2],[3,4],[5,6]] and B=[["a","b"],["c","d"]], I
I am testing the following code, I found that the output after the "print" is inconsistent with the text file. I have set the encoding to be "UTF-8". Is this a bug? How to fix? import requests url = "http://www.aastocks.com/tc/sto
I have this Unicode list list = [u'Hello\n', u'23456\n', u'45678\n',u'85963\n']. I want it to convert into the string list as below list1 = ['Hello','23456','45678','85963'] With minimal code.You can use str() and strip() in a list comprehension : >>
This is more of a request for explanation of how the csv module really understands data coming in from a file. I don't quite understand a quirk I've come across a few times tied specifically to new line characters. With the following code: with open(
I'm a bit lost on this one. I also tried to install an older version of cx_Oracle, which I have installed in a separate virtualenv, but it also fails at the same place with the same error message. $ pip install cx_Oracle (...) cx_Oracle.c:10:17: erro
Hi I have created a GUI using tkinter, it accepts entry from users. I have created my own presence checks and 'spelling' checks to ensure that the user only enters accepted values. But each time that I enter these values it makes the user click on th
This question already has an answer here: How to create a decorator function with arguments on python class? 1 answer So with the following... def makeBold(fn): def wrapped(): return '<b>'+fn()+'</b>' return wrapped @makeBold def produceElemen
Basically, I'm asking the user to input a string of text into the console, but the string is very long and includes many line breaks. How would I take the user's string and delete all line breaks to make it a single line of text. My method for acquir
I tried searching internet but could not find the meaning of hashable. When they say objects are hashable or hashable objects what does it mean?From the Python glossary: An object is hashable if it has a hash value which never changes during its life
I'm working on a little set of scripts in python, and I came to this: line = "a b c d e f g" a, b, c, d, e, f, g = line.split() I'm quite aware of the fact that these are decisions taken during implementation, but shouldn't (or does) python offe
So I have a biiiiig list of lists, looks like: big_list = [[17465, [22, 33, 1, 7, 83, 54, 84, -5], '123-432-3'], [13254, [42, 64, 4, -5, 75, -2, 1, 6], '1423-1762-4'], [.................................................................................
After running: sudo easy_install lxml I get the following error: src/lxml/lxml.etree.c:165527: fatal error: error writing to -: Broken pipe compilation terminated. This looks like a c-compiler problem. gcc --version yields 4.2.1. I don't really know
I have some elements in a list in one class. I want them sorted in a new list, and they have to be sorted by an attribute from another class. Can anyone give an example? My code so far looks like this: class Carcompany: def __init__(self, model, prod
I have a Django project, let's say "project1". Typical folder structure for applications is: /project1/ /app1/ /app2/ ... __init__.py manage.py settings.py urls.py What should I do if I want to hold all of my applications in some separate folder
I get this error when trying to take an integer and prepend "b" to it, converting it into a string: File "program.py", line 19, in getname name = "b" + num TypeError: Can't convert 'int' object to str implicitly That's relate
How can a standard-library module (say math) be accessed when a file prog.py is placed in the same directory as a local module with the same name (math.py)? I'm asking this question because I would like to create a package uncertainties that one can
I have some data. 224,000 rows of it, in a SQLite database. I want to extract time series information from it to feed a data visualisation tool. Essentially, each row in the db is an event that has (among other things not strictly relevant) a time-da
I want an algorithm to iterate over list slices. Slices size is set outside the function and can differ. In my mind it is something like: for list_of_x_items in fatherList: foo(list_of_x_items) Is there a way to properly define list_of_x_items or som