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 |
|---|---|---|---|---|---|---|---|---|---|
read output of php file using python | 38,116,305 | <p>I have a <code>php</code> file on server that prints some data from the <code>mysql</code> database in <code>json</code> format. </p>
<p>When I run my <code>php</code> file in my browser I can see the <code>json</code> array. Now I want to get that <code>json</code> array in a <code>python</code> file. Is there a w... | 1 | 2016-06-30T07:16:20Z | 38,143,968 | <p>I finally got the answer after trying a lot of different python libraries</p>
<pre><code>import json
import urllib.request
url = "http://example.com/your-filename.php"
x = urllib.request.urlopen(url)
raw_data = x.read()
encoding = x.info().get_content_charset('utf8') # JSON default
print(raw_data) #this is data ... | 1 | 2016-07-01T11:12:30Z | [
"python",
"subprocess"
] |
I need to get the element id of page 2 and write a html page | 38,116,310 | <p>I am trying to write a html page(page1) to hit a url of another page (Pgae2). and get the element id of a dropdown of page 2 to display it selected when I click on a hyperlink of url of page 2 from page1.
Could anyone tell how to implement this?</p>
<p><strong>HTML:</strong></p>
<pre><code><!DOCTYPE html>
&... | -2 | 2016-06-30T07:16:33Z | 38,116,397 | <p>On the page 2 you simply can fetch the ID by document.getElementById("ID") and use it on document.ready . there is nothing to do with page one in your case .</p>
| 0 | 2016-06-30T07:20:55Z | [
"javascript",
"jquery",
"python",
"html",
"ajax"
] |
I need to get the element id of page 2 and write a html page | 38,116,310 | <p>I am trying to write a html page(page1) to hit a url of another page (Pgae2). and get the element id of a dropdown of page 2 to display it selected when I click on a hyperlink of url of page 2 from page1.
Could anyone tell how to implement this?</p>
<p><strong>HTML:</strong></p>
<pre><code><!DOCTYPE html>
&... | -2 | 2016-06-30T07:16:33Z | 38,116,442 | <p>You can use it by using <a href="http://api.jquery.com/jQuery.get/" rel="nofollow">GET</a> method of jQuery.</p>
<p><strong>For e.g.</strong></p>
<pre><code>$.get('Page2.html', null, function(text){
alert($(text).find('#name')); //#name is the name of your dropdown of 2nd page
});
</code></pre>
| 0 | 2016-06-30T07:23:57Z | [
"javascript",
"jquery",
"python",
"html",
"ajax"
] |
I need to get the element id of page 2 and write a html page | 38,116,310 | <p>I am trying to write a html page(page1) to hit a url of another page (Pgae2). and get the element id of a dropdown of page 2 to display it selected when I click on a hyperlink of url of page 2 from page1.
Could anyone tell how to implement this?</p>
<p><strong>HTML:</strong></p>
<pre><code><!DOCTYPE html>
&... | -2 | 2016-06-30T07:16:33Z | 38,116,525 | <p>You can store the selected value in localstorage on change event of dropdown like this - </p>
<p><code>localStorage.setItem("selectedValue","yourselectedValue");</code></p>
<p>and you can access this value from any page.</p>
| 0 | 2016-06-30T07:27:28Z | [
"javascript",
"jquery",
"python",
"html",
"ajax"
] |
I need to get the element id of page 2 and write a html page | 38,116,310 | <p>I am trying to write a html page(page1) to hit a url of another page (Pgae2). and get the element id of a dropdown of page 2 to display it selected when I click on a hyperlink of url of page 2 from page1.
Could anyone tell how to implement this?</p>
<p><strong>HTML:</strong></p>
<pre><code><!DOCTYPE html>
&... | -2 | 2016-06-30T07:16:33Z | 38,116,639 | <p>You can use <code><a></code> element, <code>location.hash</code>, <code>.focus()</code></p>
<p>page1.html</p>
<pre><code><!DOCTYPE html>
<html>
<head>
</head>
<body>
<a href="page2.html#select">click</a>
</body>
</html>
</code></pre>
<p>pa... | 0 | 2016-06-30T07:32:45Z | [
"javascript",
"jquery",
"python",
"html",
"ajax"
] |
How can i create a list with this API Data? | 38,116,369 | <p>I'm using the runescape API for high scores.</p>
<p>I am getting back all of my stats from the api which is fine but im trying to figure out how choose to a specific number and print this number..</p>
<p>for example the number (2422)</p>
<pre><code>import urllib3
from bs4 import BeautifulSoup
import requests
url... | 0 | 2016-06-30T07:19:32Z | 38,116,681 | <p>Seems like your API returns data in the form of <em>"three comma separated numbers per line"</em>. Therefore you may just use <code>r.text</code> in order to get the response:</p>
<pre><code>In [14]: r.text
Out[14]: '99245,2422,387973429\n88599,99,16385311\n80538,99,18028072\n49262,99,23912868\n88753,99,27170883\n6... | 2 | 2016-06-30T07:34:24Z | [
"python",
"python-3.x"
] |
Extending the bot in python's IRC library | 38,116,388 | <p>I am attempting to extend the example bot that comes with this <a href="https://pypi.python.org/pypi/irc" rel="nofollow">IRC library here</a>. I've repasted the code of said bot <a href="http://pastebin.com/Ex8kk03D" rel="nofollow">here</a>.</p>
<p>My problem is that I don't quite see what needs to be modified in o... | 0 | 2016-06-30T07:20:21Z | 38,182,546 | <p>Check out <a href="https://github.com/jaraco/irc/blob/master/scripts/testbot.py" rel="nofollow">this example</a> of what you need to do.</p>
<pre><code>class TestBot(irc.bot.SingleServerIRCBot):
def __init__(self, channel, nickname, server, port=6667):
irc.bot.SingleServerIRCBot.__init__(self, [(server,... | 1 | 2016-07-04T10:32:15Z | [
"python",
"bots",
"irc"
] |
Python extract all key values in in nested JSON in a list | 38,116,546 | <p>I have a json like below:</p>
<pre><code>{"widget": {
"debug": "on",
"window": {
"title": "SampleWidget",
"name": "main_window",
"width": 500,
"height": 500
},
"image": {
"src": "Images/Sun.png",
"name": "sun1",
"hOffset": 250,
"vOffse... | 0 | 2016-06-30T07:28:31Z | 38,116,773 | <pre class="lang-py prettyprint-override"><code>data = {"widget": { "debug": "on", "window": { "title": "SampleWidget", "name": "main_window", "width": 500, "height": 500 }, "image": { "src": "Images/Sun.png", "name": "sun1", "hOffset": 250, "vOffset": 250, "alignment": "center" }, "text": { "data": "Click Here", "size... | 2 | 2016-06-30T07:38:45Z | [
"python",
"json"
] |
Pyroute2 import error - import AF_BRIDGE | 38,116,552 | <p>whenever I'm trying to run the sample script of pyroute2 module :</p>
<pre><code>from pyroute2 import IPRoute
ip = IPRoute()
print([x.get_attr('IFLA_IFNAME') for x in ip.get_links()])
</code></pre>
<p>I'm getting the following error :</p>
<pre><code>Traceback (most recent call last):
File "ex.py", line 2, in &l... | 0 | 2016-06-30T07:28:42Z | 39,311,079 | <p>Firstly, from official <a href="https://github.com/svinota/pyroute2" rel="nofollow">pyroute2 git repository</a>:</p>
<blockquote>
<p>Pyroute2 is a pure Python netlink and Linux network configuration library. It requires only Python stdlib, no 3rd party libraries. Later it can change, but the deps tree will remain... | 0 | 2016-09-03T20:31:35Z | [
"python",
"python-2.7",
"import",
"python-3.5",
"openbsd"
] |
Launch Jenkins parametrized build from script | 38,116,657 | <p>I am trying to launch a Jenkins parametrized job from a python script. Due to environment requirements, I can't install python-jenkins. I am using raw requests module.</p>
<p>This job I am trying to launch has three parameters:</p>
<ul>
<li>string (let's call it payload)</li>
<li>string (let's call it target)</li>... | 1 | 2016-06-30T07:33:32Z | 38,117,170 | <p>import jenkinsapi
from jenkinsHandler import JenkinsHandler
in your python script</p>
<p>Pass parameters to buildJob() , (like < your JenkinsHandler object name>.buildJob())
JenkinsHandler module has functions like init() , buildJob(), isRunning() which helps in triggering the build </p>
| 0 | 2016-06-30T07:57:30Z | [
"python",
"jenkins",
"python-requests"
] |
Launch Jenkins parametrized build from script | 38,116,657 | <p>I am trying to launch a Jenkins parametrized job from a python script. Due to environment requirements, I can't install python-jenkins. I am using raw requests module.</p>
<p>This job I am trying to launch has three parameters:</p>
<ul>
<li>string (let's call it payload)</li>
<li>string (let's call it target)</li>... | 1 | 2016-06-30T07:33:32Z | 38,147,532 | <p>Here is an example:</p>
<pre><code>curl -vvv -X POST http://127.0.0.1:8080/jenkins/job/jobname/build
--form file0='@/tmp/yourfile'
--form json='{"parameter": [{"name":"file", "file":"file0"}]}'
--form json='{"parameter": [{"name":"payload", "value":"123"}]
--form json='{"parameter": [{"name":... | 0 | 2016-07-01T14:07:21Z | [
"python",
"jenkins",
"python-requests"
] |
Launch Jenkins parametrized build from script | 38,116,657 | <p>I am trying to launch a Jenkins parametrized job from a python script. Due to environment requirements, I can't install python-jenkins. I am using raw requests module.</p>
<p>This job I am trying to launch has three parameters:</p>
<ul>
<li>string (let's call it payload)</li>
<li>string (let's call it target)</li>... | 1 | 2016-06-30T07:33:32Z | 38,696,105 | <p>It turns out it is impossible to send both data and file in a single request via HTTP.</p>
| 0 | 2016-08-01T10:04:56Z | [
"python",
"jenkins",
"python-requests"
] |
Failing to change timezones of price data using IBPy | 38,116,936 | <p>I would like to be able to get price data of a security with EST (New York) as the timezone. My broker is Interactive Brokers. I am using python 3.5 with the <a href="https://github.com/blampe/IbPy" rel="nofollow">IBPy library</a>. My problem is that when I modify the 3rd argument of reqHistoricalData which controls... | 1 | 2016-06-30T07:45:54Z | 38,283,833 | <p>The TZ just tells the IB server when to end the request. The responses will always be in GMT if you use 2 for formatDate param, or in your local time zone if you use 1. </p>
<p>So by using JST you tell the server to end the request about 12 hours earlier, ie. when that was the time in Japan.</p>
<p>In your examp... | 3 | 2016-07-09T16:21:41Z | [
"python",
"timezone",
"interactive-brokers",
"ibpy"
] |
Update pandas DataFrame with .str.replace() vs .replace() | 38,117,016 | <p>I have a column in my pandas Dataframe df that contains a string with some trailing hex-encoded NULLs (\x00). At least I think that it's that. When I tried to replace them with:</p>
<pre><code>df['SOPInstanceUID'] = df['SOPInstanceUID'].replace('\x00', '')
</code></pre>
<p>the column is not updated. When I do the ... | 0 | 2016-06-30T07:50:24Z | 38,117,070 | <p>The former looks for <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.replace.html" rel="nofollow">exact matches</a>, the <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.replace.html" rel="nofollow">latter</a> looks for matches in any part of the string, w... | 2 | 2016-06-30T07:52:56Z | [
"python",
"pandas",
"dataframe"
] |
Update pandas DataFrame with .str.replace() vs .replace() | 38,117,016 | <p>I have a column in my pandas Dataframe df that contains a string with some trailing hex-encoded NULLs (\x00). At least I think that it's that. When I tried to replace them with:</p>
<pre><code>df['SOPInstanceUID'] = df['SOPInstanceUID'].replace('\x00', '')
</code></pre>
<p>the column is not updated. When I do the ... | 0 | 2016-06-30T07:50:24Z | 38,117,138 | <p>You did not specify a regex or require an exact match, hence str.replace worked</p>
<pre><code>str.replace(old, new[, count])
</code></pre>
<p>Return a copy of the string with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurrences are replaced.</... | 1 | 2016-06-30T07:56:26Z | [
"python",
"pandas",
"dataframe"
] |
Writing data to json in python | 38,117,094 | <p>I have np array of 3*10 dimension, each column is vertex with its x, y, z co-ordinate.</p>
<p>I want to output this data to JSON file like following.</p>
<pre><code>{
"v0" : {
"x" : 0.0184074,
"y" : 0.354329,
"z" : -0.024123
},
"v1" : {
"x" : 0.34662,
"y" : 0.338337,
"z" : -0.0333459
}
#and so on...
</code></pre>
... | -1 | 2016-06-30T07:54:31Z | 38,117,216 | <p>You should call <code>json.load(fileObj)</code>, here I have modified:</p>
<pre><code>#vertices is np array of 3*10 dimention
for x in xrange(0,10):
s += "\n\"v\""+ str(x) +" : {";
s += "\n\"x\" : "+str(vertices[0][x]) +","
s += "\n\"y\" : "+str(vertices[1][x]) +","
s += "\n\"z\" : "+str(vertices[2]... | 0 | 2016-06-30T08:00:16Z | [
"python",
"json",
"numpy",
"dictionary"
] |
Writing data to json in python | 38,117,094 | <p>I have np array of 3*10 dimension, each column is vertex with its x, y, z co-ordinate.</p>
<p>I want to output this data to JSON file like following.</p>
<pre><code>{
"v0" : {
"x" : 0.0184074,
"y" : 0.354329,
"z" : -0.024123
},
"v1" : {
"x" : 0.34662,
"y" : 0.338337,
"z" : -0.0333459
}
#and so on...
</code></pre>
... | -1 | 2016-06-30T07:54:31Z | 38,117,241 | <p>The exception is raised because you use <code>json.loads</code>, which expects a JSON string as argument not a filename.</p>
<p>However, the way you dump the JSON is wrong too. You are building a string <code>s</code>, which contains invalid JSON. Then, you are dumping this single string with <code>json.dump</code>... | 0 | 2016-06-30T08:01:06Z | [
"python",
"json",
"numpy",
"dictionary"
] |
Writing data to json in python | 38,117,094 | <p>I have np array of 3*10 dimension, each column is vertex with its x, y, z co-ordinate.</p>
<p>I want to output this data to JSON file like following.</p>
<pre><code>{
"v0" : {
"x" : 0.0184074,
"y" : 0.354329,
"z" : -0.024123
},
"v1" : {
"x" : 0.34662,
"y" : 0.338337,
"z" : -0.0333459
}
#and so on...
</code></pre>
... | -1 | 2016-06-30T07:54:31Z | 38,117,601 | <p>You need to construct your json properly first:</p>
<pre><code>s = {}
for x in xrange(0,10):
s["v"+str(x)]= { "x":str(vertices[0][x]),"y":str(vertices[1][x]),"z":str(vertices[2][x]) }
</code></pre>
<p>Then you dump it:</p>
<pre><code>with open("text.json", "w") as outfile:
json.dump(s, outfile, indent=4)
... | 0 | 2016-06-30T08:19:27Z | [
"python",
"json",
"numpy",
"dictionary"
] |
How can I get the text from a dialogue using selenium-python? | 38,117,131 | <p>I want to crawl the dialogue text in a <strong>popup window</strong>. The problem is that after I triggered the link the window appears but it seems that the selenium driver cannot handle it automatically as I learned from other questions on this site by entering <code>driver.window_handles</code>.
The source of th... | 0 | 2016-06-30T07:56:14Z | 38,118,265 | <p>Once you have your parent element : </p>
<pre><code>wd = driver.find_element_by_css_selector('div[node-type="repeat_list"]')
</code></pre>
<p>you can continue calling methods on this object, and in this order reach the children elements, you can use find <code>element_by_xpath</code>, or <code>find element_by_clas... | 0 | 2016-06-30T08:52:25Z | [
"python",
"selenium",
"selenium-webdriver",
"dialog"
] |
OpenCV CalcCovarMatrix vs. Numpy Cov | 38,117,383 | <p>I am porting an image processing algorithm from Python to C++, using OpenCV in both cases.</p>
<p>In the Python version, we are using np.cov from Numpy:</p>
<pre><code>import numpy as np
#Using some dummy data to represent BGR pixels
values = [[30, 37, 35], [26, 36, 34], [38, 45, 41], [40, 47, 43], [38, 45, 43], [... | 0 | 2016-06-30T08:08:35Z | 38,136,833 | <p>The culprit has been identified! There were two problems:</p>
<p>1) <code>values.at<uchar>(0) = (30, 37, 35);</code> does not in fact write the values into the row (as someone coming in from Python would expect). It actually just writes the last value, 35, into the 0th position of the Mat. The Mat in the abov... | 0 | 2016-07-01T03:59:00Z | [
"python",
"c++",
"opencv",
"numpy"
] |
PySpark: read, map and reduce from multiline record textfile with newAPIHadoopFile | 38,117,391 | <p>I'm trying so solve a problem that is kind of similar to <a href="http://stackoverflow.com/questions/31227363/creating-spark-data-structure-from-multiline-record">this post</a>. My original data is a text file that contains values (observations) of several sensors. Each observation is given with a timestamp but the ... | 0 | 2016-06-30T08:09:09Z | 38,120,668 | <p>Personally I would:</p>
<ul>
<li><p>extend delimiter with <code>::</code></p>
<pre><code>sheet = sc.newAPIHadoopFile(
path,
'org.apache.hadoop.mapreduce.lib.input.TextInputFormat',
'org.apache.hadoop.io.LongWritable',
'org.apache.hadoop.io.Text',
conf={'textinputformat.record.delimiter': 'Time\... | 1 | 2016-06-30T10:37:06Z | [
"python",
"hadoop",
"hdfs",
"pyspark",
"custom-formatting"
] |
Pandas Python, select columns based on rows conditions | 38,117,400 | <p>I have a dataframe:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(np.random.randn(2, 4))
print(df)
0 1 2 3
0 1.489198 1.329603 1.590124 1.123505
1 0.024017 0.581033 2.500397 0.156280
</code></pre>
<p>I want to select the columns which for there is at least one row w... | 1 | 2016-06-30T08:09:24Z | 38,117,460 | <p>Use <code>mask</code> created with <code>df > 2</code> with <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.any.html" rel="nofollow"><code>any</code></a> and then select columns by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ix.html" rel="nofollo... | 1 | 2016-06-30T08:12:43Z | [
"python",
"pandas",
"dataframe",
"condition"
] |
Pandas Python, select columns based on rows conditions | 38,117,400 | <p>I have a dataframe:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(np.random.randn(2, 4))
print(df)
0 1 2 3
0 1.489198 1.329603 1.590124 1.123505
1 0.024017 0.581033 2.500397 0.156280
</code></pre>
<p>I want to select the columns which for there is at least one row w... | 1 | 2016-06-30T08:09:24Z | 38,117,475 | <p>Use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.gt.html#pandas.DataFrame.gt" rel="nofollow"><code>gt</code></a> and <code>any</code> to filter the df:</p>
<pre><code>In [287]:
df.ix[:,df.gt(2).any()]
Out[287]:
2
0 1.590124
1 2.500397
</code></pre>
<p>Here we use <co... | 2 | 2016-06-30T08:13:33Z | [
"python",
"pandas",
"dataframe",
"condition"
] |
Is there any legitimate use of list[True], list[False] in Python? | 38,117,555 | <p>Since <code>True</code> and <code>False</code> are instances of <code>int</code>, the following is valid in Python:</p>
<pre><code>>>> l = [0, 1, 2]
>>> l[False]
0
>>> l[True]
1
</code></pre>
<p>I understand why this happens. However, I find this behaviour a bit unexpected and can lead t... | 37 | 2016-06-30T08:17:05Z | 38,117,588 | <p>In the past, some people have used this behaviour to produce a poor-man's <a href="http://stackoverflow.com/questions/394809/does-python-have-a-ternary-conditional-operator">conditional expression</a>:</p>
<pre><code>['foo', 'bar'][eggs > 5] # produces 'bar' when eggs is 6 or higher, 'foo' otherwise
</code></pr... | 58 | 2016-06-30T08:18:59Z | [
"python",
"boolean"
] |
Is there any legitimate use of list[True], list[False] in Python? | 38,117,555 | <p>Since <code>True</code> and <code>False</code> are instances of <code>int</code>, the following is valid in Python:</p>
<pre><code>>>> l = [0, 1, 2]
>>> l[False]
0
>>> l[True]
1
</code></pre>
<p>I understand why this happens. However, I find this behaviour a bit unexpected and can lead t... | 37 | 2016-06-30T08:17:05Z | 38,123,068 | <p>If you are puzzled why <code>bool</code> is a valid index argument: this is simply for <strong>consistency</strong> with the fact that <code>bool</code> is a subclass of <code>int</code> and in Python it <strong>is</strong> a numerical type. </p>
<p>If you are asking why <code>bool</code> is a numerical type in the... | 34 | 2016-06-30T12:27:00Z | [
"python",
"boolean"
] |
Is there any legitimate use of list[True], list[False] in Python? | 38,117,555 | <p>Since <code>True</code> and <code>False</code> are instances of <code>int</code>, the following is valid in Python:</p>
<pre><code>>>> l = [0, 1, 2]
>>> l[False]
0
>>> l[True]
1
</code></pre>
<p>I understand why this happens. However, I find this behaviour a bit unexpected and can lead t... | 37 | 2016-06-30T08:17:05Z | 38,133,888 | <p>There are often better ways, but Boolean indices do have their uses. I've used them when I want to convert a boolean result to something more human readable:</p>
<pre><code>test_result = run_test()
log.info("The test %s." % ('Failed', 'Passed')[test_result])
</code></pre>
| 4 | 2016-06-30T21:55:13Z | [
"python",
"boolean"
] |
What is the best way to implement google cloud storage? | 38,117,597 | <p>I am using google cloud storage for content at server side like user's videos, images and profile picture.
I have some doubt about what is the best practice to implement google cloud signed URL concept.</p>
<p>According to me</p>
<p>1st:- I can store an object name in database and generate a signed URL to get that... | 5 | 2016-06-30T08:19:16Z | 38,164,570 | <p>Signed URLs rely on expiration to <a href="https://cloud.google.com/storage/docs/access-control/signed-urls#signed-urls" rel="nofollow">provide security</a>, so setting a very high expiration and storing the signed URL indefinitely will compromise this.</p>
<p>A good trade-off is to cache the signed URL somewhere (... | 1 | 2016-07-02T21:19:42Z | [
"java",
"python",
".net",
"scala",
"google-cloud-storage"
] |
What is the best way to implement google cloud storage? | 38,117,597 | <p>I am using google cloud storage for content at server side like user's videos, images and profile picture.
I have some doubt about what is the best practice to implement google cloud signed URL concept.</p>
<p>According to me</p>
<p>1st:- I can store an object name in database and generate a signed URL to get that... | 5 | 2016-06-30T08:19:16Z | 38,165,655 | <p>You don´t need an API call to generate a signed URL, you can get a JSON key and generate the URL with common ssl tools from a myriad of programming languages; take a look at the <a href="https://cloud.google.com/storage/docs/access-control/create-signed-urls-program" rel="nofollow">Signed URL Documentation</a>, it ... | 0 | 2016-07-03T00:27:22Z | [
"java",
"python",
".net",
"scala",
"google-cloud-storage"
] |
python xlsxwriter write cell according to row data | 38,117,610 | <p>I have python dictionaries: </p>
<pre><code>student_age = {'bala':20,'raju':21}
student_id = {'bala':289,'raju':567}
</code></pre>
<p>and ten more similar dictionaries with key as student name and value different field.</p>
<p><strong>Expected excel result:</strong>
<a href="http://i.stack.imgur.com/moL7u.png" r... | 1 | 2016-06-30T08:20:08Z | 38,117,739 | <p>Check this link to learn about dictionaries in python : <a href="http://learnpythonthehardway.org/book/ex39.html" rel="nofollow">http://learnpythonthehardway.org/book/ex39.html</a></p>
<p>Without providing some sample code it's hard to see what you did, so please Edit your question with sample code and I'll Edit my... | 0 | 2016-06-30T08:27:18Z | [
"python",
"excel",
"row",
"xlsxwriter"
] |
python xlsxwriter write cell according to row data | 38,117,610 | <p>I have python dictionaries: </p>
<pre><code>student_age = {'bala':20,'raju':21}
student_id = {'bala':289,'raju':567}
</code></pre>
<p>and ten more similar dictionaries with key as student name and value different field.</p>
<p><strong>Expected excel result:</strong>
<a href="http://i.stack.imgur.com/moL7u.png" r... | 1 | 2016-06-30T08:20:08Z | 38,117,833 | <p>You could simply add all your python dictionaries to a list so you can iterate through them for each student to populate each column for every row. Something like this:</p>
<p><strong>Updated to address OP's comments</strong></p>
<p>For #1, simply write the headers in the first row, and then offset the other rows... | 1 | 2016-06-30T08:32:44Z | [
"python",
"excel",
"row",
"xlsxwriter"
] |
Read file and check dictionary | 38,117,824 | <p>I want to read a file line by line and check for each line whether one string of the line is allowed by my dictionary to be with another string in the same line. I have come up with this code </p>
<pre><code>dic={'ALA':['N','H','CA','HA','CB','HB1','HB2','HB3','C','O'],
'GLY':['N','H','CA','HA2','HA3','C','O'],
(..... | -1 | 2016-06-30T08:32:18Z | 38,118,013 | <p>You don't have a key named '3.2' in <code>dic</code>. I think you should check the key name first.</p>
<pre><code>for line in fin:
atom=line[12:16].strip()
resi=line[17:20].strip()
result = dic.get(resi)
if result and (atom not in result):
print(line)
</code></pre>
| 0 | 2016-06-30T08:40:47Z | [
"python",
"python-3.x",
"dictionary"
] |
Read file and check dictionary | 38,117,824 | <p>I want to read a file line by line and check for each line whether one string of the line is allowed by my dictionary to be with another string in the same line. I have come up with this code </p>
<pre><code>dic={'ALA':['N','H','CA','HA','CB','HB1','HB2','HB3','C','O'],
'GLY':['N','H','CA','HA2','HA3','C','O'],
(..... | -1 | 2016-06-30T08:32:18Z | 38,118,031 | <p>The problem is you're getting the value of <code>3.2</code> for <code>resi</code> for one of the lines and since <code>3.2</code> is not a valid key in dic, you're getting an exception.</p>
<pre><code>for line in fin:
atom=line[12:16].strip()
resi=line[17:20].strip()
if resi in dic and atom not in dic[r... | 1 | 2016-06-30T08:41:31Z | [
"python",
"python-3.x",
"dictionary"
] |
Read file and check dictionary | 38,117,824 | <p>I want to read a file line by line and check for each line whether one string of the line is allowed by my dictionary to be with another string in the same line. I have come up with this code </p>
<pre><code>dic={'ALA':['N','H','CA','HA','CB','HB1','HB2','HB3','C','O'],
'GLY':['N','H','CA','HA2','HA3','C','O'],
(..... | -1 | 2016-06-30T08:32:18Z | 38,118,088 | <p>It says Keyerror when you use dic[resi] because 'resi' is not a key in the dic but 'ALA' is a key in your dictionary. If you try something like print (dic['ALA']) it will print everything under the 'ALA' key. </p>
| 0 | 2016-06-30T08:44:31Z | [
"python",
"python-3.x",
"dictionary"
] |
pandas str contain to return match | 38,117,868 | <p>Pandas <code>str.contains()</code> where evaluated to <code>True</code> in the way below returns the row. But how to return the match instead of the row?</p>
<pre><code>In [1]: df
language level
java programming beginner
c/c++ intermediate
php beginner
In [2]: df[df['langu... | 1 | 2016-06-30T08:34:07Z | 38,118,094 | <p>You can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.extract.html" rel="nofollow"><code>str.extract</code></a> and then remove rows with <code>NaN</code> by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.dropna.html" rel="nofollow"><code>dropna... | 2 | 2016-06-30T08:44:49Z | [
"python",
"pandas"
] |
np.where code - ValueError: "cannot set items on DatetimeIndexResampler" | 38,118,183 | <p>I created a data frame to use when testing the resample features as follows:</p>
<pre><code>f = pd.DataFrame(data=np.linspace(50, 100, 200), index=pd.date_range(end='2014-06-18', periods=200), columns=['last'])
f
Out[63]:
last
2013-12-01 50.000000
2013-12-02 50.251256
2013-12-03 50.502513
</code></pre>
<p>I the... | 1 | 2016-06-30T08:49:00Z | 38,118,236 | <p>You need add some aggragate function like <code>mean</code>, <code>sum</code>, because in version <code>0.18.0</code> was <code>API</code> changed and return <code>Resampler</code> - see <a href="http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#resample-api" rel="nofollow">resample api</a>:</p>
<pre><code>... | 2 | 2016-06-30T08:51:24Z | [
"python",
"numpy",
"pandas"
] |
np.where code - ValueError: "cannot set items on DatetimeIndexResampler" | 38,118,183 | <p>I created a data frame to use when testing the resample features as follows:</p>
<pre><code>f = pd.DataFrame(data=np.linspace(50, 100, 200), index=pd.date_range(end='2014-06-18', periods=200), columns=['last'])
f
Out[63]:
last
2013-12-01 50.000000
2013-12-02 50.251256
2013-12-03 50.502513
</code></pre>
<p>I the... | 1 | 2016-06-30T08:49:00Z | 38,118,272 | <p>First issue is that your resample object is just a resampler, you need to call some aggregate function like <code>mean</code>, secondly even if that were to be fixed your line:</p>
<pre><code>f_d1_resamp['Gap'] = np.where(f['last'] > f['last'].shift(),(f["last"].shift() - f["last"]),'')
</code></pre>
<p>raises ... | 1 | 2016-06-30T08:52:41Z | [
"python",
"numpy",
"pandas"
] |
What is the best way to take python input from users on a website and run it your server backend? | 38,118,197 | <p>I have a <strong><em>Django</em></strong> web-service where I have to take <strong><em>python</em></strong> code from users and run it in the backend and use that code for some purpose. Presently I have taken code by user and I store it in a file. When needed to run, I use a file descriptor to open the file and take... | 0 | 2016-06-30T08:49:39Z | 38,119,867 | <p>According to that other subject (<a href="http://stackoverflow.com/questions/1027714/how-to-execute-a-file-within-the-python-interpreter">How to execute a file within the python interpreter?</a>), it might be a good idea for you to try using the function <code>execfile(filename, variables)</code>. </p>
<p>So you ju... | 0 | 2016-06-30T10:01:37Z | [
"python",
"django",
"python-2.7",
"web-services"
] |
What is the best way to take python input from users on a website and run it your server backend? | 38,118,197 | <p>I have a <strong><em>Django</em></strong> web-service where I have to take <strong><em>python</em></strong> code from users and run it in the backend and use that code for some purpose. Presently I have taken code by user and I store it in a file. When needed to run, I use a file descriptor to open the file and take... | 0 | 2016-06-30T08:49:39Z | 38,124,993 | <p>you can use <code>execfile(filename, variables)</code> to execute it , but be careful , users can execute dangerous code , they can execute a <code>rm -fr *</code> command and delete all your files for example,</p>
<p>what you need is a <a href="https://pypi.python.org/pypi/pysandbox/" rel="nofollow">pysandbox </a>... | 0 | 2016-06-30T13:45:41Z | [
"python",
"django",
"python-2.7",
"web-services"
] |
In Python how do I plot using GMPY2? | 38,118,252 | <p>I'm not new to programming, but I am new to Python and numerical computing, so this may be a newbie question.</p>
<p>I'm using GMPY2 to handle computation of extremely large numbers, but I want to use MatPlotLib to graph the results. I currently have</p>
<pre><code>import gmpy2
from gmpy2 import mpz, mpq, mpfr, mp... | 0 | 2016-06-30T08:51:57Z | 38,126,562 | <p>Disclaimer: I maintain <code>gmpy2</code>.</p>
<p>Since you didn't state your error message, I tried your code and encountered the following error message:</p>
<pre><code>TypeError: add() argument types not supported
</code></pre>
<p>The <code>gmpy2</code> functions only accept scalar arguments. They do not itera... | 0 | 2016-06-30T14:47:11Z | [
"python",
"numpy",
"matplotlib",
"plot"
] |
How can I retrieve the docstring for a property of a Python class instance? | 38,118,264 | <p>Suppose I have a class like this:</p>
<pre><code>class TestCase(object):
"""Class docstring"""
def meth(self):
"""Method docstring"""
return 1
@property
def prop(self):
"""Property docstring"""
return 2
</code></pre>
<p>It's easy enough for me to get the docstrings... | 1 | 2016-06-30T08:52:23Z | 38,118,315 | <p>You are trying to access the <code>__doc__</code> from the instance which will try to first , evaluate the property, for which the returned value may have no attribute <code>__doc__</code>, or use the <code>__doc__</code> of the returned type. </p>
<p>Instead, you should access the <code>__doc__</code> for the <cod... | 3 | 2016-06-30T08:54:43Z | [
"python",
"properties",
"docstring"
] |
How to get all array in json object? | 38,118,268 | <p>I have json object send from view to html by success via ajax in django like this:</p>
<pre><code>json: Object
name1: Array[2]
name2: Array[2]
age: '18'
class: 'CLS01'
phone: ''
code: 'SV01
</code></pre>
<p>Now I want to loop in json object and get all array, in this case is <code>name1</code> and <code>name2</cod... | -1 | 2016-06-30T08:52:35Z | 38,118,418 | <pre><code>{% for eachdata in data %}
{% if eachdata == 'name1' or eachdata == 'name2' %}
{% for eachrec in eachdata %}
{{ eachrec }}
{% endfor %}
{% endif %}
{% endfor %}
</code></pre>
<p>This is how you can get the nested array out in django templates</p>
| 0 | 2016-06-30T09:00:27Z | [
"javascript",
"jquery",
"python",
"django"
] |
How to get all array in json object? | 38,118,268 | <p>I have json object send from view to html by success via ajax in django like this:</p>
<pre><code>json: Object
name1: Array[2]
name2: Array[2]
age: '18'
class: 'CLS01'
phone: ''
code: 'SV01
</code></pre>
<p>Now I want to loop in json object and get all array, in this case is <code>name1</code> and <code>name2</cod... | -1 | 2016-06-30T08:52:35Z | 38,118,419 | <p>Something like this maybe (where <code>obj</code> is your object): </p>
<pre><code>var arrays = [];
for(prop in obj) {
if(obj.hasOwnProperty(prop) && Array.isArray(obj[prop])) {
arrays.push(obj[prop]);
}
}
console.log(JSON.stringify(arrays, null, 2)); //Your arrays (in the array: arrays)
</code><... | 0 | 2016-06-30T09:00:33Z | [
"javascript",
"jquery",
"python",
"django"
] |
How to get all array in json object? | 38,118,268 | <p>I have json object send from view to html by success via ajax in django like this:</p>
<pre><code>json: Object
name1: Array[2]
name2: Array[2]
age: '18'
class: 'CLS01'
phone: ''
code: 'SV01
</code></pre>
<p>Now I want to loop in json object and get all array, in this case is <code>name1</code> and <code>name2</cod... | -1 | 2016-06-30T08:52:35Z | 38,118,454 | <p>You can try:</p>
<pre><code>for(var x in jsonObject){
if(jsonObject[x].constructor === Array){
//do anything
}
}
</code></pre>
| 0 | 2016-06-30T09:02:05Z | [
"javascript",
"jquery",
"python",
"django"
] |
Python Deep Learning find Duplicates | 38,118,382 | <p>I want to try and learn Deep Learning with Python.
The first thing that came to my mind for a useful scenario would be a Duplicate-Check.</p>
<p>Let's say you have a customer-table with name,address,tel,email and want to insert new customers.
E.g.:</p>
<pre><code>In Table:
Max Test,Teststreet 5, 00642 / 58458,info... | 1 | 2016-06-30T08:58:31Z | 38,119,344 | <p>Duplicate matching is a special case of similarity matching. You can define input features as either individual characters or fields and then train your network. It's a binary classification problem (true/false) unless you want to have a similarity score (95% match). The network should be able to learn that punctuat... | 0 | 2016-06-30T09:40:41Z | [
"python",
"deep-learning"
] |
How can I use python to filter the json with AWS list pricing API? | 38,118,412 | <p>I want to filter the json that operatinSystem are linux ,and I have some problem with it,the part of json in </p>
<pre><code> '' : {
</code></pre>
<p>that I don't know how dictionary represent it and </p>
<pre><code>"DQ578CGN99KG6ECF" : {
</code></pre>
<p>how can I represent it with wildcard, anyone could help... | 0 | 2016-06-30T09:00:04Z | 38,119,675 | <p>I'm not sure about the wildcard representation. I'll look into it and get back to you. Meanwhile, I have already worked with this json before so I can tell you how to access the information you need.
The information you need can be obtained as follows:</p>
<pre><code>for each_product in urlx['products']:
if url... | 0 | 2016-06-30T09:54:18Z | [
"python",
"json",
"amazon-web-services"
] |
python convert raw binary data to array of floats | 38,118,437 | <p>I'm new to python but i need to get this project done in it. I'm using telnetlib to get some raw data from a device, and this is what the data looks like (this is only part of the output i get, the real one is about 10x bigger)</p>
<blockquote>
<p>\xc2\xb2\xdd\x0f\xc2\xb2x/\xc2\xb2\x08\xb2M\xcf\xc2\xb2\xc5S\xc2\x... | -1 | 2016-06-30T09:01:22Z | 38,120,355 | <p>You need to know in advance the number of elements in the array, or somehow infer the count, ie by counting the number of bytes and then dividing by the float size. You then use the struct module to unpack the binary data.</p>
<pre><code>if (len(data) % 8) > 0:
assert "Data length not a multiple of 8"
L = []... | 0 | 2016-06-30T10:23:27Z | [
"python",
"arrays",
"binary",
"floating-point"
] |
request.POST.get() gives None in django | 38,118,478 | <p>I have an ajax call and I caught the request using pdb. <strong>request.POST</strong> gives me the following value:</p>
<pre><code><QueryDict: {u'{"layer_id":1,"status":"True"}': [u'']}>
</code></pre>
<p>But <strong>request.POST.get('status')</strong> gives <strong>None</strong></p>
| 0 | 2016-06-30T09:03:14Z | 38,118,508 | <p>You are not sending form-encoded data, so <code>request.POST</code> is useless. Use <code>request.body</code>.</p>
| 2 | 2016-06-30T09:04:57Z | [
"python",
"ajax",
"django",
"python-requests"
] |
append page to existing pdf file using python (and matplotlib?) | 38,118,510 | <p>I would like to append pages to an existing pdf file.</p>
<p>Currently, I am using matplotlib pdfpages. however, once the file is closed, saving another figure into it overwrites the existing file rather than appending.</p>
<pre><code>from matplotlib.backends.backend_pdf import PdfPages
import matplotlib.pyplot as... | 2 | 2016-06-30T09:04:59Z | 38,128,675 | <p>You may want to use <a href="https://github.com/mstamy2/PyPDF2/" rel="nofollow">pyPdf</a> for this. </p>
<pre><code># Merge two PDFs
from pyPdf import PdfFileReader, PdfFileWriter
output = PdfFileWriter()
pdfOne = PdfFileReader(file( "some\path\to\a\PDf", "rb"))
pdfTwo = PdfFileReader(file("some\other\path\to\a\P... | 1 | 2016-06-30T16:25:08Z | [
"python",
"pdf",
"matplotlib"
] |
append page to existing pdf file using python (and matplotlib?) | 38,118,510 | <p>I would like to append pages to an existing pdf file.</p>
<p>Currently, I am using matplotlib pdfpages. however, once the file is closed, saving another figure into it overwrites the existing file rather than appending.</p>
<pre><code>from matplotlib.backends.backend_pdf import PdfPages
import matplotlib.pyplot as... | 2 | 2016-06-30T09:04:59Z | 39,670,750 | <p>I searched around for a while but could not find a way to append to the same pdf file after re-opening it elsewhere in the program. I ended up using dictionaries, that way I can store the figures to the dictionary for each pdf I'm interested in creating and write them to pdfs at the end. Here is an example:</p>
<pr... | 1 | 2016-09-23T23:05:54Z | [
"python",
"pdf",
"matplotlib"
] |
Python 3 - Calculate average & write to .csv | 38,118,526 | <p><strong>(A) Python code</strong></p>
<pre><code>import csv
from collections import defaultdict
data = defaultdict(str)
#Make a list with the predefined variables
definition = ["record_id", "abbreviation", "patient_id", "study_id",
"step_count", "distance", "ambulation_time", "velocity", "cadence",
"normalized_vel... | 0 | 2016-06-30T09:05:33Z | 38,118,739 | <p>Try this:</p>
<pre><code>if h in r0:
try:
avg = round((float(row[1].replace(',', '.').replace(';', '.')) + float(row[2].replace(',', '.').replace(';', '.'))) / 2, 2)
data[item] = avg
except ValueError:
data[item] = 0 # for cases with entry strings or commas
#print(avg)
... | 0 | 2016-06-30T09:15:37Z | [
"python",
"csv",
"average"
] |
Python 3 - Calculate average & write to .csv | 38,118,526 | <p><strong>(A) Python code</strong></p>
<pre><code>import csv
from collections import defaultdict
data = defaultdict(str)
#Make a list with the predefined variables
definition = ["record_id", "abbreviation", "patient_id", "study_id",
"step_count", "distance", "ambulation_time", "velocity", "cadence",
"normalized_vel... | 0 | 2016-06-30T09:05:33Z | 38,118,924 | <p>You are calculating the average but not adding it into the csv file that the first problem you are facing- of what I understood from your ambiguous question.
First add another column in the list <code>definition</code> and add the key named <code>average</code> into the dict <code>data</code>, here's the modified c... | 0 | 2016-06-30T09:23:29Z | [
"python",
"csv",
"average"
] |
Python 3 - Calculate average & write to .csv | 38,118,526 | <p><strong>(A) Python code</strong></p>
<pre><code>import csv
from collections import defaultdict
data = defaultdict(str)
#Make a list with the predefined variables
definition = ["record_id", "abbreviation", "patient_id", "study_id",
"step_count", "distance", "ambulation_time", "velocity", "cadence",
"normalized_vel... | 0 | 2016-06-30T09:05:33Z | 38,120,251 | <p>I will try to explain it in a better way. I would like the result.csv to eventually output the following: </p>
<p><strong>Desired output</strong></p>
<pre><code>record_id abbreviation patient_id study_id step_count distance ambulation_time velocity cadence normalized_velocity step_time_differential step... | 0 | 2016-06-30T10:18:46Z | [
"python",
"csv",
"average"
] |
some random error in python dictionary | 38,118,560 | <p>I get some random error while printing results from python dictionary</p>
<p>code</p>
<pre><code>response_str = {'personal_emails': [{'email_address': 'hi'}]}
email_f = []
email_s = []
email_h = []
email_s = response_str["personal_emails"]
#print response_str
#print email_s
for email_1 in email_s:
print ema... | 1 | 2016-06-30T09:07:31Z | 38,118,946 | <p>The problem here is because of this line:</p>
<pre><code>email_s.append(email_1["email_address"])
</code></pre>
<p>This is the list the iterator runs on, and during the iterations you change it.</p>
<p>when I ran this code after comment that line out it ran smoothly.<br></p>
<p>So, my suggestion is you use anoth... | 2 | 2016-06-30T09:24:25Z | [
"python",
"dictionary"
] |
3D animation using matplotlib | 38,118,598 | <p>I want to make 3D animation with matplotlib, but I don't know how to. Here is my non-working code.</p>
<pre><code>from matplotlib import pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import animation
from math import *
fig = plt.figure()
ax = fig.add_subplot(111) #, proje... | 0 | 2016-06-30T09:08:53Z | 38,121,759 | <p>I used this example <a href="http://matplotlib.org/1.4.1/examples/animation/simple_3danim.html" rel="nofollow">http://matplotlib.org/1.4.1/examples/animation/simple_3danim.html</a>
and modified your code:</p>
<pre><code>from matplotlib import pyplot as plt
import numpy as np
import mpl_toolkits.mplot3d.axes3d as p3... | 0 | 2016-06-30T11:26:26Z | [
"python",
"animation",
"matplotlib",
"3d"
] |
Replacing a column with a function of itself in Pandas? | 38,118,675 | <p>I'm currently lost deep inside the pandas documentation. My problem is this:</p>
<p>I have a simple dataframe </p>
<pre><code>col1 col2
1 A
4 B
5 X
</code></pre>
<p>My aim is to apply something like:</p>
<pre><code> df['col1'] = df['col1'].apply(square)
</code></pre>
<p>where square is a cle... | 1 | 2016-06-30T09:12:25Z | 38,118,728 | <p>it works properly for me (pandas 0.18.1):</p>
<pre><code>In [31]: def square(x):
....: return x ** 2
....:
In [33]: df
Out[33]:
col1 col2
0 1 A
1 4 B
2 5 X
In [35]: df.col1 = df.col1.apply(square)
In [36]: df
Out[36]:
col1 col2
0 1 A
1 16 B
2 25 X
</code></... | 1 | 2016-06-30T09:15:04Z | [
"python",
"python-2.7",
"pandas"
] |
In sublime3, how to override Anaconda plugin settings for current project? | 38,118,679 | <p>I use sublime 3 for python coding, with plugin Anaconda for format checking. But when I read others' codes, I don't need this function, because the whole file is full of format error which I don't care about but the Anaconda lint bothers me. So I would like close the function for this "project" (not current file), w... | 0 | 2016-06-30T09:12:36Z | 38,119,596 | <p>You can control the state Anaconda linter using the <code>anaconda_linting</code> setting. </p>
<pre><code>"anaconda_linting": false
</code></pre>
<p>Working with <a href="https://www.sublimetext.com/docs/3/projects.html" rel="nofollow">projects</a> gives you more refined control where you want to use the linter a... | 2 | 2016-06-30T09:51:09Z | [
"python",
"sublimetext3",
"sublime-anaconda"
] |
How can I get the median of every three row-intervals for all columns? | 38,118,721 | <p>I have a huge dataset of 1600 rows and 13 columns, every three rows present data of a single person, while the columns are characteristics of this person.
I want to get the median of all columns for every person (3 rows).</p>
<p>For example, from this:</p>
<pre><code> C1 C2 C3 C4 C5...
R1 1 2 3 4 5
R2 6 7... | -2 | 2016-06-30T09:14:48Z | 38,118,950 | <p>In <code>R</code>, we create a grouping variable using <code>%/%</code> and then get the <code>median</code> of all the columns with <code>summarise_each</code></p>
<pre><code> library(dplyr)
df1 %>%
group_by(grp = ((row_number()-1)%/%3)+1) %>%
summarise_each(funs(median))
# grp C1 C2 C3... | 0 | 2016-06-30T09:24:42Z | [
"python"
] |
How can I get the median of every three row-intervals for all columns? | 38,118,721 | <p>I have a huge dataset of 1600 rows and 13 columns, every three rows present data of a single person, while the columns are characteristics of this person.
I want to get the median of all columns for every person (3 rows).</p>
<p>For example, from this:</p>
<pre><code> C1 C2 C3 C4 C5...
R1 1 2 3 4 5
R2 6 7... | -2 | 2016-06-30T09:14:48Z | 38,120,236 | <p>You can turn your data into an array and use <code>apply</code>:</p>
<pre><code>DF <- read.table(text = " C1 C2 C3 C4 C5
R1 1 2 3 4 5
R2 6 7 8 9 1
R3 2 3 4 5 6
R4 7 6 9 8 3
R5 3 4 6 2 5
... | 0 | 2016-06-30T10:17:47Z | [
"python"
] |
How can I get the median of every three row-intervals for all columns? | 38,118,721 | <p>I have a huge dataset of 1600 rows and 13 columns, every three rows present data of a single person, while the columns are characteristics of this person.
I want to get the median of all columns for every person (3 rows).</p>
<p>For example, from this:</p>
<pre><code> C1 C2 C3 C4 C5...
R1 1 2 3 4 5
R2 6 7... | -2 | 2016-06-30T09:14:48Z | 38,120,393 | <p>Here's my attempt. It evaluates the median value for every three sublists.
The median is taken doing the sum of the elements taken from a zip of the unpacked sublist.</p>
<pre><code>t =[[1, 2, 3, 4, 5], [6, 7, 8, 9, 1], ......
median = lambda subl: list(map(lambda n: sum(n)/len(subl), zip(*subl)))
for i in range(... | 0 | 2016-06-30T10:24:50Z | [
"python"
] |
Python Flask Swagger Flasgger Download Excel | 38,118,900 | <p>I am trying to return an excel file from Swagger API. Built that using Flask with a Swagger wrapper with Flasgger. Here's the code - </p>
<pre><code>@app.route('/cluster', methods=['POST'])
def index():
"""
This API will help you generate clusters based on keywords present in unstructured text
Call this... | 0 | 2016-06-30T09:22:46Z | 38,123,944 | <p>Did you try to change the mimetype?</p>
<p>I think that the traditional mimetype for excel is <code>application/vnd.ms-excel</code></p>
<p>You could find more details on microsoft files mimetype here: <a href="http://stackoverflow.com/questions/4212861/what-is-a-correct-mime-type-for-docx-pptx-etc">What is a corre... | 0 | 2016-06-30T13:02:10Z | [
"python",
"flask",
"swagger",
"xlsx"
] |
Use hard drive instead of RAM in Python | 38,118,942 | <p>I'd like to know if there's a method or a Python Package that can make me use a large dataset without writing it in RAM.</p>
<p>I'm also using pandas for statistical function.</p>
<p>I need to have access on the entire dataset because many statistical functions needs the entire dataset to return credible results.<... | 1 | 2016-06-30T09:24:16Z | 38,119,151 | <p>You could alternatively use <a href="https://dato.com/learn/gallery/notebooks/introduction_to_sframes.html" rel="nofollow">Sframes</a>, <a href="http://dask.pydata.org/en/latest/" rel="nofollow">Dask</a> for large dataset support or alternatively use pandas and read/iterate in chunks in order to minimise RAM usage.
... | 1 | 2016-06-30T09:33:40Z | [
"python",
"pandas",
"memory",
"pydev"
] |
Use hard drive instead of RAM in Python | 38,118,942 | <p>I'd like to know if there's a method or a Python Package that can make me use a large dataset without writing it in RAM.</p>
<p>I'm also using pandas for statistical function.</p>
<p>I need to have access on the entire dataset because many statistical functions needs the entire dataset to return credible results.<... | 1 | 2016-06-30T09:24:16Z | 38,119,245 | <p>If all you need is a virtualization of the disk as a large RAM memory you might set up a swap file on the system. The kernel will then automatically swap pages in and out as needed, using heuristics to figure out what pages should be swapped and which should stay on disk.</p>
| 0 | 2016-06-30T09:37:03Z | [
"python",
"pandas",
"memory",
"pydev"
] |
Pandas dataframe: Is there a difference in performance in replacing values by column and row? | 38,118,999 | <p>I have the following pandas DataFrame:</p>
<pre><code>import pandas as pd
df = pd.read_csv('filename.csv')
print(df)
dog A B C
0 dog1 0.787575 0.159330 0.053095
1 dog10 0.770698 0.169487 0.059815
2 dog11 0.792689 0.152043 0.055268
3 dog12 0.785066 ... | 1 | 2016-06-30T09:27:10Z | 38,119,057 | <p>You can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ix.html" rel="nofollow"><code>ix</code></a> or <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.loc.html" rel="nofollow"><code>loc</code></a> if want select by column name:</p>
<pre><code>df.ix... | 1 | 2016-06-30T09:29:06Z | [
"python",
"performance",
"pandas",
"indexing",
"dataframe"
] |
Odoo 8 Fields different models | 38,119,058 | <p>I currently struggle with fields in odoo. I'm pretty new to odoo so it would be very nice to have an overview over the whole fields/inheritance stuff. Just picture the following scenario: Module A has some fields that I'd like to display in Module B. For that purpose I'm developing Module C.</p>
<p>How can I read a... | 0 | 2016-06-30T09:29:09Z | 38,123,726 | <p>Your requirements are not very clear.</p>
<p>However, let's say that in Module A there's a class called classA.
In Module B there's a class called classB.
You want to show the fields of classA in classB, then you need some connection between them.</p>
<p>In your module C, create a class called classC in which you ... | 1 | 2016-06-30T12:53:44Z | [
"python",
"openerp",
"odoo-8"
] |
Cannot get Marionette example code to run on Python + Selenium | 38,119,166 | <p>so unfortunately <code>Webdriver</code> doesn't work anymore with Firefox 47+, so I was looking into switching to <code>Marionette</code>.</p>
<p>I've been following the instruction <a href="https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver" rel="nofollow">on this page</a></p>
<p>Unfortunate... | 1 | 2016-06-30T09:34:16Z | 38,131,129 | <p>You need to download the <a href="https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver#Setting_up_the_Marionette_executable" rel="nofollow">Marionette executable as well</a>.
<a href="https://github.com/mozilla/geckodriver/releases" rel="nofollow">https://github.com/mozilla/geckodriver/releases</... | 0 | 2016-06-30T18:52:15Z | [
"python",
"selenium",
"firefox-marionette"
] |
Cannot get Marionette example code to run on Python + Selenium | 38,119,166 | <p>so unfortunately <code>Webdriver</code> doesn't work anymore with Firefox 47+, so I was looking into switching to <code>Marionette</code>.</p>
<p>I've been following the instruction <a href="https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver" rel="nofollow">on this page</a></p>
<p>Unfortunate... | 1 | 2016-06-30T09:34:16Z | 38,131,395 | <p>Current version of Firefox doesn't work with <code>selenium webdriver</code>. Why you are not trying to install earlier version of Firefox. </p>
<p>Firefox 47.0 works fine for me. You can download it from <a href="https://ftp.mozilla.org/pub/firefox/releases/47.0/" rel="nofollow">Firefox FTP</a></p>
<p>You can try... | 0 | 2016-06-30T19:07:00Z | [
"python",
"selenium",
"firefox-marionette"
] |
How to Subtract the result of two Django Queries? | 38,119,532 | <p>in my View.py</p>
<pre><code>def reset(request):
Result = [(Contact.objects.all().count()] - [(Subscriber.objects.all().count()]
return HttpResponse(Result)
</code></pre>
<p>I want to Subtract these two queries,but it did not work.....</p>
| -1 | 2016-06-30T09:48:23Z | 38,119,631 | <p>You can do by this way :</p>
<pre><code> Contact.objects.all().count() - Subscriber.objects.all().count()
</code></pre>
<p>now you can easily <code>subtract</code> . i have edited the code. Please have a look </p>
| 0 | 2016-06-30T09:52:41Z | [
"python",
"django"
] |
How to get information entered by the user using simple html login page in django view? | 38,119,541 | <p>I have a simple login page returned by a django view. I need to get the information entered into the username and password boxes by the user. How can I get it without using forms in Django? </p>
<p>here is my view:</p>
<pre><code> def index(request):
html="""<html>
<title>Login</title&... | -1 | 2016-06-30T09:48:54Z | 38,119,758 | <p>You can get POST parameters doing:</p>
<pre><code>if request.method == 'POST':
userid = request.POST.get('text1' ,'')
</code></pre>
<p>Where the second string is the value if the parameter does not exist.</p>
| 0 | 2016-06-30T09:57:01Z | [
"python",
"django"
] |
getting back key:subkey pair sorted on subkey of subkey of key. python | 38,119,543 | <p>I have a JSON file </p>
<pre><code> {
"b0:47:bf:af:c1:42":
{
"No. of visits": 10, "cities":
{
"Mumbai": {"count": 5,"last_visited": "5/22/2016"},
"Kolkata": {"count": 2,"last_visited": "5/22/2016"},
"Amritsar":{"count": 3,"last_visited": "5/22/2016"}
}
},
"c0:ee:fb:71:be:0d":
{
"N... | 1 | 2016-06-30T09:48:56Z | 38,125,239 | <p>Here you go, That's whatever I understood from the question, specifics? Ask!</p>
<pre><code>>>> with open('file.txt', 'r') as f:
... json_ = json.load(f)
>>> formatted_ = [[key, 'cities', city, value['cities'][city]['count']] for key, value in json_.items() for city in value['cities']]
>>... | 2 | 2016-06-30T13:54:16Z | [
"python",
"python-2.7",
"dictionary"
] |
Python pandas loop that deletes csv rows until a string appears | 38,119,656 | <p>I'm having trouble to create a code that reads a .csv file row by row and keep deleting the rows until it finds a certain string.
For instance, I want to keep only the rows after "AH":</p>
<pre><code>SG 1 2 3
OH 3 3 UI
AH 4 5 5
R3 4 4 4
</code></pre>
<p>The code should return only:</p>
<pre><code>R3 4 4 4
</co... | 0 | 2016-06-30T09:53:31Z | 38,119,982 | <p>What exactly you mean by deleting the rows, or did you mean ignoring the rows.
This might work for you:</p>
<pre><code>import csv
def return_required_row(filename_to_read, filename_to_write ,keyword):
with open(filename_to_read, 'r') as fin, open(filename_to_write, 'w') as fout:
reader = csv.reader(... | 0 | 2016-06-30T10:06:15Z | [
"python",
"csv",
"pandas"
] |
Python pandas loop that deletes csv rows until a string appears | 38,119,656 | <p>I'm having trouble to create a code that reads a .csv file row by row and keep deleting the rows until it finds a certain string.
For instance, I want to keep only the rows after "AH":</p>
<pre><code>SG 1 2 3
OH 3 3 UI
AH 4 5 5
R3 4 4 4
</code></pre>
<p>The code should return only:</p>
<pre><code>R3 4 4 4
</co... | 0 | 2016-06-30T09:53:31Z | 38,121,967 | <p>You can first convert to string by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.astype.html" rel="nofollow"><code>astype</code></a> and compare. Then
with <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.cumsum.html" rel="nofollow"><code>cumsum</code... | 0 | 2016-06-30T11:36:11Z | [
"python",
"csv",
"pandas"
] |
pandas caculate the np.var() for each column | 38,119,668 | <p>how to caculate the np.var() for each column , if the np.var()<0.1, then remove the column. </p>
<pre><code>Id F M R
7 1 286 907
12 1 286 907
17 1 186 1271
21 1 296 905
30 1 308 908
32 1 267 905
40 2 591 788
41 1 486 874
47 1 686 906
74 1 230 907
</code></pre>
| 1 | 2016-06-30T09:53:54Z | 38,119,852 | <p>try this:</p>
<pre><code>In [62]: df[df.columns[(df.var(ddof=0) >= 1.0)]]
Out[62]:
Id M R
0 7 286 907
1 12 286 907
2 17 186 1271
3 21 296 905
4 30 308 908
5 32 267 905
6 40 591 788
7 41 486 874
8 47 686 906
9 74 230 907
</code></pre>
<p>Explanation:</p>
<pre><c... | 1 | 2016-06-30T10:01:05Z | [
"python",
"pandas"
] |
Passing python list oracle where clause cx_Oracle | 38,119,700 | <h1>-<em>- coding: utf-8 -</em>-</h1>
<pre><code>from __future__ import unicode_literals
</code></pre>
<p>'''Hi everybody,
I'm frustrated trying to pass oracle where clause a python list , I'm using cx_Oralce here my code:'''
import cx_Oracle</p>
<pre><code>con = cx_Oracle.connect(str('user/passwordr@server/... | 0 | 2016-06-30T09:55:10Z | 38,154,606 | <p>After hours trying to figure out how to do it , finally i get the solution. here is the code:</p>
<pre><code># -*- coding: utf-8 -*-
#from __future__ import unicode_literals
import cx_Oracle
con = cx_Oracle.connect(str('user/pass@server/orcl'))
cursor = con.cursor()
cursor.execute(str('select employee_id from emp... | 0 | 2016-07-01T22:30:16Z | [
"python",
"oracle",
"list",
"module"
] |
Convert a JSON bytes object | 38,119,794 | <p>I'm making an API in Python and it throws me something like this. I already tried with BeautifulSoup and it didn't accept it (neither as bytes nor converted into a string). What can I do?</p>
<pre><code>b'[{"cc_emails":["ccc@yyy.com"],"fwd_emails":[],"reply_cc_emails":["ccc@yyy.com"],"fr_escalated":false,"spam":fal... | -2 | 2016-06-30T09:58:34Z | 38,121,351 | <p>The bytes object needs to be decoded to a string:</p>
<pre><code>content = codecs.decode(r.content,'utf-8')
jcontent = json.loads(content)
</code></pre>
| 0 | 2016-06-30T11:07:09Z | [
"python"
] |
nested for loop, set variable and if else in a batch script | 38,119,808 | <p>I am trying to make a batch script which will write specific IP addresses in a file.
I have a txt file (created by one python script) having a list of IP addresses (one in each new-line), Now I need to ping each of these IPs using for loop, check if the TTL value is between 100 to 128 (windows hosts) and write the I... | 1 | 2016-06-30T09:59:07Z | 38,120,645 | <p>This will do what you are asking. Modify as needed when you migrate to your first example.</p>
<pre><code>for /f "tokens=6 delims= " %a in ('ping -n 1 4.2.2.2 ^| find "TTL"') do for /f "tokens=2 delims==" %b in ('echo.%a') do echo %b
</code></pre>
<p>BTW, the first FOR loop in your post is incomplete. I think you ... | 1 | 2016-06-30T10:35:51Z | [
"python",
"windows",
"batch-file",
"vbscript",
"cmd"
] |
nested for loop, set variable and if else in a batch script | 38,119,808 | <p>I am trying to make a batch script which will write specific IP addresses in a file.
I have a txt file (created by one python script) having a list of IP addresses (one in each new-line), Now I need to ping each of these IPs using for loop, check if the TTL value is between 100 to 128 (windows hosts) and write the I... | 1 | 2016-06-30T09:59:07Z | 38,125,679 | <p>In vbscript you can do something like this :</p>
<pre><code>strHost = "4.2.2.2"
if Ping(strHost) = True then
Wscript.Echo "Host " & strHost & " contacted"
Else
Wscript.Echo "Host " & strHost & " could not be contacted"
end if
'*****************************************************************... | 1 | 2016-06-30T14:10:39Z | [
"python",
"windows",
"batch-file",
"vbscript",
"cmd"
] |
nested for loop, set variable and if else in a batch script | 38,119,808 | <p>I am trying to make a batch script which will write specific IP addresses in a file.
I have a txt file (created by one python script) having a list of IP addresses (one in each new-line), Now I need to ping each of these IPs using for loop, check if the TTL value is between 100 to 128 (windows hosts) and write the I... | 1 | 2016-06-30T09:59:07Z | 38,130,137 | <p>So, my answer seems to turn to a somewhat different one than I was seeking. It is in python 2.x I just finished writing. Although it is not very sophisticated and stealth in terms of execution (pops up lots of CMD windows and writes to files and then reads to form the result). But still got the job done. I guess I'l... | 1 | 2016-06-30T17:52:14Z | [
"python",
"windows",
"batch-file",
"vbscript",
"cmd"
] |
nested for loop, set variable and if else in a batch script | 38,119,808 | <p>I am trying to make a batch script which will write specific IP addresses in a file.
I have a txt file (created by one python script) having a list of IP addresses (one in each new-line), Now I need to ping each of these IPs using for loop, check if the TTL value is between 100 to 128 (windows hosts) and write the I... | 1 | 2016-06-30T09:59:07Z | 38,131,289 | <p>Give a try for this batch file to get the <code>TTL</code> value in the same line having IP address</p>
<pre><code>@echo off
Title Get TTL from IP adress
set vbsfile=%Tmp%\%~n0.vbs
set IP_File=E:\vb-ping\ip.txt
set LogFile=Log.txt
If Exist %LogFile% Del %LogFile%
For /f %%a in ('Type %IP_File%') Do (
Call:VBS... | 1 | 2016-06-30T19:01:31Z | [
"python",
"windows",
"batch-file",
"vbscript",
"cmd"
] |
nested for loop, set variable and if else in a batch script | 38,119,808 | <p>I am trying to make a batch script which will write specific IP addresses in a file.
I have a txt file (created by one python script) having a list of IP addresses (one in each new-line), Now I need to ping each of these IPs using for loop, check if the TTL value is between 100 to 128 (windows hosts) and write the I... | 1 | 2016-06-30T09:59:07Z | 38,279,036 | <p>So, I created the full scanning script for all the Windows clients which are not a part of my Org's Domain. It's been enough long time, but I thought to post it here.<br><br>
This script relies on initial client's scan with ping-sweep of <strong>nmap</strong>. Since creating script using <strong>multiprocessing</str... | 0 | 2016-07-09T06:25:07Z | [
"python",
"windows",
"batch-file",
"vbscript",
"cmd"
] |
Python: How to search a build file for a specific string and replace it with a user input string | 38,119,861 | <p>I have searched a text file mobileBuildSettings for specific strings determined by user input and I have copied those strings. This piece of code works perfectly fine I have tested it.</p>
<p>My problem is as follows:
I then try to search a build file called abproject for @AppIdentifier@ and replace it with a strin... | 0 | 2016-06-30T10:01:24Z | 38,120,412 | <p>I had to do the same thing a few days ago, here is my solution :</p>
<ol>
<li>Open the file</li>
<li>Parse it line by line and replace the string you want to rplace</li>
<li>Store every line in a temp file</li>
<li>When you're done, delete the old file and rename the temp file as the new file</li>
</ol>
<p>Here is... | 0 | 2016-06-30T10:25:24Z | [
"python",
"search",
"replace"
] |
Django: Strategies for tracking and displaying users data | 38,119,874 | <h1>Details</h1>
<p>I have made my custom authentication process for the users, (no, i didn't use django's dedicated authentication), I almost finished it, but still having concerns on the most important part at the time.</p>
<p>so these are main parts of authentication process:</p>
<ol>
<li>User sign's into the web... | 0 | 2016-06-30T10:01:52Z | 38,120,157 | <p>The canonical solution is to use <a href="https://docs.djangoproject.com/en/1.9/topics/http/sessions/" rel="nofollow">sessions</a>. FWIW note that all of your problems are already solved in Django's <code>contrib.auth</code> app, taking care of a whole lot of known security issues.</p>
| 1 | 2016-06-30T10:14:18Z | [
"python",
"django",
"authentication"
] |
Django: Strategies for tracking and displaying users data | 38,119,874 | <h1>Details</h1>
<p>I have made my custom authentication process for the users, (no, i didn't use django's dedicated authentication), I almost finished it, but still having concerns on the most important part at the time.</p>
<p>so these are main parts of authentication process:</p>
<ol>
<li>User sign's into the web... | 0 | 2016-06-30T10:01:52Z | 38,123,491 | <p>Writing your own auth system is a nice way to learn all the details of how it works, but you must be careful to not introduce security issues. The Django auth framework has been working for 10 years or so, so it can be trusted to do the right thing.</p>
<p>Bruno's answer is right: you should use sessions. Sessions ... | 2 | 2016-06-30T12:44:21Z | [
"python",
"django",
"authentication"
] |
django, entering a hashed password in registration and storing it as such | 38,119,929 | <p>I am working on openedx(works on django) and i need to create an api to register the user coming from a particular site, i am being given a hashed password not a normal one and i need to save it as so.</p>
<p>The problem here is that the openedx's registration function hashes the password that is being passed into ... | 0 | 2016-06-30T10:04:25Z | 38,124,108 | <p>I would suggest to override method set <code>set_password</code> in user_model.</p>
<pre><code>class MyUser(AbstractBaseUser):
# if you need to hash passwords for some users.
is_password_hashed = models.BooleanField(default=True)
...
def set_password(self, raw_password):
if self.is_password... | 1 | 2016-06-30T13:08:47Z | [
"python",
"django",
"rest",
"django-rest-framework",
"openedx"
] |
django, entering a hashed password in registration and storing it as such | 38,119,929 | <p>I am working on openedx(works on django) and i need to create an api to register the user coming from a particular site, i am being given a hashed password not a normal one and i need to save it as so.</p>
<p>The problem here is that the openedx's registration function hashes the password that is being passed into ... | 0 | 2016-06-30T10:04:25Z | 38,178,925 | <p>It's as simple as:</p>
<pre><code>from django.contrib.auth.models import User
User.objects.filter(username="myuser").update(password=hashed_password)
</code></pre>
<p>(remember passwords are stored as hashed values in the database)</p>
| 1 | 2016-07-04T07:19:41Z | [
"python",
"django",
"rest",
"django-rest-framework",
"openedx"
] |
django, entering a hashed password in registration and storing it as such | 38,119,929 | <p>I am working on openedx(works on django) and i need to create an api to register the user coming from a particular site, i am being given a hashed password not a normal one and i need to save it as so.</p>
<p>The problem here is that the openedx's registration function hashes the password that is being passed into ... | 0 | 2016-06-30T10:04:25Z | 38,754,547 | <p>The Open edX <code>manage_user</code> management command <a href="https://github.com/edx/edx-platform/pull/13124" rel="nofollow">was recently updated</a> to support this use case when creating a new user.</p>
<p>Example:</p>
<p><code>./manage.py lms --settings=devstack manage_user jane jane@example.com --initial-p... | 0 | 2016-08-03T22:15:40Z | [
"python",
"django",
"rest",
"django-rest-framework",
"openedx"
] |
Tokenizing words into a new column in a pandas dataframe | 38,119,954 | <p>I am trying to go through a list of comments collected on a pandas dataframe and tokenize those words and put those words in a new column in the dataframe but I have having an error running through this, is </p>
<p>The error is stating that AttributeError: 'unicode' object has no attribute 'apwords'</p>
<p>Is ther... | 0 | 2016-06-30T10:05:17Z | 38,120,242 | <p>Don't you just want to do this:</p>
<pre><code> df['words'] = df['complaint'].apply(apwords)
</code></pre>
<p>you don't need to define the function <code>addwords</code>. Which should be defined as:</p>
<pre><code>addwords = lambda x: apwords(x)
</code></pre>
| 0 | 2016-06-30T10:18:20Z | [
"python",
"pandas",
"dataframe",
"nltk"
] |
Tokenizing words into a new column in a pandas dataframe | 38,119,954 | <p>I am trying to go through a list of comments collected on a pandas dataframe and tokenize those words and put those words in a new column in the dataframe but I have having an error running through this, is </p>
<p>The error is stating that AttributeError: 'unicode' object has no attribute 'apwords'</p>
<p>Is ther... | 0 | 2016-06-30T10:05:17Z | 38,121,437 | <p>Your way to apply the <code>lambda</code> function is correct, it is the way you define <code>addwords</code> that doesn't work.</p>
<p>When you define <code>apwords</code> you define a <code>function</code> not an <code>attribute</code> therefore when you want to apply it, use:</p>
<pre><code>addwords = lambda x:... | 0 | 2016-06-30T11:11:44Z | [
"python",
"pandas",
"dataframe",
"nltk"
] |
Anaconda & Tensorflow & Skflow: dnn() got an unexpected keyword argument 'keep_prob' | 38,120,008 | <p>When running this example in Anaconda 2.7:</p>
<pre><code>import tensorflow.contrib.learn as skflow
def DNN_model(X, y):
"""This is DNN with 50, 20, 10 hidden layers, and dropout of 0.5 probability."""
layers = skflow.ops.dnn(X, [50, 30, 10], keep_prob=0.5)
return skflow.models.logistic_regression(layer... | 1 | 2016-06-30T10:07:07Z | 38,120,728 | <p>According to the <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/learn/python/learn/ops/dnn_ops.py" rel="nofollow">repository</a> it seems this version is depreciated:</p>
<p><code>learn.ops.dnn is deprecated,please use contrib.layers.dnn.</code></p>
<p>However, different arguments... | 2 | 2016-06-30T10:40:16Z | [
"python",
"tensorflow",
"anaconda"
] |
PySpark: how to map by first item in array | 38,120,019 | <p>My initial RDD is a list of blocks in which each block is a list of lines itself. So it's</p>
<blockquote>
<p>[infos_var1, infos_var2]</p>
</blockquote>
<p>and each block is </p>
<blockquote>
<p>var_name, var_value1, var_value2, var_value3 </p>
</blockquote>
<p>The original data looks like this:</p>
<pre><c... | 0 | 2016-06-30T10:08:00Z | 38,122,728 | <p>What you have is a list of list of items and not tuple</p>
<p>Try this:</p>
<pre><code>df.map(lambda i : (i[0], i[1:]))
</code></pre>
<p>For the <code>i[1:]</code> part , look up for slicing in <a href="https://docs.python.org/2/tutorial/introduction.html" rel="nofollow">here</a></p>
| 1 | 2016-06-30T12:11:04Z | [
"python",
"apache-spark",
"mapreduce",
"pyspark"
] |
crawling web data using python html error | 38,120,180 | <p>i want to crawling data using python
i tried tried again
but it didn't work
i can not found code's error
i wrote code like this:</p>
<pre><code>import re
import requests
from bs4 import BeautifulSoup
url='http://news.naver.com/main/ranking/read.nhn?mid=etc&sid1=111&rankingType=popular_week&oid=277&am... | 0 | 2016-06-30T10:15:17Z | 38,120,423 | <p>Requests will fetch the URL's contents, but will not execute any JavaScript. </p>
<p>I performed the same fetch with cURL, and I can't find any occurrence of <code>u_cbox_contents</code> in the HTML code. Most likely, it's injected using JavaScript, which explains why BeautifulSoup can't find it.</p>
<p>If you nee... | 1 | 2016-06-30T10:26:07Z | [
"python",
"web",
"beautifulsoup",
"web-crawler"
] |
Elegant pair wise scalar product of many vectors in numpy | 38,120,381 | <p>I have 2 sets of <code>n*m</code> vectors <code>x_ij</code> and <code>y_ij</code> of dimension <code>d</code> stored in two <code>np.ndarray</code> <code>X</code> and <code>Y</code> of shape <code>n*m*d</code>.
I want to get the <code>n*m</code> matrix of scalar products <code>x_ij.y_ij</code>.
At the moment I do th... | 1 | 2016-06-30T10:24:23Z | 38,120,595 | <p>Well, you are keeping the first two axes aligned and sum-reducing the last axes on both inputs. For such a case, one efficient way to solve it would be with <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html" rel="nofollow"><code>np.einsum</code></a>, like so -</p>
<pre><code>np.einsum('... | 1 | 2016-06-30T10:33:39Z | [
"python",
"numpy"
] |
Canvas not loading Python 3.5.2 | 38,120,383 | <p>Python code:</p>
<pre><code>from tkinter import *
window = Tk()
c = Canvas(window, width=500, height=800, bg='red')
c.pack()
</code></pre>
<p>But when I run this code the canvas doesn't open </p>
<p>and There is no errors</p>
<p>Why doesn't it work?</p>
| -7 | 2016-06-30T10:24:27Z | 38,120,416 | <p>You have to actually start the main event loop. Add <code>window.mainloop()</code> to the end of that script.</p>
| 3 | 2016-06-30T10:25:48Z | [
"python",
"tkinter"
] |
pandas box plot for multiple column | 38,120,688 | <p>My data frames (pandas's structure) looks like above
<a href="http://i.stack.imgur.com/mzIbU.png" rel="nofollow"><img src="http://i.stack.imgur.com/mzIbU.png" alt="enter image description here"></a></p>
<p>Now I want to make boxplot for each feature on separate canvas. The separation condition is the first column. ... | 1 | 2016-06-30T10:38:11Z | 38,122,390 | <p><a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.boxplot.html" rel="nofollow"><code>DataFrame.boxplot()</code></a> automates this rather well:</p>
<pre><code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'is_true_seed': np.random.choice([Tr... | 2 | 2016-06-30T11:55:57Z | [
"python",
"pandas",
"boxplot"
] |
User is getting logged out after changing password | 38,120,743 | <p>I have a view that allows user to change password.I do not want to use default password authentication system.When a user changes his password,the password is successfully changed but the user is getting logged out.I saw that session is getting invalidated on password change.I do not want to login again after passwo... | 0 | 2016-06-30T10:40:49Z | 38,121,141 | <p>You should use variable u in update_session_auth_hash. You are using "user" from request, which still has the old password.</p>
| 1 | 2016-06-30T10:58:36Z | [
"python",
"django",
"django-views"
] |
How to make plt.savefig() save image for 'maximized' window instead of default size | 38,120,826 | <p>I know that this question have been raised previously but it didnt solve the problem. I am trying to plot graphs using subplots my problem is same as the question with similar title. I think instead of explaining in words I will show you what is happening and what I want. the first image is the plot I get when I run... | 0 | 2016-06-30T10:44:50Z | 38,122,478 | <p>I think your problem is the scaling of each plot or the figure size: <br>
<strong>For scaling:</strong>
You can try and change the axes scaling by:</p>
<pre><code>plt.axis([40, 160, 0.01, 0.1])
</code></pre>
<p><a href="http://matplotlib.org/users/pyplot_tutorial.html" rel="nofollow">Here</a> you can find a nice t... | 0 | 2016-06-30T11:59:38Z | [
"python",
"matplotlib",
"plot"
] |
How use django import-export and mptt. Django admin | 38,120,853 | <p>Django-Import-Export not imported file if I use django-mptt</p>
<p>model.py</p>
<pre><code>class Page(MPTTModel):
name = models.CharField(max_length=250)
parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True)
content = models.TextField(blank=True, null=True)
cla... | -1 | 2016-06-30T10:45:55Z | 38,139,074 | <p>Issue: <a href="https://github.com/django-import-export/django-import-export/issues/483" rel="nofollow">https://github.com/django-import-export/django-import-export/issues/483</a></p>
<p>You need remove itertools and sys from import_export/resources.py</p>
<p>Fix: <a href="https://github.com/django-import-export/d... | 0 | 2016-07-01T07:03:51Z | [
"python",
"django",
"django-mptt",
"mptt",
"django-import-export"
] |
Error when moving files | 38,120,907 | <p>I'm trying to write a code that moves files in my download folder to other specified folders but I keep getting errors. Here's my code.</p>
<pre><code>import os
import shutil
series = []
for i in os.listdir('C:\\Users\\Mike\\Downloads\\Video'):
if ('.mp4') in i:
series.append(i)
for j in series:
if... | 1 | 2016-06-30T10:48:18Z | 38,122,632 | <p>The error you get is Windows platform specific. You are using <code>shutil.move</code> which uses <code>os.rename</code> under the hood. From <a href="https://docs.python.org/2/library/os.html#os.rename" rel="nofollow">docs</a>:</p>
<blockquote>
<p>On Windows, if dst already exists, OSError will be raised even if... | 1 | 2016-06-30T12:06:29Z | [
"python",
"file",
"python-3.x"
] |
Importing a large xml file to Neo4j with Py2neo | 38,121,022 | <p>I have a problem in importing <strong>a very big XML file</strong> with 36196662 lines. I am trying to create a <strong>Neo4j Graph Database</strong> of this XML file with <strong>Py2neo</strong> my xml file look like that:</p>
<p><a href="http://imgur.com/pLylHeG" rel="nofollow">http://imgur.com/pLylHeG</a></p>
<... | 0 | 2016-06-30T10:53:42Z | 38,128,897 | <p>If you are importing data into a new database you may want to try the import-tool: <a href="https://neo4j.com/docs/operations-manual/current/#import-tool" rel="nofollow">https://neo4j.com/docs/operations-manual/current/#import-tool</a></p>
<p>In that case you should parse your XML file as you already do but instead... | 0 | 2016-06-30T16:38:23Z | [
"python",
"xml",
"neo4j",
"xml-parsing",
"py2neo"
] |
Importing a large xml file to Neo4j with Py2neo | 38,121,022 | <p>I have a problem in importing <strong>a very big XML file</strong> with 36196662 lines. I am trying to create a <strong>Neo4j Graph Database</strong> of this XML file with <strong>Py2neo</strong> my xml file look like that:</p>
<p><a href="http://imgur.com/pLylHeG" rel="nofollow">http://imgur.com/pLylHeG</a></p>
<... | 0 | 2016-06-30T10:53:42Z | 38,214,236 | <p>I think you should use a streaming parser, otherwise it might be even on the python side that you overflow on memory.</p>
<p>Also I recommend doing transactions in Neo4j with batches of 10k to 100k updates per transaction.</p>
<p>Don't store <code>"NO xxxx"</code> fields, just leave them off it is just a waste of ... | 0 | 2016-07-05T23:11:24Z | [
"python",
"xml",
"neo4j",
"xml-parsing",
"py2neo"
] |
Multiple matches on split-string | 38,121,082 | <p>I'm using the split()-function on an hexlified string in Python. This string is containing a marker (0xffffffffffffffff) which I want to split out. After this marker there is hexadecimal data. There can be multiple "markers" in the hexlified string.</p>
<p>Now I found out that there is a problem when my first data-... | 2 | 2016-06-30T10:55:40Z | 38,121,643 | <p>You could do it in two steps: First, group the digits into pairs, then split by 8 groups of <code>ff</code>:</p>
<pre><code>>>> a = "0a0b0c0d0e0fffffffffffffffff0a0b0c"
>>> b = re.sub(r"(?<=\w{2})(\w{2})", r" \1", a)
>>> re.split(r"(?:ff ){8}", b)
['0a 0b 0c 0d 0e 0f ', '0a 0b 0c']
</c... | 1 | 2016-06-30T11:20:53Z | [
"python",
"regex",
"string",
"split"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.