title
stringlengths
10
172
question_id
int64
469
40.1M
question_body
stringlengths
22
48.2k
question_score
int64
-44
5.52k
question_date
stringlengths
20
20
answer_id
int64
497
40.1M
answer_body
stringlengths
18
33.9k
answer_score
int64
-38
8.38k
answer_date
stringlengths
20
20
tags
list
Find route_table_id by subnet_id using boto3
37,933,608
<p>I'm trying to figure out how to find route_table_id based upon a subnet_id(in a vpc) using boto3. There is api in boto3(v1.3.1), ec2.RouteTableAssociation(id). With correct route_table_association_id, try to access the resource's attribute route_table_id, it gives exception as below:</p> <pre><code>In [19]: rta.rou...
0
2016-06-20T23:58:54Z
37,948,380
<p>Try <a href="http://boto3.readthedocs.io/en/latest/reference/services/ec2.html#EC2.Client.describe_route_tables" rel="nofollow">describe_route_tables</a>. </p> <p>All required info is under the responding JSON ['RouteTables'][*]["Associations"] </p>
0
2016-06-21T15:18:30Z
[ "python", "amazon-ec2", "boto3" ]
How to make QPushButton editable text when one click on it?
37,933,629
<p>Using Python 2.7 and PyQt4. So I need a way to make a text of the QPushButton editable when click on it, like on QTextEdit.</p>
1
2016-06-21T00:01:52Z
37,933,711
<p>There is no builtin way to edit a push button in the sense that you have a cursor and can type along.</p> <p>Probably the easiest solution is to bring up a QInputDialog. If that feels to heavy, you could also place a floating QLineEdit over or next to the QPushButton. Close that on <code>&lt;Enter&gt;</code> and se...
1
2016-06-21T00:10:48Z
[ "python", "pyqt4", "qtextedit", "qpushbutton" ]
pandas dataframe- replace row values
37,933,678
<p>I have a dataframe with four columns (see input dataframe below). I need to check if Meta column has pattern relation (example M_relation) then add number from relation column to the meta column value. How this can be done in pandas?</p> <p>Input dataframe:</p> <pre><code>-------------------------------------- ...
1
2016-06-21T00:07:14Z
37,933,791
<p>You could:</p> <pre><code>pattern = df.Meta.str.split('_').str.get(1) == 'relation' df.loc[pattern, 'Meta'] = df.loc[pattern, 'Meta'] + '_' + df.loc[pattern, 'Relation'].str.split('_').str.get(1) </code></pre> <p>to get:</p> <pre><code> Entry1 Relation Entry2 Meta 0 E11 R_31 E21 M_xx...
1
2016-06-21T00:20:27Z
[ "python", "pandas" ]
Parsing and creating a dict python
37,933,727
<p>I would like to create a dict by parsing a string</p> <pre><code>&lt;brns ret = "Herld" other = "very"&gt; &lt;brna name = "ame1"&gt; </code></pre> <p>I would like to create a dict that has the following key-value pairs:</p> <pre><code>dict = {'brnsret': 'Herld', 'brnsother':'very', 'brnaname':'a...
1
2016-06-21T00:12:43Z
37,933,795
<p>An alternative option and, probably, just for educational reasons - you can pass this kind of string into a lenient <em>HTML parser</em> like <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/" rel="nofollow"><code>BeautifulSoup</code></a>:</p> <pre><code>from bs4 import BeautifulSoup data = """ &lt;b...
2
2016-06-21T00:20:57Z
[ "python", "dictionary" ]
print text from while loop on a single line in python
37,933,767
<p>I made a decryption .py file for fun but while decrypting, the text is displayed vertically. My current code is:</p> <pre><code>while depthTracker &gt;= 0: depthTracker -= 1 multiplier = 32 ** depthTracker letter = userIn letter = letter // multiplier userIn -= letter * multiplier letterPri...
-1
2016-06-21T00:17:01Z
37,933,804
<p>If you leave a dangling comma at the end of your <strong>print</strong> command in <strong>letterPrint</strong>, the system routine will not start a new line. I can't comment on your actual code, since you failed to provide it. However, it might look something like this:</p> <pre><code>print letter, </code></pre>...
2
2016-06-21T00:22:13Z
[ "python" ]
print text from while loop on a single line in python
37,933,767
<p>I made a decryption .py file for fun but while decrypting, the text is displayed vertically. My current code is:</p> <pre><code>while depthTracker &gt;= 0: depthTracker -= 1 multiplier = 32 ** depthTracker letter = userIn letter = letter // multiplier userIn -= letter * multiplier letterPri...
-1
2016-06-21T00:17:01Z
37,933,807
<p>In letterPrint , where you are printing, do </p> <pre><code>print('whaterver you want to print',end = ' ') </code></pre>
3
2016-06-21T00:22:33Z
[ "python" ]
print text from while loop on a single line in python
37,933,767
<p>I made a decryption .py file for fun but while decrypting, the text is displayed vertically. My current code is:</p> <pre><code>while depthTracker &gt;= 0: depthTracker -= 1 multiplier = 32 ** depthTracker letter = userIn letter = letter // multiplier userIn -= letter * multiplier letterPri...
-1
2016-06-21T00:17:01Z
37,933,817
<p>What version of python?</p> <p>If it's 2.7 I think you can change the print statement in <code>letterPrint</code> to the following:</p> <pre><code>print str, </code></pre> <p>If it's 3.0 I think you can do this equivalently:</p> <pre><code>print(str, end=" ") </code></pre> <p>Is this the behaviour you want?</p>...
1
2016-06-21T00:23:59Z
[ "python" ]
How to use SyntaxNet parser/tagger with spaCy API?
37,933,803
<p>I have been using <a href="https://spacy.io/" rel="nofollow">spaCy</a> Python package to parse and tag text and using the resulting dependency tree and other attributes to derive meaning. Now I would like to use SyntaxNet's Parsey McParseface for parsing and dependency tagging (which seems better), but I would like ...
3
2016-06-21T00:22:03Z
38,059,346
<p>From <a href="https://spacy.io/blog/syntaxnet-in-context" rel="nofollow">the spaCy blog</a>:</p> <blockquote> <p>Obviously, we want to build a bridge between Parsey McParseface and spaCy, so that you can use the more accurate model with the sweeter spaCy API.</p> </blockquote> <p>However, it looks like there sti...
2
2016-06-27T16:56:20Z
[ "python", "nlp", "syntaxnet", "spacy" ]
Having a model to relate to several different models
37,933,857
<p>I have a simple notification model:</p> <pre><code>class Notification(models.Model): user = models.ForeignKey(User) sender = models.ForeignKey(User) model = '''What to put here?''' comment = models.CharField(max_length=200) created = models.DateTimeField(auto_now=False,auto_now_add=True) </code>...
1
2016-06-21T00:30:44Z
37,933,914
<p>Django need to know the model before creating a relation, you can store the model in char field like <code>post:23</code> <code>user_follow:41</code> and define a <code>get_model</code> method that will parse that field and return the right model object</p>
0
2016-06-21T00:39:12Z
[ "python", "django" ]
Having a model to relate to several different models
37,933,857
<p>I have a simple notification model:</p> <pre><code>class Notification(models.Model): user = models.ForeignKey(User) sender = models.ForeignKey(User) model = '''What to put here?''' comment = models.CharField(max_length=200) created = models.DateTimeField(auto_now=False,auto_now_add=True) </code>...
1
2016-06-21T00:30:44Z
37,934,078
<p>All depends on your design, you have several options. Different options depend on the size of your database:</p> <ul> <li>How many notifications are there?</li> <li>Do you need to update the notifications often?</li> <li>Or most of the notifications are inserted once and then read often?</li> </ul> <hr> <h3>Use ...
0
2016-06-21T01:05:05Z
[ "python", "django" ]
Having a model to relate to several different models
37,933,857
<p>I have a simple notification model:</p> <pre><code>class Notification(models.Model): user = models.ForeignKey(User) sender = models.ForeignKey(User) model = '''What to put here?''' comment = models.CharField(max_length=200) created = models.DateTimeField(auto_now=False,auto_now_add=True) </code>...
1
2016-06-21T00:30:44Z
37,934,332
<p>You could use <a href="https://docs.djangoproject.com/en/1.9/ref/contrib/contenttypes/" rel="nofollow">Content Types</a>/<a href="https://docs.djangoproject.com/en/1.9/ref/contrib/contenttypes/#generic-relations" rel="nofollow">Generic Relations</a></p> <pre><code>class Notification(models.Model): user = models...
1
2016-06-21T01:48:10Z
[ "python", "django" ]
I'm unable to print my list using the format I specified beforehand
37,933,889
<p>This is what I'm trying to do:</p> <pre><code>LAYOUT = "{!s:4} {!s:11} {!s:10} {!s:10} {!s:15} {!s:10} {!s:10} {!s:15} {!s:10} {!s:10}" Item_1 = [002,"Cucharas",12.3,12.5,"4/5/16",200,12.5,"4/6/16",150,140] print LAYOUT.format("UPC", "Item", "Cost", "Price", "F_Comp", "QTY", "Profit", "F_Venta", "QTY_Sold", "QTY...
0
2016-06-21T00:35:24Z
37,933,915
<p>Square brackets, <code>[]</code>, are generally used for indexing and slicing, which calls the object's <code>__getitem__</code> method, which the <code>str.format</code> function does not have. Use parentheses like you did in the previous line, and unpack the iterable with <code>*</code>:</p> <pre><code>print LAYO...
3
2016-06-21T00:39:24Z
[ "python" ]
Tensorflow GPU setup: error with CUDA on PyCharm
37,933,890
<p>I have TF 0.8 installed on Python3, MacOSX El Capitan.</p> <p>When running a simple test code for TF I get this message:</p> <pre><code>ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Library not loaded: @rpath/libcuda...
1
2016-06-21T00:35:29Z
37,951,582
<p>Could you try TF 0.9, which adds the MacOX GPU support?</p> <p><a href="https://github.com/tensorflow/tensorflow/blob/r0.9/RELEASE.md" rel="nofollow">https://github.com/tensorflow/tensorflow/blob/r0.9/RELEASE.md</a></p>
0
2016-06-21T18:08:24Z
[ "python", "ipython", "pycharm", "tensorflow" ]
Tensorflow GPU setup: error with CUDA on PyCharm
37,933,890
<p>I have TF 0.8 installed on Python3, MacOSX El Capitan.</p> <p>When running a simple test code for TF I get this message:</p> <pre><code>ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Library not loaded: @rpath/libcuda...
1
2016-06-21T00:35:29Z
37,997,801
<p>If you're getting this error, make sure you installed CUDA, cuDNN correctly as described in the Tensorflow install instructions. Note the TF, CUDA, cuDNN version you're installing and what Python version you're using.</p> <p>Filenames, paths etc frequently vary, so small tweaks in filenames and paths may be needed ...
2
2016-06-23T17:06:33Z
[ "python", "ipython", "pycharm", "tensorflow" ]
Tensorflow GPU setup: error with CUDA on PyCharm
37,933,890
<p>I have TF 0.8 installed on Python3, MacOSX El Capitan.</p> <p>When running a simple test code for TF I get this message:</p> <pre><code>ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Library not loaded: @rpath/libcuda...
1
2016-06-21T00:35:29Z
38,707,979
<p>I think the problem is in the SIP (System Integrity Protection). Restricted processes run with cleared environment variables and you got this error.</p> <p>You need to go to Recovery Mode, start Terminal and input </p> <pre><code>$ csrutil disable </code></pre> <p>, and reboot</p>
0
2016-08-01T20:56:45Z
[ "python", "ipython", "pycharm", "tensorflow" ]
python matrix string transpose without using numpy or zip/ map
37,933,901
<p>My current output is 3x1 matrix but I wish to have an output in horizontal matrix 1x3: <code>['apple', 'orange', 'grape']</code></p> <p>My python version is 3.5.1 and I fail to install numpy, I get an error if using <code>zip</code> or <code>map</code> to transpose as my variable is string not an integer.</p> <p>H...
-3
2016-06-21T00:37:49Z
37,934,119
<p>If you just want to print the list one item per line you can do something like this:</p> <pre><code>for item in mylist: print(item) </code></pre> <p>You can also look at the pretty print tools which will columnize and sort your list when it prints.</p> <pre><code>from pprint import pprint pprint(mylist) </cod...
0
2016-06-21T01:12:06Z
[ "python", "python-2.7", "python-3.x", "matrix", "transpose" ]
Unicode issues with tarfile.extractall() (Python 2.7)
37,933,910
<p>I'm using python 2.7.6 on Windows and I'm using the tarfile module to extract a file a gzip file. The <code>mode</code> option of <code>tarfile.open()</code> is set to <code>"r:gz"</code>. After the open call, if I were to print the contents of the archive via <code>tarfile.list()</code>, I see the following directo...
0
2016-06-21T00:38:57Z
37,956,020
<p>I learned that tar doesn't retain the encoding information as part of the archive and treats filenames as raw byte sequences. So, the output I saw from <code>tarfile.extractall()</code> was simply raw the character sequence that comprised the file's name prior to compression. In order to get the <code>extractall()</...
0
2016-06-21T23:09:17Z
[ "python", "windows", "python-2.7", "unicode", "tarfile" ]
Gracefully failing if value is not found in pandas dataframe
37,933,917
<p>What is a graceful way to fail when I want to access a value from a dataframe based on multiple conditions:</p> <pre><code>#Select from DataFrame using criteria from multiple columns newdf = df[(df['column_one']&gt;2004) &amp; (df['column_two']==9)] </code></pre> <p>If not value satisfying above condition exists, ...
0
2016-06-21T00:39:50Z
37,946,518
<p>If instead of dropping rows where the condition is not met, you want pandas to return a dataframe with rows of <code>NaN</code> where the condition is <code>False</code> and the original values otherwis, you can do the following.</p> <p>You can assign a list of <code>booleans</code> with length equal to the number ...
1
2016-06-21T13:58:02Z
[ "python", "pandas" ]
Kivy Grabbing Touch without Delay
37,933,920
<p>I was trying to implement touchtracer demo example into my code. <a href="https://kivy.org/docs/examples/gen__demo__touchtracer__main__py.html" rel="nofollow">Here is the original page</a></p> <p>I realized that the tracing does only work with a delay (after you press and hold the button) due to the necessary <em>t...
2
2016-06-21T00:39:57Z
38,022,079
<p>Ah, I got it now! So you want to draw on hover - without a need to press the button - like html/css <code>:hover</code>, right?</p> <p>There was a guy who made a behavior for that, but <a href="https://gist.github.com/opqopq/15c707dc4cffc2b6455f" rel="nofollow">that file</a>(+ <a href="https://gist.github.com/KeyWe...
0
2016-06-24T21:02:07Z
[ "python", "kivy" ]
Kivy Grabbing Touch without Delay
37,933,920
<p>I was trying to implement touchtracer demo example into my code. <a href="https://kivy.org/docs/examples/gen__demo__touchtracer__main__py.html" rel="nofollow">Here is the original page</a></p> <p>I realized that the tracing does only work with a delay (after you press and hold the button) due to the necessary <em>t...
2
2016-06-21T00:39:57Z
38,108,763
<p>Okay it looked like a version problem with one of the libraries. I used this in python2.7 built on Ubuntu 14.0 running on a virtualbox. I updated everything related to python and re-installed kivy with libraries and the problem is fixed. I am still not sure what caused it since I did not receive any error messages i...
1
2016-06-29T19:44:11Z
[ "python", "kivy" ]
Pandas: Can pandas groupby filter work on original object?
37,933,925
<p>Starting with this question as base.</p> <p><a href="http://stackoverflow.com/questions/13446480/python-pandas-remove-entries-based-on-the-number-of-occurrences">Python Pandas: remove entries based on the number of occurrences</a></p> <pre><code>data = pandas.DataFrame( {'pid' : [1,1,1,2,2,3,3,3], 'tag' :...
0
2016-06-21T00:40:12Z
37,934,086
<p>There is only so many ways you can solve this problem. My answer includes 4 solutions. I am sure, there are other ways. Maybe some other answers will present a better way. </p> <p><strong>Solution #1:</strong></p> <pre><code>data = data.groupby('tag').filter(lambda x: len(x) &gt; 1) pid tag 1 1 45 2 1 ...
1
2016-06-21T01:07:06Z
[ "python", "pandas", "filter", "group-by" ]
Pandas: Can pandas groupby filter work on original object?
37,933,925
<p>Starting with this question as base.</p> <p><a href="http://stackoverflow.com/questions/13446480/python-pandas-remove-entries-based-on-the-number-of-occurrences">Python Pandas: remove entries based on the number of occurrences</a></p> <pre><code>data = pandas.DataFrame( {'pid' : [1,1,1,2,2,3,3,3], 'tag' :...
0
2016-06-21T00:40:12Z
37,938,052
<p>A couple of options (yours is at the bottom):</p> <p>This first one is <code>inplace</code> and as quick as I could make it. Its a bit quicker than your solution but not by virtue of dropping rows in place. I can get even better performance with the second option and this does not change in place.</p> <pre><code...
1
2016-06-21T07:27:06Z
[ "python", "pandas", "filter", "group-by" ]
Why does collect() on a DataFrame with 1 row use 2000 exectors?
37,933,927
<p>This is the simplest DataFrame I could think of. I'm using PySpark 1.6.1.</p> <pre><code># one row of data rows = [ (1, 2) ] cols = [ "a", "b" ] df = sqlContext.createDataFrame(rows, cols) </code></pre> <p>So the data frame completely fits in memory, has no references to any files and looks quite trivial to me...
4
2016-06-21T00:40:32Z
37,940,715
<p>You can configure the number of executors. In many cases, spark will take as many executors as available, and execution time is a lot worse than when you limit to a small number of executors.</p> <pre><code>conf = SparkConf() conf.set('spark.dynamicAllocation.enabled','true') conf.set('spark.dynamicAllocation.maxEx...
0
2016-06-21T09:35:25Z
[ "python", "apache-spark", "pyspark", "yarn", "distributed" ]
Why does collect() on a DataFrame with 1 row use 2000 exectors?
37,933,927
<p>This is the simplest DataFrame I could think of. I'm using PySpark 1.6.1.</p> <pre><code># one row of data rows = [ (1, 2) ] cols = [ "a", "b" ] df = sqlContext.createDataFrame(rows, cols) </code></pre> <p>So the data frame completely fits in memory, has no references to any files and looks quite trivial to me...
4
2016-06-21T00:40:32Z
38,019,364
<p>So I looked into the code a bit to try to figure out what was going on. It seems that <code>sqlContext.createDataFrame</code> really does not make any kind of attempt to set reasonable parameter values based on the data.</p> <p><strong>Why 2000 tasks?</strong></p> <p>Spark uses 2000 tasks because my data frame had...
2
2016-06-24T17:50:43Z
[ "python", "apache-spark", "pyspark", "yarn", "distributed" ]
How can I respond to a prompt in os.system?
37,933,957
<p>I'm trying to do something like this:</p> <pre><code>from subprocess import Popen p = Popen(["vagrant", "ssh", "vmname", "-c", '"pvcreate -ff /dev/sdb"']) </code></pre> <p>But it requires user input. Also, that didn't work anyway. They give the error: <code>bash: pvcreate -ff /dev/sdb: command not found</code>, be...
1
2016-06-21T00:46:04Z
37,934,109
<p>I'd suggest using the list form of invocation.</p> <pre><code>import subprocess command = ["vagrant", "ssh", "vmname", "-c", "pvcreate -ff /db/sdb"] output,error = subprocess.Popen( command, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).c...
3
2016-06-21T01:11:02Z
[ "python", "ssh", "vagrant" ]
Inputting an array to python function by hand
37,934,038
<p>I want to input a two-dimensional array into a python function, by hand. </p> <p>For example:</p> <pre><code>x = numpy.zeroes(1,2) x[0,0] = 2 x[0,1] = 4 def f(x): return x**2 f(x) </code></pre> <p>This function returns an array with elements 4 and 16. However, I want to be able to input the two-dimensional el...
1
2016-06-21T00:59:09Z
37,934,339
<p>The reason why inputting <code>f(2, 4)</code> and <code>f([2, 4])</code> does not work because, for the former, the function only accepts one argument and, for the latter, you are passing in a Python list.</p> <p>Numpy arrays have more functionality. Python lists do not. You can see the difference when you look at ...
3
2016-06-21T01:49:43Z
[ "python", "arrays", "function", "numpy" ]
python data structure with multidimensional numpy arrays
37,934,055
<p>So I have some irregular, multi-dimensional data that I'd like to be able to index by the 'age' and 'Z' value.</p> <p>For each 'age', and 'Z' I have an array of 100 wavelengths and assoc'd fluxes (ex data):</p> <pre><code>age = np.array([10,20,30,40,50]) Z = np.array([7,8]) waveln = np.array([np.array([a f...
1
2016-06-21T01:01:36Z
37,934,457
<p>Do you realize the <code>waveln</code> is a 10x100 2d array, not an array of arrays? You could construct the same with</p> <pre><code>np.repeat(np.arange(100)[None,:],10,axis=0) </code></pre> <p>If you really want <code>waveln</code> to be a 1d array containing 10 arrays, you'll have to use an alternative object ...
2
2016-06-21T02:03:27Z
[ "python", "numpy", "multidimensional-array" ]
Threaded Python TCP Client Class continuously calls Receiver method and blocks Send method
37,934,061
<p>I hope the title is appropriate. If not please suggest an alternative. I am working with the following Python Client Class.</p> <pre><code>import Queue import socket import struct import threading import time class ClientCommand(object): CONNECT, SEND, RECEIVE, CLOSE = range(4) def __init__(self, type, da...
0
2016-06-21T01:02:32Z
38,389,264
<p>The error is</p> <pre><code> if msgid != "step1": NameError: name 'msgid' is not defined </code></pre> <p>Instead of</p> <pre><code> #TODO Add better error handling than a print print "Server down" </code></pre> <p>you had better written</p> <pre><code> raise </code></pre> <p>and spotted it immedi...
0
2016-07-15T06:30:12Z
[ "python", "multithreading", "sockets", "tcp" ]
Threaded Python TCP Client Class continuously calls Receiver method and blocks Send method
37,934,061
<p>I hope the title is appropriate. If not please suggest an alternative. I am working with the following Python Client Class.</p> <pre><code>import Queue import socket import struct import threading import time class ClientCommand(object): CONNECT, SEND, RECEIVE, CLOSE = range(4) def __init__(self, type, da...
0
2016-06-21T01:02:32Z
38,391,448
<blockquote> <p>However, as soon as I break out of the "Receive Handler", it automatically calls upon that function again.</p> </blockquote> <p>This is because you call <code>sct.cmd_q.put(ClientCommand(ClientCommand.RECEIVE))</code> within the <code>while True</code> loop that's run through for each single chunk ...
1
2016-07-15T08:30:41Z
[ "python", "multithreading", "sockets", "tcp" ]
Disallow safe mode on launch for Selenium in Python?
37,934,063
<p>I'm trying to launch into a website using a Selenium MWE:</p> <pre><code>from selenium import webdriver browser = webdriver.Firefox() browser.get('http://seleniumhq.org/') </code></pre> <p>However, it's not working. The process itself hangs until it times out.</p> <p>I think that the problem is that instead of j...
2
2016-06-21T01:02:42Z
37,934,205
<p>Firefox 47 and selenium 2.53 don't play nicely together - there are <em>compatibility issues</em>:</p> <ul> <li><a href="https://github.com/SeleniumHQ/selenium/issues/2110" rel="nofollow">https://github.com/SeleniumHQ/selenium/issues/2110</a></li> <li><a href="https://github.com/SeleniumHQ/selenium/issues/2257" rel...
2
2016-06-21T01:23:40Z
[ "python", "selenium", "firefox", "safe-mode" ]
Python 2.7.3 urllib2 Error
37,934,099
<p>When I try to run my python script this error happens. How can I solve this problem ?</p> <pre><code>['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'urllib2'] Traceback (most recent call last): File "m.py", line 3, in &lt;module&gt; import requests File "/usr/local/lib/python2.7/dist-pac...
2
2016-06-21T01:09:14Z
37,935,088
<p>you need to upgrade <a href="https://pypi.python.org/pypi/requests/" rel="nofollow">requests</a> </p> <pre><code>pip install --upgrade requests </code></pre>
1
2016-06-21T03:30:09Z
[ "python" ]
Use Python CGI to display file contents in <div>
37,934,126
<p>I am trying to display the contents of /etc/postfix/transport.in in a <code>&lt;div&gt;</code> via python &amp; cgi. When I run the script from the command line it works as I would expect, however, when called from the webpage it does not display the file contents. This is what I have in my CGI:</p> <pre><code>#!...
1
2016-06-21T01:13:05Z
37,934,486
<p>The "Data File" are different.</p> <p><em>Data File transport.in</em></p> <p><em>Data File /etc/postfix/transport.in</em></p> <p>Please paste the url when you called from the webpage.</p>
1
2016-06-21T02:07:26Z
[ "python", "html", "cgi" ]
Not able to login using request library in Python
37,934,155
<p>I am trying to open this <a href="https://www.handy.com/login" rel="nofollow">website</a>, and access the dashboard's information using <code>requests</code> library in python. This is kind of webscraping but the issue is I am not able to login. I tried bunch of different methods to post my login credentials but not...
1
2016-06-21T01:17:14Z
37,934,654
<p>First off, when authentication is required and a session must be maintained for further requests, the requests.session object is the intended way to do so.</p> <p>This involves creating a session object and using that to send your POST requests.</p> <p>session = requests.session() r = session.post(url, data=payloa...
1
2016-06-21T02:30:34Z
[ "python", "authentication", "python-requests", "basic-authentication" ]
Hierarchical axis labeling in matplotlib (Python)
37,934,242
<p>Suppose I'm looking at an n x n grid and on each axis I have labels of say, animals. But I'm also interested at looking at the relationship between groups, subgroups, etc. of the animals. So for example, I may have vertebrates and invertebrates, within vertebrates I may have mammals and reptiles and so forth. (If...
0
2016-06-21T01:32:17Z
37,950,630
<p>Unfortunately I can't figure out how to disable minor ticks:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt import matplotlib.ticker as ticker from mpl_toolkits.axes_grid.parasite_axes import SubplotHost fig1 = plt.figure() ax1 = SubplotHost(fig1, 111) fig1.add_subplot(ax1) # Some data x = np.a...
1
2016-06-21T17:13:29Z
[ "python", "matplotlib" ]
Change user agent used with robotparser in Python
37,934,316
<p>I am using the <code>robotparser</code> from the urlib module in Python to determine if can download webpages. One site I am accessing however returns a 403 error when the robot.txt file is accessed via the default user-agent, but correct response if e.g. downloaded via requests with my user-agent string. (The site ...
0
2016-06-21T01:45:45Z
37,935,740
<p>There is no option to fetch robots.txt with User-Agent using <code>RobotFileParser</code>, but you can fetch it yourself and path an array of strings to the <code>parse()</code> method :</p> <pre><code>from urllib.robotparser import RobotFileParser import urllib.request rp = RobotFileParser() with urllib.request...
1
2016-06-21T04:43:10Z
[ "python", "python-3.x", "web-scraping", "robots.txt" ]
Variable not being recognized as integer in Python?
37,934,389
<p>Here is my code: </p> <pre><code>print "How many frames do you want?" f = raw_input() print f frames = 'abcdefghijklmnopqrstuvwxyz' if f &gt; 0: frames = frames[:f] print frames </code></pre> <p>Then when I run it (my input was 2), I get this error where the variable f is not being recognized as an int, e...
-1
2016-06-21T01:55:38Z
37,934,429
<p>The <code>raw_input()</code> function returns a string regardless of what you type in.</p> <p>To turn that into an actual integer, you could use something like:</p> <pre><code>f = int(raw_input()) </code></pre> <p>However, be aware that is not going to go well unless you actually enter an integer. You should real...
0
2016-06-21T02:00:06Z
[ "python", "python-2.7", "variables", "int" ]
Variable not being recognized as integer in Python?
37,934,389
<p>Here is my code: </p> <pre><code>print "How many frames do you want?" f = raw_input() print f frames = 'abcdefghijklmnopqrstuvwxyz' if f &gt; 0: frames = frames[:f] print frames </code></pre> <p>Then when I run it (my input was 2), I get this error where the variable f is not being recognized as an int, e...
-1
2016-06-21T01:55:38Z
37,934,438
<p>You have to change <code>raw_input</code> to <code>input</code>.<code>raw_input</code> takes it as a string whereas <code>input</code> takes it as a integer. Here is the code: </p> <pre><code> print "How many frames do you want?" f = input() print f frames = 'abcdefghijklmnopqrstuvwxyz' if f &gt; ...
0
2016-06-21T02:00:45Z
[ "python", "python-2.7", "variables", "int" ]
Variable not being recognized as integer in Python?
37,934,389
<p>Here is my code: </p> <pre><code>print "How many frames do you want?" f = raw_input() print f frames = 'abcdefghijklmnopqrstuvwxyz' if f &gt; 0: frames = frames[:f] print frames </code></pre> <p>Then when I run it (my input was 2), I get this error where the variable f is not being recognized as an int, e...
-1
2016-06-21T01:55:38Z
37,934,440
<p>The problem here is that you did not convert the input into an integer. Therefore, Python does not recognize it as an integer.</p> <p><a href="https://docs.python.org/2/library/functions.html#raw_input" rel="nofollow"><code>raw_input()</code></a> will take an input from stdin and spit out a string. Python does not ...
0
2016-06-21T02:01:11Z
[ "python", "python-2.7", "variables", "int" ]
Identifying consecutive occurrences of a value
37,934,399
<p>I have a df like so:</p> <pre><code>Count 1 0 1 1 0 0 1 1 1 0 </code></pre> <p>and I want to return a <code>1</code> in a new column if there are two or more consecutive occurrences of <code>1</code> in <code>Count</code> and a <code>0</code> if there is not. So in the new column each row would get a <code>1</code...
9
2016-06-21T01:56:07Z
37,934,663
<p>Not sure if this is optimized, but you can give it a try:</p> <pre><code>from itertools import groupby import pandas as pd l = [] for k, g in groupby(df.Count): size = sum(1 for _ in g) if k == 1 and size &gt;= 2: l = l + [1]*size else: l = l + [0]*size df['new_Value'] = pd.Series(l) ...
1
2016-06-21T02:32:12Z
[ "python", "pandas", "dataframe", "itertools" ]
Identifying consecutive occurrences of a value
37,934,399
<p>I have a df like so:</p> <pre><code>Count 1 0 1 1 0 0 1 1 1 0 </code></pre> <p>and I want to return a <code>1</code> in a new column if there are two or more consecutive occurrences of <code>1</code> in <code>Count</code> and a <code>0</code> if there is not. So in the new column each row would get a <code>1</code...
9
2016-06-21T01:56:07Z
37,934,721
<p>You could:</p> <pre><code>df['consecutive'] = df.Count.groupby((df.Count != df.Count.shift()).cumsum()).transform('size') * df.Count </code></pre> <p>to get: </p> <pre><code> Count consecutive 0 1 1 1 0 0 2 1 2 3 1 2 4 0 0 5 0...
8
2016-06-21T02:39:32Z
[ "python", "pandas", "dataframe", "itertools" ]
trip_cost('Pittsburgh', 5) raised an error: unsupported operand type(s) for +: 'int' and 'NoneType'
37,934,460
<p>Here is my code, which said "trip_cost('Pittsburgh', 5) raised an error: unsupported operand type(s) for +: 'int' and 'NoneType'" when I ran it. Find the original question here: <a href="https://www.codecademy.com/courses/python-beginner-P5YtY/1/4?curriculum_id=4f89dab3d788890003000096" rel="nofollow">https://www.c...
1
2016-06-21T02:04:40Z
37,934,563
<blockquote> <pre><code>...+plane_ride_cost(days) </code></pre> </blockquote> <p>I think you mean <code>city</code> there. And write something so that the bottom can't fall out of the function again.</p>
1
2016-06-21T02:19:05Z
[ "python" ]
print term frequency list (have distribution)
37,934,476
<p>I have everything almost sorted, but because I want the top 2k unique words, I'm getting a super jumbled distribution. I'm eventually going to use this to build a dictionary, but I want to see which are the most common 2k words so I can choose the pertinent ones for the dictionary. Anyhow, see code below. How do I a...
1
2016-06-21T02:06:43Z
37,942,291
<p>You do get the counts of the various words when you use most_common(). Use items method to get a list of items in sorted order (most frequent first).</p> <pre><code>fdist = nltk.FreqDist(filtered_stories) #filtered_stories is already lowercase print(fdist) top_2k = [ ] top_2k = fdist.most_common(2000) tok_2k.ite...
1
2016-06-21T10:45:14Z
[ "python", "nltk" ]
Lambda function not working properly
37,934,491
<p>I am trying to write a lambda function to do the same program which I already implemented using a <code>while</code> loop, but I am not able to figure out how to correct my current program using the lambda function. As here, I want to multiply 4 with decreased value of <code>n</code>. For example, 3 should work li...
3
2016-06-21T02:07:53Z
37,934,613
<p><code>~</code> is a <a href="https://en.wikipedia.org/wiki/Unary_operation" rel="nofollow">unary</a> <a href="https://en.wikipedia.org/wiki/Bitwise_operation" rel="nofollow">bitwise</a> operator meaning <code>NOT</code>. <code>~x</code> is equivalent to <code>-x - 1</code>. Let's break this down:</p> <p>4*n**~-n...
4
2016-06-21T02:26:01Z
[ "python", "lambda" ]
Pip dosen't show the installed module - argparse
37,934,493
<p>I've already installed argparse successfully, but it doesn't show up on pip list.</p> <pre><code>C:\Python34&gt;pip install argparse Collecting argparse Downloading argparse-1.4.0-py2.py3-none-any.whl Installing collected packages: argparse Successfully installed argparse-1.4.0 C:\Python34&gt;pip install argpars...
0
2016-06-21T02:08:22Z
37,934,664
<p>Its Not importnat. You Can Check Your Library With <strong>show</strong>.</p> <pre><code>pip show argparse </code></pre> <p>Result:</p> <pre><code>C:\Users\ALiRezaCH&gt;pip show argparse --- Metadata-Version: 2.0 Name: argparse Version: 1.4.0 Summary: Python command-line parsing library Home-page: https://github....
0
2016-06-21T02:32:13Z
[ "python", "pip", "argparse" ]
Pip dosen't show the installed module - argparse
37,934,493
<p>I've already installed argparse successfully, but it doesn't show up on pip list.</p> <pre><code>C:\Python34&gt;pip install argparse Collecting argparse Downloading argparse-1.4.0-py2.py3-none-any.whl Installing collected packages: argparse Successfully installed argparse-1.4.0 C:\Python34&gt;pip install argpars...
0
2016-06-21T02:08:22Z
37,958,368
<p>Search tags for the package that is expecting <code>argparse</code>. I recall an earlier SO question about a specific package expecting a specific <code>argparse</code> version.</p> <p>In the standard version, <code>argparse.__version__</code> is <code>1.1</code>. That is, the version number hasn't changed since ...
0
2016-06-22T04:06:29Z
[ "python", "pip", "argparse" ]
how to change element in 2D array in python
37,934,507
<p>I intend to change the value of boolean array in 2D from True to false, but the code does not work. The output results are the same even I use statement b[r][c] = False. Could someone help me on this, thanks.</p> <pre><code>import numpy as np b = np.array([[True for j in range(5)] for i in range(5)]) print(b) for...
0
2016-06-21T02:11:08Z
37,934,541
<p>You need to use the indices of <code>b</code> to change elements, not the elements themselves. Try:</p> <pre><code>import numpy as np b = np.array([[True for j in range(5)] for i in range(5)]) print(b) for i, r in enumerate(b): for j, c in enumerate(r): b[i,j] = False print(b) </code></pre>
3
2016-06-21T02:16:37Z
[ "python" ]
how to change element in 2D array in python
37,934,507
<p>I intend to change the value of boolean array in 2D from True to false, but the code does not work. The output results are the same even I use statement b[r][c] = False. Could someone help me on this, thanks.</p> <pre><code>import numpy as np b = np.array([[True for j in range(5)] for i in range(5)]) print(b) for...
0
2016-06-21T02:11:08Z
37,934,571
<p>What you're looking for is this:</p> <pre><code>b[r, c] = False </code></pre> <p>numpy arrays work best using numpy's access methods. The other way would create a view of the array and you'd be altering the view.</p> <p>EDIT: also, r, c do need to be numbers, not True / True like the other answer said. I was read...
0
2016-06-21T02:20:18Z
[ "python" ]
how to change element in 2D array in python
37,934,507
<p>I intend to change the value of boolean array in 2D from True to false, but the code does not work. The output results are the same even I use statement b[r][c] = False. Could someone help me on this, thanks.</p> <pre><code>import numpy as np b = np.array([[True for j in range(5)] for i in range(5)]) print(b) for...
0
2016-06-21T02:11:08Z
37,934,649
<p>You could use broadcasting in Numpy. (works on all elements without the for loops.)</p> <pre><code>a =np.array([True]*25).reshape(5,5) b = a * False print(b) </code></pre> <p>True evaluates to 1 and False evaluates to 0 so 1*0 is ... 0</p>
1
2016-06-21T02:29:25Z
[ "python" ]
If anyone can take a look I would appreicate it
37,934,525
<p>This is my very first programing class and I'm having a hard time with this problem. I cant seem to get this to work I keep getting "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType" </p> <pre><code>def woodtype(wood): MAH=float(75.00) OAK=float(100) coffetab=float(0) if woodtype=="maho...
-8
2016-06-21T02:14:41Z
37,934,579
<p>Your function <code>woodtype</code> appears to be poorly indented, and has no return statement, so it returns <code>None</code>.</p> <p>by adding a return you should be able to solve the issues, e.g.</p> <pre><code>def woodtype(wood): MAH=float(75.00) OAK=float(100) coffetab=float(0) if wood=="mah...
0
2016-06-21T02:21:03Z
[ "python", "typeerror" ]
Django Basic Manager
37,934,630
<p>I'm using a <a href="https://github.com/commadelimited/beginners-guide-to-django-rest-framework" rel="nofollow">project</a> to learn about the Django Rest Framework but came across this odd code (to me).</p> <pre><code>class AuthorManager(models.Manager): pass class Author(models.Model): objects = AuthorM...
-1
2016-06-21T02:27:38Z
37,936,298
<p>From Django's documentation:</p> <blockquote> <p>A Manager is the interface through which database query operations are provided to Django models. At least one Manager exists for every model in a Django application.</p> </blockquote> <p>Here, the given model manager <strong>AuthorManager</strong> is not providin...
0
2016-06-21T05:32:53Z
[ "python", "django" ]
Subtract one row from another in Pandas DataFrame
37,934,647
<p>I am trying to subtract one row from another in a Pandas DataFrame. I have multiple descriptor columns preceding one numerical column, forcing me to set the index of the DataFrame on the two descriptor columns. </p> <p>When I do this I get a KeyError on whatever the first column name listed in the set_index() list ...
0
2016-06-21T02:29:21Z
37,934,764
<p>Not sure I understand you correctly:</p> <pre><code>df = pd.DataFrame({'COL_A': ['A', 'A'], 'COL_B': ['B', 'B'], 'COL_C': [4, 2]}) </code></pre> <p>gives:</p> <pre><code> COL_A COL_B COL_C 0 A B 4 1 A B 2 </code></pre> <p>then</p> <pre><code>df.s...
0
2016-06-21T02:45:13Z
[ "python", "pandas", "indexing", "dataframe", "loc" ]
Subtract one row from another in Pandas DataFrame
37,934,647
<p>I am trying to subtract one row from another in a Pandas DataFrame. I have multiple descriptor columns preceding one numerical column, forcing me to set the index of the DataFrame on the two descriptor columns. </p> <p>When I do this I get a KeyError on whatever the first column name listed in the set_index() list ...
0
2016-06-21T02:29:21Z
37,936,892
<p>Consider the sample dataframe given below:</p> <pre><code>In [44]: result Out[44]: monthyear Facility Date Yield Planned 0 Dec 15 CCM2 2015-12-01 2550.000000 0.0 1 Feb 16 CCM2 2016-02-01 4250.000000 0.0 2 Jan 16 CCM1 2016-01-01 1540.000000 0.0 3 Jan 16 ...
1
2016-06-21T06:19:47Z
[ "python", "pandas", "indexing", "dataframe", "loc" ]
how can i make code which is that input is a specific date and output is the day of the week?
37,934,709
<p>i want to use <strong>Class</strong> and <strong>try~except</strong> function to make codes. input is that i put <strong>integer (ex: 20160101)</strong> then it converts to <strong>datetime</strong>. And final output is <strong>the day of the week.</strong></p> <p>I think i can convert integer to date like this:</p...
-3
2016-06-21T02:37:55Z
37,934,830
<p>I didn't understand exactly what you are looking for, may be you want something like this</p> <pre><code>import datetime class Day: def __init__(self, date_str): self._date = datetime.datetime.strptime(date_str, '%Y%m%d') def dayOfWeek(self): return self._date.weekday() d = Day("20011222...
0
2016-06-21T02:54:57Z
[ "python", "class", "datetime", "try-except" ]
tensorflow DNN with two hidden layers significantly slower and produce much worse result than using scikit flow
37,934,796
<p>my bio dataset has 20K rows and 170 feature. I'm doing dnn regression to predict bioactivity. ( one unit output layer with linear equation and two hidden layers). It ran very slow on my cpu and produced really bad r-square (negative). Then I ran it with skflow with the same network architecture. It was way way fas...
1
2016-06-21T02:50:50Z
37,949,058
<p>There's a lot of parameters that are different between your <code>TensorFlowDNNRegressor</code> and vanilla tensorflow model including: </p> <p><code>hidden2 = 100</code></p> <p><code>learning_rate=0.01</code></p> <p><code>batch_size=1000</code>, the default <code>batch_size</code> for <code>TensorFlowDNNRegresso...
0
2016-06-21T15:49:25Z
[ "python", "tensorflow", "deep-learning", "skflow" ]
Why does Python's float raise ValueError for some very long inputs?
37,934,813
<p>On my Python 2.7.9 on x64 I see the following behavior:</p> <pre><code>&gt;&gt;&gt; float("10"*(2**28)) inf &gt;&gt;&gt; float("10"*(2**29)) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; ValueError: could not convert string to float: 1010101010101010101010101010101010101010101...
8
2016-06-21T02:52:04Z
37,935,060
<p><strong>Because the zeros are skipped when inferring the base</strong></p> <p><a href="https://hg.python.org/cpython/file/c6880edaf6f3/Objects/longobject.c" rel="nofollow">I like to look to my favourite reference implementation</a> for questions like this. </p> <hr> <p><strong>The Proof</strong></p> <p>Casevh ha...
4
2016-06-21T03:26:00Z
[ "python" ]
Why does Python's float raise ValueError for some very long inputs?
37,934,813
<p>On my Python 2.7.9 on x64 I see the following behavior:</p> <pre><code>&gt;&gt;&gt; float("10"*(2**28)) inf &gt;&gt;&gt; float("10"*(2**29)) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; ValueError: could not convert string to float: 1010101010101010101010101010101010101010101...
8
2016-06-21T02:52:04Z
37,935,066
<p>For the case of float("10"*(2**29)), you are converting the string to a float value which most probably exceeds the max value that a float can have in Python.</p> <p>Whereas, for the case of float("0"*(2**33)), you are converting the string to a float value of 0.0 regardless of how many times you multiply it by.</p...
2
2016-06-21T03:26:50Z
[ "python" ]
AttributeError: 'bool' object has no attribute 'items'
37,934,847
<p>I'm a beginner in python. I'm currently try to deal with use the IK to move the robot arm. When I try to run my program the arm was able to move to the my setted starting position but when it's going to next step it shows me this error:<code>AttributeError: 'bool' object has no attribute 'items'</code></p> <p>This ...
-1
2016-06-21T02:56:56Z
37,934,970
<p>You're trying to access the elements of a boolean value, which is not allowed. In your example, <code>positions</code> is a true/false value and not what you're expecting it to be. There's some section of the code where <code>positions</code> is being assigned to a boolean. You should walk through your code and l...
0
2016-06-21T03:14:12Z
[ "python", "attributeerror" ]
AttributeError: 'bool' object has no attribute 'items'
37,934,847
<p>I'm a beginner in python. I'm currently try to deal with use the IK to move the robot arm. When I try to run my program the arm was able to move to the my setted starting position but when it's going to next step it shows me this error:<code>AttributeError: 'bool' object has no attribute 'items'</code></p> <p>This ...
-1
2016-06-21T02:56:56Z
37,935,003
<p>The error tells you that booleans (either True or False) don't have an attribute "items".</p> <p>When you call</p> <p><code>self._limb.move_to_joint_positions(joint_angles)</code> you are passing the argument "joint_angles" which becomes "positions" in the function <code>move_to_joint_positions()</code>.</p> <p>L...
0
2016-06-21T03:19:12Z
[ "python", "attributeerror" ]
No events appear in Tensorboard (r0.8 and r0.9) on Mac OS X
37,934,874
<p>Script (just simple linear regression line fitting):</p> <pre><code>import tensorflow as tf import numpy as np ITERS = 25 N = 5000 MINI_BATCH_SIZE = 500 LEARNING_RATE = 0.001 # create dataset &amp; sampling X = np.random.randn(N) Y = 0.5 * X + 0.3 * np.random.random(N) def sample(X, Y...
2
2016-06-21T03:00:23Z
37,951,973
<p>Could it be related to this issue ? </p> <p><a href="https://github.com/tensorflow/tensorflow/issues/1421" rel="nofollow">https://github.com/tensorflow/tensorflow/issues/1421</a></p> <blockquote> <p>@llevar, what worked for me is copying the global.css file from this git repository to the location listed in th...
0
2016-06-21T18:28:33Z
[ "python", "tensorflow", "tensorboard" ]
Tensorflow Op Naming for Consecutive Runs in Interactive IPython terminal
37,934,955
<p>I've noticed that on subsequent runs of a Tensorflow script, your graph Ops get numbered names for example:</p> <pre><code>loss = tf.reduce_mean(tf.nn.l2_loss(y - pred), name="l2_loss") </code></pre> <p>would get the names:</p> <pre><code>l2_loss l2_loss_1 l2_loss_2 ... l2_loss_N </code></pre> <p>as you continue...
2
2016-06-21T03:12:31Z
37,935,900
<p>You might want to add <code>tf.reset_default_graph()</code> to the beginning of the script where you set up the graph. That deletes all existing tensors, variables and operations from the default graph. This way previous executions of the script will not interfere.</p> <p>I am not sure, though, if the error message...
3
2016-06-21T04:59:16Z
[ "python", "ipython", "tensorflow" ]
Tensorflow Op Naming for Consecutive Runs in Interactive IPython terminal
37,934,955
<p>I've noticed that on subsequent runs of a Tensorflow script, your graph Ops get numbered names for example:</p> <pre><code>loss = tf.reduce_mean(tf.nn.l2_loss(y - pred), name="l2_loss") </code></pre> <p>would get the names:</p> <pre><code>l2_loss l2_loss_1 l2_loss_2 ... l2_loss_N </code></pre> <p>as you continue...
2
2016-06-21T03:12:31Z
38,610,177
<p>To your follow-up question, you might be getting the <code>AssertionError</code> due to redefining your interactive session.</p> <pre><code>sess = InteractiveSession() sess = InteractiveSession() Exception AssertionError: AssertionError("Nesting violated for default stack of &lt;type 'weakref'&gt; objects") in ... ...
6
2016-07-27T10:19:28Z
[ "python", "ipython", "tensorflow" ]
Creating a Pandas dataframe from elements of a dictionary
37,934,969
<p>I'm trying to create a pandas dataframe from a dictionary. The dictionary is set up as</p> <pre><code>nvalues = {"y1": [1, 2, 3, 4], "y2": [5, 6, 7, 8], "y3": [a, b, c, d]} </code></pre> <p>I would like the dataframe to include only <code>"y1"</code> and "<code>y2"</code>. So far I can accomplish this using </p> ...
5
2016-06-21T03:14:10Z
37,934,996
<p>You could use a <code>dictionary comprehension</code> to filter out unwanted <code>keys</code> like so:</p> <pre><code>df = pd.DataFrame.from_dict({k: v for k, v in nvalues.items() if k != 'y3'}) </code></pre> <p>to get:</p> <pre><code> y1 y2 0 1 5 1 2 6 2 3 7 3 4 8 </code></pre> <p>There are ...
2
2016-06-21T03:18:15Z
[ "python", "dictionary", "pandas" ]
Creating a Pandas dataframe from elements of a dictionary
37,934,969
<p>I'm trying to create a pandas dataframe from a dictionary. The dictionary is set up as</p> <pre><code>nvalues = {"y1": [1, 2, 3, 4], "y2": [5, 6, 7, 8], "y3": [a, b, c, d]} </code></pre> <p>I would like the dataframe to include only <code>"y1"</code> and "<code>y2"</code>. So far I can accomplish this using </p> ...
5
2016-06-21T03:14:10Z
37,935,021
<p>You can specify <code>columns</code> in the <code>DataFrame</code> constructor:</p> <pre><code>pd.DataFrame(nvalues, columns=('y1', 'y2')) y1 y2 0 1 5 1 2 6 2 3 7 3 4 8 </code></pre>
4
2016-06-21T03:21:41Z
[ "python", "dictionary", "pandas" ]
what gets returned when you return self?
37,935,224
<p>what gets returned when you return 'self' inside a python class? where do we exactly use return 'self'? In the below example what does self exactly returns </p> <pre><code>class Fib: '''iterator that yields numbers in the Fibonacci sequence''' def __init__(self, max): self.max = max def __iter_...
0
2016-06-21T03:48:17Z
37,935,344
<p><a href="http://meta.stackexchange.com/questions/144452/is-it-okay-to-put-partial-answers">Partial Answer</a>:</p> <p>When you return <code>self</code>, you return the class instance. For example:</p> <pre><code>class Foo: def __init__(self, a): self.a = a def ret_self(self): return self </...
0
2016-06-21T04:00:42Z
[ "python", "python-3.x" ]
what gets returned when you return self?
37,935,224
<p>what gets returned when you return 'self' inside a python class? where do we exactly use return 'self'? In the below example what does self exactly returns </p> <pre><code>class Fib: '''iterator that yields numbers in the Fibonacci sequence''' def __init__(self, max): self.max = max def __iter_...
0
2016-06-21T03:48:17Z
37,935,500
<p>The keyword <code>self</code> is used to refer to the instance that you are calling the method from.</p> <p>This is particularly useful for <a href="https://en.wikipedia.org/wiki/Method_chaining#Python" rel="nofollow">chaining</a>. In your example, let's say we want to call <code>__next__()</code> on an initialized...
1
2016-06-21T04:16:14Z
[ "python", "python-3.x" ]
what gets returned when you return self?
37,935,224
<p>what gets returned when you return 'self' inside a python class? where do we exactly use return 'self'? In the below example what does self exactly returns </p> <pre><code>class Fib: '''iterator that yields numbers in the Fibonacci sequence''' def __init__(self, max): self.max = max def __iter_...
0
2016-06-21T03:48:17Z
37,936,174
<p>Python treats method calls like <code>object.method()</code> approximately like <code>method(object)</code>. <a href="https://docs.python.org/3/tutorial/classes.html#method-objects" rel="nofollow">The docs</a> say that "call <code>x.f()</code> is exactly equivalent to <code>MyClass.f(x)</code>". This means that a me...
1
2016-06-21T05:22:05Z
[ "python", "python-3.x" ]
Cannot get right slice bound for non-unique label when indexing data frame with python-pandas
37,935,294
<p>I have such a data frame <code>df</code>:</p> <pre><code>a b 10 2 3 1 0 0 0 4 .... # about 50,000+ rows </code></pre> <p>I wish to choose the <code>df[:5, 'a']</code>. But When I call <code>df.loc[:5, 'a']</code>, I got an error: <code>KeyError: 'Cannot get right slice bound ...
0
2016-06-21T03:55:58Z
37,935,451
<p>The error message is explained <a href="http://pandas.pydata.org/pandas-docs/stable/gotchas.html#non-monotonic-indexes-require-exact-matches" rel="nofollow">here</a>: <code>if the index is not monotonic, then both slice bounds must be unique members of the index</code>.</p> <p>The difference between <code>.loc</cod...
1
2016-06-21T04:11:18Z
[ "python", "pandas", "dataframe" ]
How to download a file from webpage by python request module?
37,935,317
<p>I can directly download a file that is around 50 megabytes, but when I use python request to do so, it does not work. It returns: </p> <pre><code> r = sss.get(url, stream=True, headers=my_headers) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/Library/Frameworks/Pytho...
0
2016-06-21T03:58:21Z
37,935,664
<p>Try using <em>http://</em> instead of <em>https://</em> for your url?</p> <p>Check out the solution to this question. Might be the solution to the error that you're facing.</p> <p><a href="http://stackoverflow.com/questions/28557466/python-requests-exception-connectionerror-connection-aborted-badstatusline">Python...
0
2016-06-21T04:34:58Z
[ "python", "download", "request" ]
What is the fastest way to bulk load a large CSV file into MSSQL using Python?
37,935,377
<p>What is the fastest way to import data into MSSQL using Python with these requirements:</p> <ol> <li>Large file (too big for memory, no row based inserts).</li> <li>Minimal logging.</li> <li>CSV file.</li> <li>CSV file column may contain single and double quotes.</li> <li>CSV file Column may contain line breaks.</l...
0
2016-06-21T04:03:42Z
37,935,581
<p>Call <a href="https://msdn.microsoft.com/en-IN/library/ms162802.aspx" rel="nofollow">BCP</a> in windows or <a href="http://linux.die.net/man/1/freebcp" rel="nofollow">freebcp</a> for Linux from python code .</p>
0
2016-06-21T04:25:03Z
[ "python", "sql-server", "csv" ]
How to display the valueof a newly created custom model field in Django?
37,935,670
<p>I have created a custom model in models.py</p> <pre><code>class UserProfile(models.Model): #required by the auth model user = models.OneToOneField(User, on_delete=models.CASCADE) NativeLanguage = models.CharField(max_length=100) LearningLanguage = models.CharField(max_length=100) </code></pre> <p>And also created ...
0
2016-06-21T04:35:42Z
37,935,883
<p>First of all html page renders from view.py you have to send value of Native language from view to html page in views native language is retrieved from models ..</p> <p>In views.py ::</p> <pre><code>from .models import (model class name) data = model class name.objects.all().values('NativeLanguage') return rende...
0
2016-06-21T04:57:25Z
[ "python", "django", "user" ]
How to display the valueof a newly created custom model field in Django?
37,935,670
<p>I have created a custom model in models.py</p> <pre><code>class UserProfile(models.Model): #required by the auth model user = models.OneToOneField(User, on_delete=models.CASCADE) NativeLanguage = models.CharField(max_length=100) LearningLanguage = models.CharField(max_length=100) </code></pre> <p>And also created ...
0
2016-06-21T04:35:42Z
37,952,697
<p>First of all, model field names should be lowercase underscore separated:</p> <pre><code>class UserProfile(models.Model): ... user = models.OneToOneField(User, related_name='profile') native_language = models.CharField(max_length=100) </code></pre> <p>Later anywhere in the template or a view:</p> <pr...
0
2016-06-21T19:09:12Z
[ "python", "django", "user" ]
IndentationError: expected an indented block in python error generate at variable scan time
37,935,716
<p>here is my code actually i want to just use the infinite while loop to scan some int value and perform a compare if to find out the guass number is correct or not but it doesn't work give me the error about "<strong>indentationError: expected an indented block"</strong></p> <pre><code>running = True while running...
0
2016-06-21T04:40:56Z
37,935,930
<p>Many languages use braces to to encapsulate branches of conditional expressions, functions, classes, etc. Python uses whitespace to do this instead. Here is the correct formatting for your code:</p> <pre><code>running = True while running: guess = int(input('Enter an integer : ')) if guess == number: ...
0
2016-06-21T05:02:19Z
[ "python" ]
Extract first characters from list series pandas
37,935,729
<p>I have a string series containing multiples words. I want to extract the first character of each word per row in a vectorized fashion. </p> <p>So far, I have been able to split the words into a list, but haven't found a vectorized way of getting the first characters. </p> <pre><code>s = pd.Series(['aa bb cc', 'cc ...
1
2016-06-21T04:42:22Z
37,935,865
<p>You can try this :</p> <pre><code>&gt;&gt;&gt; s2 = s.str.split() &gt;&gt;&gt; s2.apply(lambda lst: [list(elt)[0] for elt in lst]) 0 [a, b, c] 1 [c, d, e] 2 [f, g] 3 [0] </code></pre> <p>Hope it'll be helpful.</p>
0
2016-06-21T04:55:19Z
[ "python", "string", "pandas", "dataframe", "character" ]
Extract first characters from list series pandas
37,935,729
<p>I have a string series containing multiples words. I want to extract the first character of each word per row in a vectorized fashion. </p> <p>So far, I have been able to split the words into a list, but haven't found a vectorized way of getting the first characters. </p> <pre><code>s = pd.Series(['aa bb cc', 'cc ...
1
2016-06-21T04:42:22Z
37,935,910
<p>A straightforward way would be to use the <code>pandas.Series.map</code> method:</p> <pre><code>In [15]: s.str.split().map(lambda lst : [string[0] for string in lst]) Out[15]: 0 [a, b, c] 1 [c, d, e] 2 [f, g] 3 [0] dtype: object </code></pre>
1
2016-06-21T05:00:17Z
[ "python", "string", "pandas", "dataframe", "character" ]
Extract first characters from list series pandas
37,935,729
<p>I have a string series containing multiples words. I want to extract the first character of each word per row in a vectorized fashion. </p> <p>So far, I have been able to split the words into a list, but haven't found a vectorized way of getting the first characters. </p> <pre><code>s = pd.Series(['aa bb cc', 'cc ...
1
2016-06-21T04:42:22Z
37,936,260
<p>Another faster solution is nested list comprehension:</p> <pre><code>s2 = pd.Series([[y[0] for y in x.split()] for x in s.tolist()]) print (s2) 0 [a, b, c] 1 [c, d, e] 2 [f, g] 3 [0] dtype: object </code></pre> <p>Thank you <a href="http://stackoverflow.com/questions/37935729/extract-first-cha...
2
2016-06-21T05:29:41Z
[ "python", "string", "pandas", "dataframe", "character" ]
Robot Framework class inheritance
37,935,838
<p>I have a parent class like below. </p> <pre><code>class ABC (object): def __init__: //Do something def __del__(): //Cleanup what you did </code></pre> <p>Test Suites are sub classes of ABC. </p> <pre><code>Class A(ABC): def __init__(): Class B(ABC): def __init__(): </code></pre> <p>Ho...
0
2016-06-21T04:52:43Z
37,939,554
<p>I'm not sure I understand what you want to do, it looks like you want to override things more than use a singleton.</p> <p>If you instanciate 2 objects you'll initiate 2 parents.</p> <pre><code>a = A() # ABC 1 b = B() # ABC 2 </code></pre> <p>But maybe what you want is something like this:</p> <pre><code>abc = A...
0
2016-06-21T08:43:55Z
[ "python", "robotframework" ]
Robot Framework class inheritance
37,935,838
<p>I have a parent class like below. </p> <pre><code>class ABC (object): def __init__: //Do something def __del__(): //Cleanup what you did </code></pre> <p>Test Suites are sub classes of ABC. </p> <pre><code>Class A(ABC): def __init__(): Class B(ABC): def __init__(): </code></pre> <p>Ho...
0
2016-06-21T04:52:43Z
37,943,508
<p>As written you question doesn't make much sense,since you can't write test suites in python. I'm going to guess you are asking about keyword libraries.</p> <p>If you want a keyword library to be instantiated once when a suite gets executed, and destroyed after all the tests have run, you need to set the library sco...
0
2016-06-21T11:44:49Z
[ "python", "robotframework" ]
quantile normalization on pandas dataframe
37,935,920
<p>Simply speaking, how to apply quantile normalization on a large Pandas dataframe (probably 2,000,000 rows) in Python?</p> <p>PS. I know that there is a package named rpy2 which could run R in subprocess, using quantile normalize in R. But the truth is that R cannot compute the correct result when I use the data...
3
2016-06-21T05:01:33Z
37,957,466
<p>Ok I implemented the method myself of relatively high efficiency.</p> <p>After finishing, this logic seems kind of easy but, anyway, I decided to post it here for any one feels confused like I was when I couldn't googled the available code.</p> <p>The code is in github: <a href="https://github.com/ShawnLYU/Quantil...
0
2016-06-22T02:16:57Z
[ "python", "deep-learning", "data-science" ]
How can I run a numpy function percentile() on a masked array?
37,935,954
<p>I try to retrieve percentiles from an array with NoData values. In my case the Nodata values are represented by -3.40282347e+38. I thought a masked array would exclude this values from further calculations. I succesfully create the masked array but for the np.percentile() function the mask has no effect.</p> <pre><...
0
2016-06-21T05:03:49Z
37,936,546
<p>Looking at the <code>np.percentile</code> code it is clear it does nothing special with masked arrays.</p> <pre><code>def percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=False): q = array(q, dtype=np.float64, copy=True) r, k = _ureduce(a, func=_pe...
1
2016-06-21T05:54:55Z
[ "python", "arrays", "numpy" ]
How to read a set of text files in to a single list in python
37,936,019
<p>I have a set of text files and i am trying to read it into a single list.but when i execute my code</p> <pre><code>def get_documents(): path1 = "D:/set/" texts=[] listing1 = os.listdir(path1) for file in listing1: with open(path1+file,'r') as f: lines = f.read().splitlines() texts.append(lines) ...
1
2016-06-21T05:09:33Z
37,936,044
<p>I believe instead of this:</p> <pre><code>texts.append(lines) </code></pre> <p>Do this:</p> <pre><code>texts.extend(lines) </code></pre>
5
2016-06-21T05:11:19Z
[ "python" ]
How to read a set of text files in to a single list in python
37,936,019
<p>I have a set of text files and i am trying to read it into a single list.but when i execute my code</p> <pre><code>def get_documents(): path1 = "D:/set/" texts=[] listing1 = os.listdir(path1) for file in listing1: with open(path1+file,'r') as f: lines = f.read().splitlines() texts.append(lines) ...
1
2016-06-21T05:09:33Z
37,936,243
<p>as you might have guessed, splitlines() returns a list, so when you put the result into another list (in your case, texts), you will have a list containing some lists. so a way to reach your desired result is to use:</p> <pre><code>new_list = [item for sub_list in texts for item in sub_list] </code></pre> <p>new_l...
0
2016-06-21T05:28:19Z
[ "python" ]
How to read a set of text files in to a single list in python
37,936,019
<p>I have a set of text files and i am trying to read it into a single list.but when i execute my code</p> <pre><code>def get_documents(): path1 = "D:/set/" texts=[] listing1 = os.listdir(path1) for file in listing1: with open(path1+file,'r') as f: lines = f.read().splitlines() texts.append(lines) ...
1
2016-06-21T05:09:33Z
37,936,573
<p>You can simply use <code>+=</code> to achieve that.</p> <pre><code>texts += lines </code></pre>
1
2016-06-21T05:56:28Z
[ "python" ]
How can use CFFI to call an existing C function given the source code?
37,936,045
<p>I have a C source/header file that are part of a bigger project. I would like to test this as a unit, independent of the real project. While it would be possible to do this in C by creating a new project with a different <code>main()</code>, I would like to see if I can use Python (3) and its frameworks (eg. nose) t...
5
2016-06-21T05:11:23Z
37,939,132
<p>For a project of mine, I use <code>cffi</code> to test my C code. IMHO <code>cffi</code> is a great tool to generate python bindings for C code and therefore think that it is a reasonable tool to use for calling and testing C functions from python. However, your code will only be as cross platform as the C code is, ...
1
2016-06-21T08:22:36Z
[ "python", "c", "unit-testing", "python-cffi" ]
convert 12 hour time format to 24 hours format from python
37,936,080
<p>from my python code, I got the resulted list like below.</p> <pre><code>list1 = [{'start': 'Mon12', 'end': '3:30'}, {'start': '7', 'end': '10:30'}] </code></pre> <p>Here, i need to convert the above list1 to 24 hrs date format like below.</p> <pre><code>list2 = [{'start': 12, 'end': 1530}, {'start': 1900, 'end': ...
0
2016-06-21T05:14:27Z
37,940,939
<p>Firstly you should probably distinguish between am/pm as mentioned in the comments above.</p> <p>However if you knew all these times were pm, suggested by your output list above, then you could iterate through each value stripping unwanted characters and add 1200, as shown below:</p> <pre><code>list1 = [{'start' :...
0
2016-06-21T09:45:25Z
[ "python" ]
Unable to print pass or fail message in output log using character map formatting
37,936,117
<p>I need to print pass or fail message in output log. For example </p> <pre><code>FFFFFFFF AAAAAAAA IIIIIIII LL FF AA AA II LL FF AA AA II LL FFFFFFFF AAAAAAAA II LL FF AA AA II LL FF AA AA ...
-2
2016-06-21T05:17:40Z
37,938,965
<p>Simple logic is:</p> <pre><code>def print_fail(): print "FFFFFFFF AAAAAAAA IIIIIIII LL" print "FF AA AA II LL" print "FF AA AA II LL" print "FFFFFFFF AAAAAAAA II LL" print "FF AA AA II LL" print "FF AA ...
0
2016-06-21T08:13:38Z
[ "python" ]
Google Bigquery API: How to get the name of temporary table
37,936,135
<p>I know that: The result of query will save in a temporary table. But how to get its name to use in other query.</p> <pre><code>from googleapiclient.discovery import build from googleapiclient.errors import HttpError from oauth2client.client import GoogleCredentials def test(): project_id = "598330041668" c...
1
2016-06-21T05:18:53Z
37,980,563
<ol> <li>Find the job ID of the query you ran. This is present in the response from <code>jobs.query</code> in the <a href="https://cloud.google.com/bigquery/docs/reference/v2/jobs/query#jobReference" rel="nofollow"><code>jobReference</code></a> field.</li> <li>Look up the query configuration for the job you ran using...
2
2016-06-23T00:53:58Z
[ "python", "google-bigquery", "temp-tables" ]
Ember-simple-auth-token / Flask error: AttributeError: 'function' object has no attribute 'get'
37,936,239
<p>I'm trying to run an Ember project that I had to upgrade it's packages, but now I run into deprecation issues.</p> <p>My current issue is that when I press 'login' I see the following error Client side:</p> <pre><code>http://127.0.0.1:8000/api/token-auth/ [HTTP/1.0 500 INTERNAL SERVER ERROR 48ms] </code></pre> <p...
-2
2016-06-21T05:27:59Z
38,028,888
<p>I had to add/edit the following:</p> <p>./config/environment.js</p> <pre><code> ENV['ember-simple-auth'] = { authorizer: 'authorizer:token', crossOriginWhitelist: [ENV.APP.krakenHost] }; ENV['ember-simple-auth-token'] = { serverTokenEndpoint: ENV.APP.krakenHost+'/api/token', serverTokenRefre...
0
2016-06-25T13:12:36Z
[ "javascript", "python", "ember.js", "flask", "ember-simple-auth" ]
Updating values in a dict on Python inside a Tkinter button
37,936,427
<p>I'm attempting to write some code for a game using Python and seem not to be able to get my variables out of the button click command into the dictionary variables for later use. What I'm trying to do is run the jingle_add() on a button click, have it run some calculations, update the displays and return the tree va...
1
2016-06-21T05:43:39Z
37,936,825
<p>Please mention from where are you getting variable 'cost'. And try to print something check if its going inside the first loop:</p> <pre><code>if fans &gt;= cost: </code></pre> <p>Your code is correct check for the values your are looping with.</p>
0
2016-06-21T06:15:17Z
[ "python", "dictionary", "tkinter" ]
Updating values in a dict on Python inside a Tkinter button
37,936,427
<p>I'm attempting to write some code for a game using Python and seem not to be able to get my variables out of the button click command into the dictionary variables for later use. What I'm trying to do is run the jingle_add() on a button click, have it run some calculations, update the displays and return the tree va...
1
2016-06-21T05:43:39Z
37,937,080
<p>In its current form, your code cannot compile due to the assignment in the <code>lambda</code> expression. An alternative would be to define what that does in a function instead and use the function as the callback:</p> <pre><code>def add_to_data(): data['fans'], data['jingle_cost'], data['jingle'] = jingle_add...
0
2016-06-21T06:33:14Z
[ "python", "dictionary", "tkinter" ]
Associating a combination's indices with a value
37,936,527
<p>I am working on a program for which I need combinations of the distances between atoms, or various points in 3D space. Here's an example:</p> <p>A file 'test' contains the following information:</p> <pre><code>Ti 1.0 1.0 1.0 O 0.0 2.0 0.0 O 0.0 0.0 0.0 Ti 1.0 3.0 4.0 O 2.0 5.0 0.0 </code></pre> <p>I would lik...
0
2016-06-21T05:52:30Z
38,002,676
<p>Before we begin, let me note that in case of crystals (and I have a bit of a suspicion that you're not dealing with a Ti2O3 <em>molecule</em>) you should be careful with the periodic boundary conditions, i.e. the two last atoms that are distant from everyone might be closer to an atom in a neighbouring cell.</p> <p...
0
2016-06-23T22:05:50Z
[ "python", "arrays", "numpy", "chemistry" ]
Installing and importing Python Modules onto OS X
37,936,625
<p>I've been trying for a couple of hours already. It seems IDLE can't find any third-party module. I am a Python beginner.</p> <p>Here is some info about my system:</p> <ul> <li>OSX version: 10.11.5</li> <li>python version: Python 2.7, Python 3.4, Python 3.5 </li> </ul> <p>The initial installation using pip (among...
0
2016-06-21T06:00:21Z
37,942,253
<p>It seems you are using conda, but you are trying to install the <code>pyperclip</code> module with <code>pip</code>. Have you tried running <code>conda install pyperclip</code>?</p> <p>As stated <a href="http://stackoverflow.com/questions/20994716/what-is-the-difference-between-pip-and-conda">here</a>:</p> <blockq...
0
2016-06-21T10:43:01Z
[ "python", "osx", "python-2.7", "python-3.x", "module" ]
Parallelization possible with Python CRFsuite?
37,936,649
<p>Is it possible to parallelize python CRFSuite (<a href="https://github.com/tpeng/python-crfsuite" rel="nofollow">https://github.com/tpeng/python-crfsuite</a>) ? I think CRF++ support parallelization, so I guess there must be some hooks to enable parallelization with CRFsuite as well.</p>
1
2016-06-21T06:02:00Z
40,063,040
<p>No, it is currently not possible; parallel training is not implemented. There is some work on it in bug tracker though. You can still run cross-validation in parallel (i.e. train multiple models in parallel).</p>
0
2016-10-15T19:00:47Z
[ "python", "crf", "crf++" ]
Python in mac and Windows
37,936,665
<p>Is there any big difference in both except different operating systems?</p> <p>I mean if i create a python script in windows, will it run these same in mac too?</p> <p>My concern is one of my buyer want me to make a program for mac and i don't have access to any mac devices that's why i have chosen python langu...
-2
2016-06-21T06:03:19Z
37,936,726
<p>There absolutely no difference between OS. Its a programming lang, only difference would be the IDE you decide to use. Other than that, the way it give O/P to programs is same. Hope it solves your doubt.</p>
2
2016-06-21T06:08:27Z
[ "python", "windows", "osx" ]
Python in mac and Windows
37,936,665
<p>Is there any big difference in both except different operating systems?</p> <p>I mean if i create a python script in windows, will it run these same in mac too?</p> <p>My concern is one of my buyer want me to make a program for mac and i don't have access to any mac devices that's why i have chosen python langu...
-2
2016-06-21T06:03:19Z
37,936,732
<p><strong>There is no difference.</strong></p> <p>Python can run on both systems. <strong>However</strong>, you may be using a module that only works on Windows (e.g. <code>win32api</code>). You can check your module's compatibility on a virtual machine.</p> <p>If you would like to compile into an application (<code...
1
2016-06-21T06:09:03Z
[ "python", "windows", "osx" ]
Python in mac and Windows
37,936,665
<p>Is there any big difference in both except different operating systems?</p> <p>I mean if i create a python script in windows, will it run these same in mac too?</p> <p>My concern is one of my buyer want me to make a program for mac and i don't have access to any mac devices that's why i have chosen python langu...
-2
2016-06-21T06:03:19Z
37,936,828
<p>Found this discussion revelant to your question. Hope it helps.</p> <p><a href="https://www.quora.com/Can-I-run-my-Python-program-in-both-Linux-and-Windows" rel="nofollow">https://www.quora.com/Can-I-run-my-Python-program-in-both-Linux-and-Windows</a></p>
1
2016-06-21T06:15:32Z
[ "python", "windows", "osx" ]
RPi3 connecting to WEP router using Python
37,936,747
<p>I've been trying to connect to WiFi networks using Python, but hitting a dead end.</p> <p>I'm using the wireless module in Python: <a href="https://github.com/joshvillbrandt/wireless" rel="nofollow">https://github.com/joshvillbrandt/wireless</a></p> <pre><code>from wireless import Wireless wireless = Wireless() w...
1
2016-06-21T06:10:33Z
37,946,997
<p>What O/S are you using? Can you connect to it from the RaspPi3 built-in wireless options? </p> <p>If so - what are settings in wpa_supplicant?</p> <p>From the library notes - this might be an answer:</p> <blockquote> <p>To use wpa_supplicant, network-manager (the backend for nmcli) must not be running. This i...
0
2016-06-21T14:20:09Z
[ "python", "wifi", "raspbian", "raspberry-pi3" ]
Scraping on Python
37,936,780
<p>I wanted to get the caption, no. of likes and comments of the recent 10 images of a particular user. Using below code I am just able to get the latest one.</p> <p>Code:</p> <pre><code>from selenium import webdriver from bs4 import BeautifulSoup import json, time, re phantomjs_path = r'C:\Users\ravi.janjwadia\Deskt...
3
2016-06-21T06:12:49Z
37,937,079
<p>In your code below, you're only retrieving the first node (which is the first image).</p> <pre><code>print(result['entry_data']['ProfilePage'][0]['user']['media']['nodes'][0]['caption']) </code></pre> <p>To get the info of the recent 10 images of the user try this instead.</p> <pre><code>recent_ten_nodes = result...
3
2016-06-21T06:33:14Z
[ "python", "web-scraping", "instagram", "screen-scraping" ]
How to remove a row with only one item in csv file using Python?
37,936,954
<p>I have tried to find an answer to this problem but to no avail. Here's the problem I'm facing -</p> <p>I have a csv file where some rows have three elements (indicating that they are full) and some other rows that only have one element in them (indicating they are not full and so should be discarded). Here's an exa...
1
2016-06-21T06:24:57Z
37,937,038
<p>The <code>csv.reader</code> object creates a new <em>list</em> for every row and does not pad these. Just test for the row length:</p> <pre><code>if len(row) &gt; 1: </code></pre> <p>The question you link to uses <code>csv.DictReader()</code>, which is given fieldnames up-front, resulting in either <code>None</cod...
1
2016-06-21T06:30:41Z
[ "python", "csv" ]
How to remove a row with only one item in csv file using Python?
37,936,954
<p>I have tried to find an answer to this problem but to no avail. Here's the problem I'm facing -</p> <p>I have a csv file where some rows have three elements (indicating that they are full) and some other rows that only have one element in them (indicating they are not full and so should be discarded). Here's an exa...
1
2016-06-21T06:24:57Z
37,937,087
<p>There is alot you can do.</p> <p>One way is maybe this:</p> <pre><code>new_list = []; for one_line in your_data_list: spl = one_line.split(","); if len( spl ) &lt; 3:# or &lt; 2 if you need pass; else: new_list.append( spl) ); </code></pre>
0
2016-06-21T06:33:52Z
[ "python", "csv" ]
Can we integrate Hadoop with Python?
37,936,958
<p>I have my project requirement in which one python script is used for analyzing the data. Previously, I used the txt files as an input to that python script. But as data grows, I have to switch my storage platform to Hadoop HDFS. How can I HDFS data to my python script? Is there any way of doing that? Thanks in advan...
1
2016-06-21T06:25:10Z
37,940,691
<p>Hadoop Streaming API:</p> <pre><code>$HADOOP_HOME/bin/hadoop jar $HADOOP_HOME/hadoop-streaming.jar \ -input myInputDirs \ -output myOutputDir \ -mapper /bin/cat \ -reducer /bin/wc </code></pre> <p>All you need to know about that is here: <a href="http://www.michael-noll.com/tutorials/writing-an-hadoop-mapreduce-p...
2
2016-06-21T09:34:05Z
[ "python", "hadoop", "hdfs", "bigdata" ]