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 |
|---|---|---|---|---|---|---|---|---|---|
Different image sizes in tensorflow with batch_size =1 | 38,966,533 | <p>I want to achieve a python class,which can load a tensorflow model and implement a inference.but i have no idea about how can i input image with variable image size.:(</p>
<pre><code>class ArtGenerater():
def __init__(self,model_path):
self.model_path = model_path
# vary shape?
... | 0 | 2016-08-16T04:09:54Z | 38,968,615 | <p>Basically you can define a various size input using None as follows </p>
<pre><code>self.x = tf.placeholder(tf.float32, [None, 784])
</code></pre>
<p>and then you can feed different input</p>
<pre><code>feed_dict={self.x: current_data} etc..
</code></pre>
<p>But be careful about neural net structure, probably y... | 0 | 2016-08-16T07:08:53Z | [
"python",
"tensorflow"
] |
Python write() function not working | 38,966,576 | <pre><code>f = open('path.txt','w')
text = f.write('This is a test\n')
print(text)
</code></pre>
<p>This is supposed to write on the file path.txt "This is a test" but it doesn't.</p>
| -3 | 2016-08-16T04:16:18Z | 38,966,597 | <p>Try doing </p>
<pre><code>f.close()
</code></pre>
<p>and delete</p>
<pre><code>print(text)
</code></pre>
<p>Hope I helped. :)</p>
| 3 | 2016-08-16T04:19:32Z | [
"python",
"python-3.x"
] |
Python equivalent of R's rnbinom parametrized with mu | 38,966,622 | <p>R has a <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/NegBinomial.html" rel="nofollow">negative binomial function</a> that can be parameterized with <code>mu</code> rather than a probability (e.g., a float >= 0 and <=1). I am trying to replicate this distribution:</p>
<pre><code>rnbinom(1000,... | 1 | 2016-08-16T04:23:42Z | 38,967,045 | <p>Here are the parameters that you passed to <code>rnbinom</code>:</p>
<pre><code>In [131]: num_samples = 10000
In [132]: size = 0.3
In [133]: mu = 15
</code></pre>
<p>As explained in the R documentation that you linked to, you can compute the probability as follows:</p>
<pre><code>In [134]: prob = size/(size + m... | 3 | 2016-08-16T05:11:49Z | [
"python",
"numpy"
] |
URL Separation in Flask | 38,966,653 | <p>I am listening to a <code>Flask</code> URL of the form,</p>
<pre><code>http://example.com:8080/v1/api?param1=value1&param2=value2&param3=value3&param4=value4
</code></pre>
<p>Now, I want to achieve <code>URL</code> separation of the parameters in either of the below forms, (<strong>ForwardSlash</strong... | 1 | 2016-08-16T04:27:34Z | 38,966,749 | <p>Instead of passing all the values as query params, can you use form-post to achieve this? You can pass an object using this method and will give you more flexibility on the type of data-structure that you want to achieve. </p>
| 0 | 2016-08-16T04:39:07Z | [
"python",
"rest",
"url",
"flask",
"restful-url"
] |
Writing safe, enforced Python classes | 38,966,762 | <p>I am trying to implement a class with the best and safest conventions possible. Are there better ways to </p>
<p>a) prevent external edits to properties, and </p>
<p>b) enforce certain constraints, such as valid rank and suit, on these properties?</p>
<pre><code>class Card:
__ranks = ['Ace', '2', '3', '4', '... | 0 | 2016-08-16T04:40:01Z | 38,966,864 | <p>It's more common to control this type of behavior through the property decorator. You can essentially create a read-only attribute by not implementing a setter:</p>
<pre><code>class Foo:
def __init__(self, bar):
self._bar = bar
@property
def bar(self):
"""Read-only access to bar."""
re... | 0 | 2016-08-16T04:51:42Z | [
"python",
"class"
] |
Writing safe, enforced Python classes | 38,966,762 | <p>I am trying to implement a class with the best and safest conventions possible. Are there better ways to </p>
<p>a) prevent external edits to properties, and </p>
<p>b) enforce certain constraints, such as valid rank and suit, on these properties?</p>
<pre><code>class Card:
__ranks = ['Ace', '2', '3', '4', '... | 0 | 2016-08-16T04:40:01Z | 38,967,556 | <h1>Prevent external edits to properties</h1>
<p>Any attribute can be changed when you have a class instance. But you can follow convention that attributes started from single and double underscore is private and you should not access them directly unless you know what are you doing.</p>
<p>To provide public interfac... | 0 | 2016-08-16T05:58:47Z | [
"python",
"class"
] |
Writing safe, enforced Python classes | 38,966,762 | <p>I am trying to implement a class with the best and safest conventions possible. Are there better ways to </p>
<p>a) prevent external edits to properties, and </p>
<p>b) enforce certain constraints, such as valid rank and suit, on these properties?</p>
<pre><code>class Card:
__ranks = ['Ace', '2', '3', '4', '... | 0 | 2016-08-16T04:40:01Z | 38,973,074 | <p>You could use a named tuple, so that the object is immutable</p>
<pre><code>>>> from collections import namedtuple
>>> Card = namedtuple('Card','rank,suit')
>>> acard = Card('10','D')
>>> acard.suit
'D'
>>> acard.rank
'10'
>>> acard.rank='H'
Traceback (most rece... | 1 | 2016-08-16T10:56:53Z | [
"python",
"class"
] |
How to return correctly formatted pandas dataframe from apply? | 38,966,779 | <p>Say we have the following dataframe:</p>
<pre><code>import pandas as pd
import numpy as np
years = [2005, 2006]
location = ['city', 'suburb']
dft = pd.DataFrame({
'year': [years[np.random.randint(0, 1+1)] for _ in range(100)],
'location': [location[np.random.randint(0, 1+1)] for _ in range(100)],
'days... | 1 | 2016-08-16T04:42:10Z | 38,968,099 | <p>My solution is use same column names in function <code>get_custom_summary</code> in <code>gt_200</code> and <code>lt_200</code> and then rename it by function <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.lower.html" rel="nofollow"><code>str.lower</code></a> and add last custom col... | 1 | 2016-08-16T06:36:53Z | [
"python",
"pandas",
"dataframe",
"multiple-columns",
null
] |
How to return correctly formatted pandas dataframe from apply? | 38,966,779 | <p>Say we have the following dataframe:</p>
<pre><code>import pandas as pd
import numpy as np
years = [2005, 2006]
location = ['city', 'suburb']
dft = pd.DataFrame({
'year': [years[np.random.randint(0, 1+1)] for _ in range(100)],
'location': [location[np.random.randint(0, 1+1)] for _ in range(100)],
'days... | 1 | 2016-08-16T04:42:10Z | 38,987,486 | <p>Return a Dataframe with columns set equal to a MultiIndex.</p>
<pre><code>from collections import OrderedDict
def get_multi_index(ordered_dict):
length = len(list(ordered_dict.values())[0])
for k in ordered_dict:
assert(len(ordered_dict[k]) == length)
names = list()
arrays = list()
fo... | 0 | 2016-08-17T03:08:41Z | [
"python",
"pandas",
"dataframe",
"multiple-columns",
null
] |
It is possible to skip/fail test in setup using pytest? | 38,966,785 | <p>I am using pytest and hope to check: </p>
<p>Is it possible to conditionally skip/fail tests (grouped in class) in setup?</p>
| 0 | 2016-08-16T04:42:58Z | 38,971,509 | <p>You can call <code>pytest.skip(...)</code> and <code>pytest.fail(...)</code> there. See "<a href="http://doc.pytest.org/en/latest/skipping.html#imperative-xfail-from-within-a-test-or-setup-function" rel="nofollow">Imperative xfail from within a test or setup function</a>" in the docs.</p>
| 1 | 2016-08-16T09:41:22Z | [
"python",
"py.test"
] |
How to deal with this logic in pandas | 38,966,912 | <p>I have a data frame like following below.</p>
<pre><code> coutry flag
0 China red
1 Russia green
2 China yellow
3 Britain yellow
4 Russia green
......................
</code></pre>
<p>In df['country'], you can see many different country names. I want to set the first appear co... | 1 | 2016-08-16T04:57:46Z | 38,966,939 | <p>You can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.factorize.html" rel="nofollow"><code>factorize</code></a> and add <code>1</code>:</p>
<pre><code>df['coutry'] = pd.factorize(df.coutry)[0] + 1
df['flag'] = pd.factorize(df.flag)[0] + 1
print (df)
coutry flag
0 1 1
1 ... | 3 | 2016-08-16T05:00:21Z | [
"python",
"pandas",
"dataframe",
"categorical-data"
] |
Access to Google analytic management API | 38,967,004 | <p>I wish to use Google analytic management API and I have very basic problem that I am struggling with. For both Javascript and Python that I tried this <a href="https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/filters/list#examples" rel="nofollow">instruction</a>, it says ther... | 0 | 2016-08-16T05:07:29Z | 38,969,054 | <p>It mentions here that you need to have analytics object authorized which is why you're getting no analytics module error
<a href="http://take.ms/Gk7z6" rel="nofollow">http://take.ms/Gk7z6</a></p>
<p>Here's how you can get your analytics authorized object
<a href="https://developers.google.com/analytics/devguides/co... | 1 | 2016-08-16T07:34:06Z | [
"javascript",
"python",
"google-analytics",
"google-analytics-api"
] |
Tensorflow: how to install roi_pooling user_op | 38,967,048 | <p>I read in <a href="http://stackoverflow.com/questions/38618960/tensorflow-how-to-insert-custom-input-to-existing-graph">this</a> post by HediBy that this ROI_POOLING user_op implementation works: <a href="https://github.com/yuxng/tensorflow/" rel="nofollow">LINK</a> </p>
<p>I used bazel build </p>
<pre><code>-c op... | 1 | 2016-08-16T05:12:15Z | 38,986,829 | <p>thanks for the tip i just found out that the error occured when I built the user_op without GPU support. I reinstalled tensorflow v 0.10, with GPU support, and placed all user_op files inside //tensorflow/core/usââer_ops. </p>
<p>If I compile the user_op using bazel build -c opt --config=cuda //tensorflow/core/... | 1 | 2016-08-17T01:32:24Z | [
"python",
"tensorflow",
"detection",
"roi"
] |
parsing quotes in json | 38,967,121 | <p>I had a problem parsing quotes in json. I use python 2.7.
my json file is here.</p>
<pre><code>{
"table": "test",
"rows":
[
{
"comment_id" : "11111",
"title" : "Worked great with limited space",
"comment" : "We have a very "small" kitchen but wanted a stylish ... | -1 | 2016-08-16T05:19:11Z | 38,967,619 | <p>your json is not valid, it should be something like this, :-)
use a valid json</p>
<pre><code>{
"table": "test",
"rows": [{
"comment_id": "11111",
"title": "Worked great with limited space",
"comment": "We have a very \"small\" kitchen but wanted a stylish refrigerator that was count... | 0 | 2016-08-16T06:03:17Z | [
"python",
"json"
] |
Add a new node at the begininning of linkedlist in python? | 38,967,232 | <p>This is my code. I trying to add a new node at the beginning of the linked-list. But the first node should be overwritten. So how should i add a new node without overwrite a first node.
sample output: <code>10 15 20</code>
I trying to add 5 at the beginning. It comes like : <code>5 15 20</code>
I need a output like ... | -1 | 2016-08-16T05:31:01Z | 38,967,551 | <p>The problem is in your main program:</p>
<pre><code>llist.head.next = second
</code></pre>
<p>This explicitely sets the list's head to point to the second element (value 15), effectively losing the previous first node (10).</p>
<blockquote>
<p>But the first node should be overwritten. </p>
</blockquote>
<p>Th... | 2 | 2016-08-16T05:58:35Z | [
"python"
] |
Add a new node at the begininning of linkedlist in python? | 38,967,232 | <p>This is my code. I trying to add a new node at the beginning of the linked-list. But the first node should be overwritten. So how should i add a new node without overwrite a first node.
sample output: <code>10 15 20</code>
I trying to add 5 at the beginning. It comes like : <code>5 15 20</code>
I need a output like ... | -1 | 2016-08-16T05:31:01Z | 38,968,817 | <p>There's a little difference in your code you have to use head as a Class Variable where value is shared among all the instances not as the attribute of class. Please refer the code for better understanding. Thank you</p>
<pre><code>class Node:
def __init__(self, data):
self.data = data
self.n... | 0 | 2016-08-16T07:21:32Z | [
"python"
] |
Pyspark extracting four tuples from RDD | 38,967,281 | <p>I have a rdd which contains five tuples as shown below</p>
<pre><code>return [word_val+'&'+f_val+'&'+N_val+'&'+n_val+'&'+str(1)]
</code></pre>
<p>I want to map these values to compute result, I was expecting the mapping to work like:</p>
<pre><code>reducer_3 = add_m.map(lambda word: (word[0],word[... | 0 | 2016-08-16T05:35:30Z | 38,978,838 | <p>You need to map into a pair tuple before the reduceByKey, e.g.:</p>
<pre><code>reducer_3 = add_m.map(lambda word: ((word[0],word[1],word[2],word[3]),1)).reduceByKey(lambda x,y: x+y)
</code></pre>
<p>This will return a set of 4-tuples and their counts. The original code you showed seemed to be missing the extra par... | 0 | 2016-08-16T15:27:39Z | [
"python",
"apache-spark",
"pyspark"
] |
django image field - magic | 38,967,288 | <p>i define upload_to = 'products', my media_root is /var/www/work.sanremo-dv.ru/media/</p>
<p>In debugger image.path equal /var/www/work.sanremo-dv.ru/media/imagename.ext - without upload_to dir. Phisical image stored by /var/www/work.sanremo-dv.ru/media/products/imagename.ext why?</p>
<hr>
<p><a href="http://i.sta... | 0 | 2016-08-16T05:35:48Z | 38,977,809 | <p>maybe you should set <code>upload_to</code> with end slash?</p>
<pre><code>upload_to = 'products/'
</code></pre>
| 0 | 2016-08-16T14:37:57Z | [
"python",
"django"
] |
How to multiply every column of one Pandas Dataframe with every column of another Dataframe efficiently? | 38,967,402 | <p>I'm trying to multiply two pandas dataframes with each other. Specifically, I want to multiply every column with every column of the other df. </p>
<p>The dataframes are one-hot encoded, so they look like this: </p>
<pre><code>col_1, col_2, col_3, ...
0 1 0
1 0 0
0 0 1
...
</co... | 4 | 2016-08-16T05:46:03Z | 38,970,257 | <p>You can use numpy.</p>
<p>Consider this example code, I did modify the variable names, but <code>Test1()</code> is essentially your code. I didn't bother create the correct column names in that function though:</p>
<pre><code>import pandas as pd
import numpy as np
A = [[1,0,1,1],[0,1,1,0],[0,1,0,1]]
B = [[0,0,1,0... | 2 | 2016-08-16T08:41:57Z | [
"python",
"pandas",
"numpy",
"dataframe"
] |
How to multiply every column of one Pandas Dataframe with every column of another Dataframe efficiently? | 38,967,402 | <p>I'm trying to multiply two pandas dataframes with each other. Specifically, I want to multiply every column with every column of the other df. </p>
<p>The dataframes are one-hot encoded, so they look like this: </p>
<pre><code>col_1, col_2, col_3, ...
0 1 0
1 0 0
0 0 1
...
</co... | 4 | 2016-08-16T05:46:03Z | 38,970,625 | <pre><code># use numpy to get a pair of indices that map out every
# combination of columns from df_1 and columns of df_2
pidx = np.indices((df_1.shape[1], df_2.shape[1])).reshape(2, -1)
# use pandas MultiIndex to create a nice MultiIndex for
# the final output
lcol = pd.MultiIndex.from_product([df_1.columns, df_2.col... | 6 | 2016-08-16T08:59:19Z | [
"python",
"pandas",
"numpy",
"dataframe"
] |
How to multiply every column of one Pandas Dataframe with every column of another Dataframe efficiently? | 38,967,402 | <p>I'm trying to multiply two pandas dataframes with each other. Specifically, I want to multiply every column with every column of the other df. </p>
<p>The dataframes are one-hot encoded, so they look like this: </p>
<pre><code>col_1, col_2, col_3, ...
0 1 0
1 0 0
0 0 1
...
</co... | 4 | 2016-08-16T05:46:03Z | 38,970,709 | <p>You can multiply along the <code>index</code> axis your first <code>df</code> with each column of the second <code>df</code>, this is the <strong><em>fastest method</em></strong> for big dataset (see below):</p>
<pre><code>df = pd.concat([df_1.mul(col[1], axis="index") for col in df_2.iteritems()], axis=1)
# Change... | 4 | 2016-08-16T09:03:53Z | [
"python",
"pandas",
"numpy",
"dataframe"
] |
Margins of matplotlib.pyplot.imshow when used in subplot environment | 38,967,478 | <p>I am trying to plot the values of several arrays in separate plots of a figure using imshow.</p>
<p>When I plot one image only, and use the plt.imshow() command with the correct extents, the figure comes out perfectly.
However, when I try to create multiple plots of this image in the same figure, using plt.subplot(... | 0 | 2016-08-16T05:53:08Z | 38,967,970 | <p>I believe the reason for the whitespace is the size of the window. You can either change the window size (you'd have to figure out the numbers) or you can adjust the subplot. I found this out by playing with the "configure subplots" button in the image popup.</p>
<pre><code>plt.subplots_adjust(right=0.4)
</code></p... | 1 | 2016-08-16T06:28:53Z | [
"python",
"matplotlib",
"subplot",
"imshow"
] |
Margins of matplotlib.pyplot.imshow when used in subplot environment | 38,967,478 | <p>I am trying to plot the values of several arrays in separate plots of a figure using imshow.</p>
<p>When I plot one image only, and use the plt.imshow() command with the correct extents, the figure comes out perfectly.
However, when I try to create multiple plots of this image in the same figure, using plt.subplot(... | 0 | 2016-08-16T05:53:08Z | 39,013,209 | <p>So the options are:</p>
<ol>
<li><p>Remove the <code>sharex</code>/<code>sharey</code> keywords - seems to clash with imshow in the subplot environment. (Suggested by <a href="http://stackoverflow.com/users/293594/xnx">xnx</a>)</p></li>
<li><p>Use <code>plt.subplots_adjust</code> with appropriate settings, in combi... | 0 | 2016-08-18T08:22:03Z | [
"python",
"matplotlib",
"subplot",
"imshow"
] |
Retrieve company name with ticker symbol input, yahoo or google API | 38,967,533 | <p>Just looking for a simple api return, where I can input a ticker symbol and receive the full company name:</p>
<p>ticker('MSFT')
will return
"Microsoft"</p>
| 1 | 2016-08-16T05:57:17Z | 38,968,465 | <p>You need to first find a website / API which allows you to lookup stock symbols and provide information. Then you can query that API for information. </p>
<p>I came up with a quick and dirty solution here: </p>
<pre><code>import requests
def get_symbol(symbol):
symbol_list = requests.get("http://chstocksearc... | 1 | 2016-08-16T07:00:18Z | [
"python",
"json",
"yahoo-finance",
"stock",
"google-finance-api"
] |
Joining two querysets in Django | 38,967,599 | <p>Suppose I have the following models</p>
<pre><code>class Award(models.Model):
user = models.ForeignKey(User)
class AwardReceived(models.Model):
award = models.ForeignKey(award)
date = models.DateField()
units = models.IntegerField()
class AwardUsed(models.Model):
award = models.ForeignKey(aw... | 1 | 2016-08-16T06:01:36Z | 38,967,621 | <p><strong>SOLUTION 1</strong></p>
<p>Just try to concatenate your queryset using <code>|</code> </p>
<pre><code>final_q = q1 | q2
</code></pre>
<p>In your example</p>
<pre><code>final_q = summary | awards_used
</code></pre>
<p>UPDATED:</p>
<p>| does not works using calculated attributes, so, we can select our qu... | 2 | 2016-08-16T06:03:57Z | [
"python",
"django"
] |
ODO command in python and how to upload missing files from CSV as NULL with simple command | 38,967,666 | <p>i try to load data from a csv file into a mysql table using odo in python.</p>
<p>the csv file contains blank cells. The odo command files when it encounters blank cells.</p>
<p>how can I use the odo command to load the data and insert a null value by default for missing data.</p>
<p>I'm trying to import a simpl... | 0 | 2016-08-16T06:08:00Z | 38,984,224 | <p>If I make all fields varchar(255) then it reads missing fiels as ''. sqlalchemy cannot force a '' from the csv file into another datatype.</p>
<p>Best is to use varchar to purely reads the csv file and then afterwards convert it to the proper formats</p>
| 0 | 2016-08-16T20:49:31Z | [
"python",
"mysql",
null,
"odo"
] |
Recursion seems not working in Python | 38,967,678 | <p>I am writing a piece of code to recursively processing *.py files. The code block is as the following:</p>
<pre><code>class FileProcessor(object):
def convert(self,file_path):
if os.path.isdir(file_path):
""" If the path is a directory,then process it recursively
untill a f... | 0 | 2016-08-16T06:09:03Z | 38,967,808 | <p>The recursion is happening fine, but <code>temp_dir</code> is not a directory so it passes control to your stub <code>else</code> block. You can see this if you put <code>print(file_path)</code> outside your <code>if</code> block.</p>
<p><code>temp_dir</code> is the <strong><em>name</em></strong> of the next direct... | 4 | 2016-08-16T06:17:20Z | [
"python",
"python-3.x",
"recursion"
] |
Recursion seems not working in Python | 38,967,678 | <p>I am writing a piece of code to recursively processing *.py files. The code block is as the following:</p>
<pre><code>class FileProcessor(object):
def convert(self,file_path):
if os.path.isdir(file_path):
""" If the path is a directory,then process it recursively
untill a f... | 0 | 2016-08-16T06:09:03Z | 38,968,143 | <p>As <code>temp_dir</code> has the filename only without parent path, you should change</p>
<pre><code>self.convert(temp_dir)
</code></pre>
<p>to</p>
<pre><code>self.convert(os.path.join(file_path, temp_dir))
</code></pre>
| 0 | 2016-08-16T06:40:22Z | [
"python",
"python-3.x",
"recursion"
] |
pymongo: global name 'ReturnDocument' is not defined | 38,967,706 | <p>I'm trying to write a python program that finds and updates a document in mongodb:</p>
<pre><code>db.collection.find_one_and_update({"Machine": "24", "Available": True},
{"$set": {"Overview.Available": False}},
projection= {"_id": 0, "Machine": 1, ... | 0 | 2016-08-16T06:11:03Z | 38,967,956 | <p>You need to import the <code>ReturnDocument</code> class first. Add this to the top of your script: </p>
<pre><code>from pymongo.collection import ReturnDocument
</code></pre>
<p>Detailed docs: <a href="http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.ReturnDocument" rel="nofoll... | 0 | 2016-08-16T06:27:46Z | [
"python",
"mongodb",
"pymongo",
"nameerror"
] |
Non-Image Bar Codes for Django | 38,967,729 | <p>I was wondering if there's a library that I can use to create bar codes in Django using just HTML + CSS rather than producing the bar codes as images (like in <strong>reportlab</strong> & <strong>pybarcode</strong>). I'm reluctant to use images because I'm creating many bar codes on the same page and I feel imag... | -1 | 2016-08-16T06:12:03Z | 38,970,441 | <p>I have decided to use <a href="http://www.jqueryscript.net/other/Simple-jQuery-Based-Barcode-Generator-Barcode.html" rel="nofollow">jquery-barcode</a> which is completely works at client end </p>
| 0 | 2016-08-16T08:50:17Z | [
"python",
"django",
"barcode"
] |
Redirection login cookie or pass in data via POST? | 38,967,833 | <p>Iâm trying to use Pythonâs requests library to automatically get my grades from a university website. The URL is <a href="https://acorn.utoronto.ca/sws/transcript/academic/main.do?main.dispatch" rel="nofollow">https://acorn.utoronto.ca/sws/transcript/academic/main.do?main.dispatch</a>, but there are several redi... | 2 | 2016-08-16T06:19:17Z | 38,971,901 | <p>You can try logging in then getting whatever page you want, there is more more data to be posted which you can get with <em>bs4</em>:</p>
<pre><code>import requests
from bs4 import BeautifulSoup
url = "https://weblogin.utoronto.ca/"
with requests.Session() as s:
s.headers.update({"User-Agent":"Mozilla/5.0 (X11;... | 0 | 2016-08-16T10:00:19Z | [
"python",
"html",
"web",
"python-requests"
] |
How to send data from C# to Python | 38,967,979 | <p>How can i send this list to list in Python script? This is so big for sending as arguments. Thank you. </p>
<pre><code> List<String> cefList= new List<String>();
for(int i=0; i<1000; i++){
cefList.Add("CEF:0|ArcSight|ArcSight|6.0.3.6664.0|agent:030|Agent [test] type [te... | 0 | 2016-08-16T06:29:24Z | 38,968,056 | <p>You need to serialize the data to a common format that is accessible from both C# and Python. For example - XML or JSON. I would recommend using JSON. </p>
<p>Then you have several options: </p>
<ul>
<li>Use sockets to transfer the data. </li>
<li>Use http to transfer the data. </li>
<li>Write to a file from C# an... | 0 | 2016-08-16T06:34:51Z | [
"c#",
"python"
] |
How to send data from C# to Python | 38,967,979 | <p>How can i send this list to list in Python script? This is so big for sending as arguments. Thank you. </p>
<pre><code> List<String> cefList= new List<String>();
for(int i=0; i<1000; i++){
cefList.Add("CEF:0|ArcSight|ArcSight|6.0.3.6664.0|agent:030|Agent [test] type [te... | 0 | 2016-08-16T06:29:24Z | 38,968,841 | <p>Since your C# program runs the python script, I guess the easiest solution would be to redirect the standard input of the python process:</p>
<pre><code> Process pyProc = Process.Start(
new ProcessStartInfo("python.exe", @"/path/to/the/script.py")
{
RedirectStandardInput = true,
... | 1 | 2016-08-16T07:23:01Z | [
"c#",
"python"
] |
How do you call C++ and\or Java functions from Python 2.7? | 38,968,007 | <p>I am creating a Windows program that so far has a .bat file calling a .pyw file, and I need functions from Java and C++. How can I do this?(I don't mind creating a new batch or python file, and I already have the header file for the C++ section and a .jar file for my java components. (For Java I use Eclipse Java Mar... | 2 | 2016-08-16T06:30:51Z | 38,968,074 | <p>This is rather simple for C++: you have to compile a library with you function, import it in Python and... call it! Python has a powerful standard library <a href="https://docs.python.org/2/library/ctypes.html" rel="nofollow">ctypes</a> to handle this kind of tasks. </p>
<p>Here is an example of loading <code>print... | 1 | 2016-08-16T06:35:38Z | [
"java",
"python",
"c++",
"python-2.7",
"batch-file"
] |
How do you call C++ and\or Java functions from Python 2.7? | 38,968,007 | <p>I am creating a Windows program that so far has a .bat file calling a .pyw file, and I need functions from Java and C++. How can I do this?(I don't mind creating a new batch or python file, and I already have the header file for the C++ section and a .jar file for my java components. (For Java I use Eclipse Java Mar... | 2 | 2016-08-16T06:30:51Z | 38,968,156 | <p>You can load C++ function and execute it from Python like BasicWolf explained in his answer. For Java, Jython might be a good approach. But then there's a problem - you will need to be dependent on Jython which is not up to date with the latest versions of Python. You will face compatibility issues with different li... | 0 | 2016-08-16T06:41:22Z | [
"java",
"python",
"c++",
"python-2.7",
"batch-file"
] |
Python : Regex capturing genric for 3 cases. | 38,968,187 | <p>Hi Anyone help me imporve my not working regular expresion.</p>
<p><strong><em>Strings Cases:</em></strong></p>
<blockquote>
<p>1) 120 lbs and is intended for riders ages <em>8 years and up</em>. <strong>#catch : 8 years and up</strong></p>
<p>2) 56w x 28d x 32h inches recommended for hobbyists recomme... | -1 | 2016-08-16T06:43:08Z | 38,968,471 | <p>Make it a habit and start with verbose regular expressions:</p>
<pre><code>import re
rx = re.compile(r'''
ages\ # look for ages
(\d+(?:\ years)?\ and\ (?:above|up)) # capture a digit, years eventually
# and one of above or up
''', re.VE... | 2 | 2016-08-16T07:00:48Z | [
"python",
"regex",
"findall"
] |
Python : Regex capturing genric for 3 cases. | 38,968,187 | <p>Hi Anyone help me imporve my not working regular expresion.</p>
<p><strong><em>Strings Cases:</em></strong></p>
<blockquote>
<p>1) 120 lbs and is intended for riders ages <em>8 years and up</em>. <strong>#catch : 8 years and up</strong></p>
<p>2) 56w x 28d x 32h inches recommended for hobbyists recomme... | -1 | 2016-08-16T06:43:08Z | 38,973,995 | <p>(As the suggestion I made in a comment appears to have been what you wanted, I offer it as an answer.)</p>
<p>If your examples illustrate all possible strings (but I fear they don't ;) you could do it as simple as</p>
<pre><code>\d+[^\d]*$
</code></pre>
<p><a href="https://regex101.com/r/gX5cC4/2" rel="nofollow">... | 0 | 2016-08-16T11:41:53Z | [
"python",
"regex",
"findall"
] |
How to use doc2vec with phrases? | 38,968,353 | <p>i want to have phrases in doc2vec and i use gensim.phrases. in doc2vec we need tagged document to train the model and i cannot tag the phrases. how i can do this?</p>
<p>here is my code</p>
<pre><code>text = phrases.Phrases(text)
for i in range(len(text)):
string1 = "SENT_" + str(i)
sentence = doc2vec.Lab... | 0 | 2016-08-16T06:53:20Z | 38,985,945 | <p>The invocation of <code>Phrases()</code> trains a phrase-creating-model. You later use that model on text to get back phrase-combined text. </p>
<p>Don't replace your original <code>text</code> with the trained model, as on your code's first line. Also, don't try to assign into the Phrases model, as happens in your... | 0 | 2016-08-16T23:24:42Z | [
"python",
"nlp",
"gensim",
"phrases",
"doc2vec"
] |
How to list the pre-installed Python packages on IBM's Spark service | 38,968,367 | <p>In a Python notebook, I can execute <code>!pip freeze</code> to get a list of installed packages. But the result is an empty list, or shows only a few packages that I installed myself. Until a few weeks ago, the command would return a list of all the packages, including those pre-installed by IBM. How can I get the ... | 0 | 2016-08-16T06:54:08Z | 38,968,368 | <p><code>!PIP_USER= pip freeze</code></p>
<p>IBM sets the environment variable PIP_USER to enable the <code>--user</code> option by default. That's because many users forgot to specify that option for <code>pip install</code>. Unfortunately, this also enables the option for <code>pip freeze</code>, where it might not ... | 3 | 2016-08-16T06:54:08Z | [
"python",
"apache-spark",
"ibm-bluemix"
] |
Python: Changing one object's data changes the other | 38,968,393 | <p>I apologize ahead of time if my explanation is not coherent enough. I am new to python and coding. I'm currently trying to create a Pokemon program that will allow 2 users to battle each other. <code>moveList</code> is a global list that contains all the possible moves in the game.
<code>x</code> - is a file the sto... | -1 | 2016-08-16T06:56:06Z | 38,968,621 | <p>The culprit is the class variable <code>move</code>. Setting up that list as a class variable means all instances will be pointing to the same list object. Consider the following:</p>
<pre><code>>>> class T:
... move = [] # move defined as class variable
... def update(self, v):
... self.move[... | 0 | 2016-08-16T07:09:10Z | [
"python"
] |
Subtract series value from pandas data frame given multiple index | 38,968,585 | <p>I have a big data frame in Pandas, <em>table A</em>, with structure like below:</p>
<pre>
key1 key2 value1
1 201501 12
2 201502 4
3 201503 3
4 201506 9
5 201507 15
6 201509 nan
</pre>
<p>from <em>table A</em>, colum <em>value1</em... | 2 | 2016-08-16T07:07:21Z | 38,968,675 | <p>You can create <code>DataFrames</code> with <code>MultiIndexes</code> by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.set_index.html" rel="nofollow"><code>set_index</code></a>, then substract by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.sub.htm... | 1 | 2016-08-16T07:12:09Z | [
"python",
"pandas",
"join",
"dataframe",
"subtraction"
] |
Subtract series value from pandas data frame given multiple index | 38,968,585 | <p>I have a big data frame in Pandas, <em>table A</em>, with structure like below:</p>
<pre>
key1 key2 value1
1 201501 12
2 201502 4
3 201503 3
4 201506 9
5 201507 15
6 201509 nan
</pre>
<p>from <em>table A</em>, colum <em>value1</em... | 2 | 2016-08-16T07:07:21Z | 38,971,858 | <pre><code>tableA.set_index(keys).value1 \
.sub(tableB.set_index(keys).value1, fill_value=0) \
.reset_index()
</code></pre>
<p><a href="http://i.stack.imgur.com/W6CBr.png" rel="nofollow"><img src="http://i.stack.imgur.com/W6CBr.png" alt="enter image description here"></a></p>
| 1 | 2016-08-16T09:58:00Z | [
"python",
"pandas",
"join",
"dataframe",
"subtraction"
] |
Django tables2 external link generation w/ custom parameters | 38,968,790 | <p>I have a music related model with Artist and song Title fields and I'd like to add a column that provides a link to search Amazon's digital music store using the artist and title from the given row on a table using Tables2. Here is what I have but not sure how to add the Amazon column and provide the Artist and Titl... | 0 | 2016-08-16T07:19:48Z | 38,974,129 | <p>I would use <a href="https://docs.djangoproject.com/en/1.10/ref/utils/#django.utils.html.format_html" rel="nofollow"><code>format_html</code></a>. </p>
<p>Furthermore, you'll need to add <code>record</code> as a parameter to the render function, which allows you access its other attributes:</p>
<pre><code>class Am... | 1 | 2016-08-16T11:48:42Z | [
"python",
"django",
"django-tables2"
] |
pd.to_datetime or parse datetimes won't work with my csv file (format: dd/mm/yyyy, hh:mm:ss) | 38,968,811 | <p>I extracted the following table from my csv file </p>
<pre><code>Date,Time,CO2(ppm),CellTemp(c),CellPres(kPa)
10/08/2016,13:21:11,356.89,51.07,99.91
10/08/2016,13:21:12,356.89,51.07,99.91
10/08/2016,13:21:13,356.83,51.07,99.91
</code></pre>
<p>I researched the last couple of days and tried different things ... | 2 | 2016-08-16T07:20:50Z | 38,968,905 | <p>It looks like there is some wrong datetime or some value, which cannot be converted to datetime, so you can add parameter <code>errors='coerce'</code> to <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.to_datetime.html" rel="nofollow"><code>to_datetime</code></a> for converting them to <code>Na... | 3 | 2016-08-16T07:26:34Z | [
"python",
"csv",
"datetime",
"pandas"
] |
Read array of preprocessed length with lldb | 38,968,902 | <p>I have this array in my C code </p>
<pre><code>uint8_t a[LENGTH];
</code></pre>
<p>I want to read the elements of array with lldb python script, but I don't know the <code>LENGTH</code> value when I'm debugging.
What is the solution?</p>
| 0 | 2016-08-16T07:26:27Z | 38,969,473 | <p>you can make it if use a temporary variables</p>
<pre><code>uint8_t a[LENGTH];
uint64_t tmp_len;
tmp_len = LENGTH;
</code></pre>
| 0 | 2016-08-16T07:58:20Z | [
"python",
"c",
"xcode",
"debugging",
"lldb"
] |
Python: How to change variable in http post request | 38,968,943 | <pre><code>data = {'Email':'myemail@gmail.com','Name':'1','Password':'gfgf65jh56456jh67'}
r = requests.post(url, data=json.dumps(data), headers=headers)
</code></pre>
<p>Hello,
I am using above code to send http request and it worked well. However, I want to use for loop to change "Name" variable. So, this is my code ... | 0 | 2016-08-16T07:29:04Z | 38,969,045 | <p>In the line that changes data, <code>data</code> is not a dictionary any more but a string...</p>
<p>Change data simply by:</p>
<pre><code>data['Name'] = str(i)
</code></pre>
| 0 | 2016-08-16T07:33:47Z | [
"python",
"python-3.x",
"http",
"post",
"https"
] |
How to find and leave only doubles in list python? | 38,969,024 | <p>How to find only doubles in list? My version of the algorithm</p>
<pre><code>import collections
a = [1,2,3,4,5,2,4,5]
b = []
for x,y in collections.Counter(a).items():
if y>1:
b.append(x)
print(b) # [2, 4, 5]
c = []
for item in a:
if item in b:
c.append(item)
print(c) # [2, 4, 5, 2,... | 5 | 2016-08-16T07:32:54Z | 38,969,122 | <pre><code>from collections import Counter
a = [1, 2, 3, 4, 5, 2, 4, 5]
counts = Counter(a)
print([num for num in a if counts[num] > 1])
</code></pre>
| 13 | 2016-08-16T07:37:59Z | [
"python"
] |
How to find and leave only doubles in list python? | 38,969,024 | <p>How to find only doubles in list? My version of the algorithm</p>
<pre><code>import collections
a = [1,2,3,4,5,2,4,5]
b = []
for x,y in collections.Counter(a).items():
if y>1:
b.append(x)
print(b) # [2, 4, 5]
c = []
for item in a:
if item in b:
c.append(item)
print(c) # [2, 4, 5, 2,... | 5 | 2016-08-16T07:32:54Z | 38,969,124 | <p>Not the most efficient way, but very concise:</p>
<pre><code>a = [1,2,3,4,5,2,4,5]
b = [x for x in a if a.count(x) > 1]
print(b)
</code></pre>
| 5 | 2016-08-16T07:38:05Z | [
"python"
] |
How to find and leave only doubles in list python? | 38,969,024 | <p>How to find only doubles in list? My version of the algorithm</p>
<pre><code>import collections
a = [1,2,3,4,5,2,4,5]
b = []
for x,y in collections.Counter(a).items():
if y>1:
b.append(x)
print(b) # [2, 4, 5]
c = []
for item in a:
if item in b:
c.append(item)
print(c) # [2, 4, 5, 2,... | 5 | 2016-08-16T07:32:54Z | 38,969,202 | <p>@Karin almost had it I think, but end result will not be a set.</p>
<pre><code>from collections import Counter
a = [1, 2, 3, 4, 5, 2, 4, 5]
counts = Counter(a)
print({k for k, v in counts.items() if v >= 2})
</code></pre>
<p>EDIT: Ahh, "leave only doubles" </p>
<pre><code>print([x for x in a if counts[x] >... | 1 | 2016-08-16T07:43:03Z | [
"python"
] |
speed up slicing dicing of customers mysql | 38,969,135 | <p>Currently we are using AWS RDS(Mysql) + Pandas. We have order, customers, products tables and so on. To get customers and do campaign based on various filters(total 18 filters) on those customers its taking too much time. "Order"'s table itself is of magnitude of million of rows. So to speed up We started doing poc ... | 1 | 2016-08-16T07:38:31Z | 38,969,632 | <p>You can use the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html" rel="nofollow"><code>top_hits</code> aggregation</a> to retrieve the documents for each customer bucket. </p>
<pre><code>{
"aggs": {
"customer_ids":{
... | 0 | 2016-08-16T08:06:20Z | [
"python",
"mysql",
"pandas",
"elasticsearch"
] |
Python look for variable in JSON | 38,969,179 | <p>I'm expecting a JSON msg to be parsed with Python along these lines to come in through MQTT:</p>
<pre><code>{"OPTION1": "0", "OPTION2": "50", "OPTION3": "0", "OPTION4": "0"}
</code></pre>
<p>Depending on the circumstances, these options may or may not be parsed through Python into the JSON msg, and as such, it may... | -1 | 2016-08-16T07:42:18Z | 38,969,345 | <p>If you are working with if else <strong>pass</strong>, <strong>continue</strong> is used with loops:-</p>
<pre><code> if data['OPTION1']:
>do something here<
else:
pass
</code></pre>
<p>Continue is used with loops. Also you can try:-</p>
<pre><code>for dataItem in data:
if "OPTION2" == dataIte... | 2 | 2016-08-16T07:51:01Z | [
"python",
"json"
] |
Python look for variable in JSON | 38,969,179 | <p>I'm expecting a JSON msg to be parsed with Python along these lines to come in through MQTT:</p>
<pre><code>{"OPTION1": "0", "OPTION2": "50", "OPTION3": "0", "OPTION4": "0"}
</code></pre>
<p>Depending on the circumstances, these options may or may not be parsed through Python into the JSON msg, and as such, it may... | -1 | 2016-08-16T07:42:18Z | 38,969,356 | <p><code>continue</code> is used with loops, you might need <code>pass</code>ehere. Also, you can use <code>in</code> to check if a key is available in a dictionary:</p>
<pre><code>if 'OPTION1' in data:
# do something
else:
pass
</code></pre>
<p><strong>But I don't think, that is what you want!</strong> You want ... | 0 | 2016-08-16T07:51:28Z | [
"python",
"json"
] |
Extract complete URL from href using Python | 38,969,205 | <p>I am doing a project on web crawling for which I need to find all links within a given web page. Till now I was using <code>urljoin</code> in <code>urllib.parse</code>. But now I found that some links are not properly joined using the <code>urljoin</code> function. </p>
<p>For e.g. the <code><a></code> tag mi... | 0 | 2016-08-16T07:43:14Z | 38,974,999 | <p>Just some tweaks to get this working. In your case pass base URI with trailing slash. Everything you will need to accomplish this is written in the <a href="https://docs.python.org/2/library/urlparse.html" rel="nofollow">docs of urlparse</a></p>
<pre><code>>>> import urlparse
>>> urlparse.urljoin(... | 1 | 2016-08-16T12:29:14Z | [
"python",
"web-crawler",
"urllib"
] |
Using more that 1 argument in glob() | 38,969,240 | <p>I'm trying to recursively search files ending with .png or .jpg in a folder named 'dataset' using the glob(). Here is the code snippet:</p>
<pre><code> for imagePath in glob.glob(args["dataset"] + "/*.png"):
</code></pre>
<p>I'm setting the image ID using the imagePath inside the loop. How can I search using 2 ... | 0 | 2016-08-16T07:44:43Z | 38,969,895 | <p>One way could perhaps be to first create the list of existing files and then loop this list</p>
<pre><code>image_types = (â/*.jpg', â/*.png')
image_files = []
for files in image_types:
image_files.extend(glob.glob("dataset/" + files))
image_files #list of .jpg and .png files
</code></pre>
| 0 | 2016-08-16T08:22:05Z | [
"python",
"python-2.7",
"recursion",
"arguments",
"glob"
] |
python pandas selecting columns from a dataframe via a list of column names | 38,969,267 | <p>I have a dataframe with a lot of columns in it. Now I want to select only certain columns. I have saved all the names of the columns that I want to select into a Python list and now I want to filter my dataframe according to this list. </p>
<p>I've been trying to do:</p>
<pre><code>df_new = df[[list]]
</code></pre... | 0 | 2016-08-16T07:46:28Z | 38,969,308 | <p>You can remove one <code>[]</code>:</p>
<pre><code>df_new = df[list]
</code></pre>
<p>Also better is use other name as <code>list</code>, e.g. <code>L</code>:</p>
<pre><code>df_new = df[L]
</code></pre>
<p>It look like working, I try only simplify it:</p>
<pre><code>L = []
for x in df.columns:
if not "_" i... | 1 | 2016-08-16T07:48:11Z | [
"python",
"pandas",
"dataframe"
] |
Prize distribution algorithm to handle ties | 38,969,303 | <p>I'm trying to come up with a prize distribution algorithm that can scalably handle different number of players and factor in ties i.e in case the contestants fall in the same position.</p>
<p>This is what I have so far:</p>
<pre><code>Distribution Formula
P=((1-d)/1-d^n)*d^(p-1))*A
Where:
P ... | -1 | 2016-08-16T07:47:54Z | 38,971,607 | <ol>
<li>Let <code>MaxT</code> (default value 1) is maximum of all ties for various tied positions </li>
<li><p>Choose <code>d <= 1/MaxT</code> </p>
<p><strong>UPDATE</strong>: For example:</p>
<blockquote>
<pre><code>1 A 30000.03221 |
1 B 30000.03221 | Tie count T1 = 2
2 C 12000.01288
3 D 4800.00... | 1 | 2016-08-16T09:46:19Z | [
"python",
"algorithm",
"math",
"statistics",
"game-engine"
] |
Python - Get the value which Satisfies OR Truth Table out of two values | 38,969,307 | <p>I have two objects which returns two values, lets say x1, x2. I just have to check whether the values exist or not and if exists it should return those, which is not None,False, 0. </p>
<p>This is just simple try, which is OK:</p>
<pre><code>def get_valid_keys(x1, x2):
""" """
a = []
if x1: a.append(x1... | 0 | 2016-08-16T07:48:10Z | 38,969,374 | <p>Weed out any zeroes:</p>
<pre><code>filter(lambda x: x, [x1, x2])
</code></pre>
| 2 | 2016-08-16T07:52:25Z | [
"python"
] |
Fuzzy string matching in Python | 38,969,383 | <p>I have 2 lists of over a million names with slightly different naming conventions. The goal here it to match those records that are similar, with the logic of 95% confidence.</p>
<p>I am made aware there are libraries which I can leverage on, such as the FuzzyWuzzy module in Python.</p>
<p>However in terms of proc... | 5 | 2016-08-16T07:52:41Z | 38,969,585 | <p>You have to index, or normalize the strings to avoid the O(n^2) run. Basically, you have to map each string to a normal form, and to build a reverse dictionary with all the words linked to corresponding normal forms.</p>
<p>Let's consider that normal forms of 'world' and 'word' are the same. So, first build a rever... | 4 | 2016-08-16T08:04:12Z | [
"python",
"algorithm",
"fuzzy-search",
"fuzzywuzzy"
] |
Fuzzy string matching in Python | 38,969,383 | <p>I have 2 lists of over a million names with slightly different naming conventions. The goal here it to match those records that are similar, with the logic of 95% confidence.</p>
<p>I am made aware there are libraries which I can leverage on, such as the FuzzyWuzzy module in Python.</p>
<p>However in terms of proc... | 5 | 2016-08-16T07:52:41Z | 38,972,464 | <p>There are several level of optimizations possible here to turn this problem from O(n^2) to a lesser time complexity.</p>
<ul>
<li><p><strong>Preprocessing</strong> : Sort your list in the first pass, creating an output map for each string , they key for the map can be normalized string.
Normalizations may include:<... | 5 | 2016-08-16T10:26:27Z | [
"python",
"algorithm",
"fuzzy-search",
"fuzzywuzzy"
] |
python: tree = ET.parse('file.xml') use variable (getdata) in place of 'file.xml' | 38,969,404 | <p>this is probably a simple answer.</p>
<p>I can parse and convert datae from XML using whats in the title,</p>
<p>however I'm pulling back data from different sources and I don't want to write them all to files before parsing them as I'm going to be combining the data into one file. </p>
<p>So I run an api call to... | 0 | 2016-08-16T07:53:47Z | 38,969,450 | <p>Take a look at the <a href="https://docs.python.org/2/library/xml.etree.elementtree.html#xml.etree.ElementTree.fromstring" rel="nofollow"><code>fromstring</code></a> method of ElementTree:</p>
<pre><code>root_element = ET.fromstring(getdata)
</code></pre>
| 2 | 2016-08-16T07:57:23Z | [
"python",
"xml",
"parsing"
] |
SQLAlchemy bulk_save_objects can't save updated object having a versioning field | 38,969,406 | <p>I'm trying to have a combination of a versioning on my rows, and <code>bulk_save_objects</code>. Here's my code, and it fails when I try to give the function an updated object at the end of the code.</p>
<pre><code>import datetime
import sqlalchemy as sqa
import sqlalchemy.ext
import sqlalchemy.ext.declarative
impo... | 0 | 2016-08-16T07:54:09Z | 39,168,568 | <p>Bulk operations bypass a lot of SQLAlchemy's functionality in the name of speed. Every bulk operation has a large list of warnings and caveats in the docs. I would not be surprised if the versioning functionality is one of the things bypassed.</p>
| 0 | 2016-08-26T14:23:44Z | [
"python",
"orm",
"sqlalchemy"
] |
Spark 2.0 filter using a UDF after a self-join | 38,969,413 | <p>I need to filter a Spark dataframe using my own User-Defined Function. My dataframe is read from a database using a jdbc connection and then goes through a self-join operation in spark before being filtered. The error occurs when trying to <code>collect</code> the dataframe after the filter.</p>
<p>I have been usin... | 0 | 2016-08-16T07:54:36Z | 38,988,600 | <p>This is a bug in pyspark.</p>
<p>I have filed a bug for it here <a href="https://issues.apache.org/jira/browse/SPARK-17100" rel="nofollow">https://issues.apache.org/jira/browse/SPARK-17100</a></p>
<p>This problem arises in left_outer, right_outer and outer joins, but not for inner joins.</p>
<p>One workaround is ... | 1 | 2016-08-17T05:18:16Z | [
"python",
"apache-spark",
"pyspark",
"spark-dataframe"
] |
Can not find api to reset virtual guest's password | 38,969,449 | <p>I have a requirement that resetting the virtual guest's password when the password is forgotten. And I failed to find a suitable method to reset the password. Maybe reloading the os is a way to reset the password, but it is too crude. Is there any api/method to reset the virtual guest's password?</p>
| 0 | 2016-08-16T07:57:19Z | 38,977,645 | <p>Currently thereâs no API method to reset the Virtual Guestâs password.</p>
| 0 | 2016-08-16T14:31:14Z | [
"python",
"softlayer"
] |
python: replace strings in a nested dictionary | 38,969,466 | <p>I have a nested dictionary and I would like to replace all the strings in the lists that have a space followed by numbers (<code>vlc 2.2</code>, <code>ado 3.4</code> and <code>ultr 3.1</code>) just with their name, i.e. <code>vlc</code>, <code>ado</code> and <code>ultr</code>. Here is the input dictionary: </p>
<pr... | 3 | 2016-08-16T07:58:02Z | 38,969,568 | <p>This solution will work if you want to strip anything following a space within the <code>to_do</code> lists. This seemed implied by your current implementation, but if you want digits only, you'll need to use a regex.</p>
<p><strong>Python 2</strong>:</p>
<pre><code>d = {
'cl1': {
'to_do': [
... | 0 | 2016-08-16T08:03:26Z | [
"python",
"dictionary"
] |
python: replace strings in a nested dictionary | 38,969,466 | <p>I have a nested dictionary and I would like to replace all the strings in the lists that have a space followed by numbers (<code>vlc 2.2</code>, <code>ado 3.4</code> and <code>ultr 3.1</code>) just with their name, i.e. <code>vlc</code>, <code>ado</code> and <code>ultr</code>. Here is the input dictionary: </p>
<pr... | 3 | 2016-08-16T07:58:02Z | 38,969,736 | <p>When you do this :</p>
<pre><code>input[k]['to_do'] = e.replace(e, e.split()[0])
</code></pre>
<p>You replace the initial arrays (<code>['ultr 3.1', 'ab']</code> and <code>['ab', 'dir8', 'cop', 'vlc 2.2.2.0', '7zi', '7zi', 'ado 3.4']</code>) by a <strong>single value</strong> (the last one processed in your loop).... | 2 | 2016-08-16T08:12:24Z | [
"python",
"dictionary"
] |
python: replace strings in a nested dictionary | 38,969,466 | <p>I have a nested dictionary and I would like to replace all the strings in the lists that have a space followed by numbers (<code>vlc 2.2</code>, <code>ado 3.4</code> and <code>ultr 3.1</code>) just with their name, i.e. <code>vlc</code>, <code>ado</code> and <code>ultr</code>. Here is the input dictionary: </p>
<pr... | 3 | 2016-08-16T07:58:02Z | 38,970,181 | <p>An even more generic way to do this would be to create a recursive method, that calls itself again:</p>
<pre class="lang-py prettyprint-override"><code>def recursive_split(input, search):
# check whether it's a dict, list, tuple, or scalar
if isinstance(input, dict):
items = input.items()
elif i... | 0 | 2016-08-16T08:37:17Z | [
"python",
"dictionary"
] |
why regular expression match an additional space in Python 2.7? | 38,969,486 | <p>Using Python 2.7. And in a long string, I want to match content which starts and ends with <code>{</code> <code>}</code>. And particularly, I am interested in two parts within <code>{</code> <code>}</code>. The first part is anything in <code>[1J, 2J, ..., 10J]</code> or <code>[1S, 2S, ..., 10S]</code>, and wrapped ... | 1 | 2016-08-16T07:59:12Z | 38,969,518 | <p><code>print num, content</code> separates the two printed values by a space. Concatenate the two strings if you don't want that space to be printed:</p>
<pre><code>print num + content
</code></pre>
<p>Note that <code>num</code> only consists of <code>'(2J'</code> and <code>(1J'</code>, respectively. The remainder ... | 3 | 2016-08-16T08:00:40Z | [
"python",
"regex",
"python-2.7"
] |
why regular expression match an additional space in Python 2.7? | 38,969,486 | <p>Using Python 2.7. And in a long string, I want to match content which starts and ends with <code>{</code> <code>}</code>. And particularly, I am interested in two parts within <code>{</code> <code>}</code>. The first part is anything in <code>[1J, 2J, ..., 10J]</code> or <code>[1S, 2S, ..., 10S]</code>, and wrapped ... | 1 | 2016-08-16T07:59:12Z | 38,969,681 | <p>You placed the <code>+</code> after your group #1, but you forgot to make sure a comma is also matched. Add it as an optional symbol to match. Also, the <code>(?:,|\))</code> part is put inside an alternative branch, while the <code>)</code> should be placed outside as the trailing char in Group 1, whule the comma i... | 2 | 2016-08-16T08:09:15Z | [
"python",
"regex",
"python-2.7"
] |
Python Yandex translate example | 38,969,543 | <p>so for example I am trying to use <code>unirest</code> for this
so i put</p>
<pre><code>base = 'translate.yandex.net
post = '/api/v1.5/tr./getLangs?ui=en&key=' + api_key
request = unirest.get(base+post, headers={'accept' : "json"})
</code></pre>
<p>and the code says something about not a valid url this is dire... | 2 | 2016-08-16T08:01:56Z | 38,990,798 | <p>Try adding <code>http://</code> or <code>https://</code> in the base url:</p>
<pre><code>base = 'http://translate.yandex.net'
post = '/api/v1.5/tr.json/getLangs?ui=en&key=' + api_key
request = unirest.get(base+post, headers={'accept' : "json"})
</code></pre>
<p>and it should be fine.</p>
<p>This is based on <... | 2 | 2016-08-17T07:41:50Z | [
"python",
"json",
"api",
"unirest",
"yandex"
] |
Program to check if list is in alternating form | 38,969,629 | <p>I am trying to write a function in Python that checks if a given list of integers is strictly alternating i.e.alternately go up and down strictly</p>
<p>So for example:</p>
<pre><code>alternating([]) = True
alternating([1,3,2,3,1,5]) = True
alternating([3,2,2,1,5])= False
alternating([3,2,1,3,5]) = False
</cod... | 0 | 2016-08-16T08:06:10Z | 38,969,766 | <p>Here is how I would do it:</p>
<pre><code>def alternating(l):
return all(cmp(a, b)*cmp(b, c) == -1 for a, b, c in zip(l, l[1:], l[2:]))
assert alternating([]) is True
assert alternating([1, 3, 2, 3, 1, 5]) is True
assert alternating([3, 2, 2, 1, 5]) is False
assert alternating([3, 2, 1, 3, 5]) is False
assert ... | 5 | 2016-08-16T08:13:50Z | [
"python"
] |
Program to check if list is in alternating form | 38,969,629 | <p>I am trying to write a function in Python that checks if a given list of integers is strictly alternating i.e.alternately go up and down strictly</p>
<p>So for example:</p>
<pre><code>alternating([]) = True
alternating([1,3,2,3,1,5]) = True
alternating([3,2,2,1,5])= False
alternating([3,2,1,3,5]) = False
</cod... | 0 | 2016-08-16T08:06:10Z | 38,969,847 | <p>Basic error #1:</p>
<pre><code>for i in range(1,len(list)):
if (((list[i]>list[i+1]) and (list[i]>list[i-1])) or ...:
return True
</code></pre>
<p>On the algorithmic perspective, you cannot possibly determine that a list of <code>n</code> elements is alternating by checking only <code>O(1)</code... | 1 | 2016-08-16T08:18:49Z | [
"python"
] |
Program to check if list is in alternating form | 38,969,629 | <p>I am trying to write a function in Python that checks if a given list of integers is strictly alternating i.e.alternately go up and down strictly</p>
<p>So for example:</p>
<pre><code>alternating([]) = True
alternating([1,3,2,3,1,5]) = True
alternating([3,2,2,1,5])= False
alternating([3,2,1,3,5]) = False
</cod... | 0 | 2016-08-16T08:06:10Z | 38,969,910 | <p>Here is a straightforward way to do it:</p>
<pre><code>def alternating(l):
for i in range(1, len(l) - 1):
if not (l[i - 1] < l[i] > l[i + 1] or
l[i - 1] > l[i] < l[i + 1]):
return False
return True
print alternating([])
print alternating([1,3,2,3,1,5])
print alternating([3,2,2... | 3 | 2016-08-16T08:22:56Z | [
"python"
] |
How to use variable from looping as dictionary key in Django template? | 38,969,637 | <p>assumed that i have return a dictionary like this in my views or template_tags :</p>
<pre><code>data = {key1:value1,key2:value2,......,keyn:valuen}
</code></pre>
<p>how can i generate something like this in my html template ?</p>
<pre><code>value1
value2
value3
.
.
.
valuen
</code></pre>
<p>This is what i've got... | -1 | 2016-08-16T08:06:45Z | 38,969,714 | <p>According to this documentation page : <a href="https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#for" rel="nofollow">https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#for</a> this should work as you wish :</p>
<pre><code>{% for key, value in data.items %}
{{ value }} <br />
{% end... | 1 | 2016-08-16T08:11:03Z | [
"python",
"django",
"django-templates"
] |
Clearing LRU cache on all object properties | 38,969,823 | <p>So I'm using <code>@lru_cache</code> on my objects in different parts, and I'm just wondering how to flush the cache on all functions on an object where @lru_cache is used, something like:</p>
<pre><code>for i in dir(self):
if 'cache_clear' in dir(i):
self.get_attr(i).cache_clear()
</code></pre>
<p>The probl... | 0 | 2016-08-16T08:17:23Z | 38,970,023 | <p>When you request an instance method from <code>self</code>, Python returns a bound method object that does not have the <code>cache_clear</code> method.</p>
<p>You need to avoid triggering instance method lookup:</p>
<pre><code>for value in vars(self).values():
attr = getattr(value, 'cache_clear', None)
if... | 0 | 2016-08-16T08:29:31Z | [
"python"
] |
how to step into C++ code while debugging python using DDD(or gdb) | 38,969,859 | <p>For test example, I have this test C++ class which I exported to Python using boost.(from boost website)</p>
<pre><code>#include <boost/python.hpp>
using namespace boost::python;
struct WorldC
{
void set(std::string msg) { this->msg = msg; }
std::string greet() { return msg; }
std::string msg;... | 4 | 2016-08-16T08:19:31Z | 39,012,199 | <p>I posted an answer for debugging C++ while running python program. </p>
<p><a href="http://stackoverflow.com/questions/38898459/debugging-python-and-c-exposed-by-">debugging python and c++ exposed by boost together</a>
boost-together/39012185#39012185</p>
| 0 | 2016-08-18T07:24:16Z | [
"python",
"c++",
"boost",
"gdb",
"ddd-debugger"
] |
Receive return value from different thread in another module | 38,969,928 | <p>I am trying to replicate <code>C#</code> code in <code>python</code> which executes a thread, waits for it to finish and returns a value. Essentially the method <code>RunAndWait</code> is in a helper class because a call to that method is being made multiple times.</p>
<p><code>C#</code> code is as follows:</p>
<p... | 0 | 2016-08-16T08:23:46Z | 38,970,155 | <p><code>threading</code> is a module. You likely mean to replace</p>
<pre><code>t = threading(group=None, target=CmdToRun, arg=q)
</code></pre>
<p>with </p>
<pre><code>t = threading.Thread(group=None, target=CmdToRun, args=(q,))
</code></pre>
<p><code>args</code> is an argument tuple.</p>
| 1 | 2016-08-16T08:35:23Z | [
"python",
"queue",
"ironpython",
"python-multithreading"
] |
Search and replace multiple specific sequences of elements in Python list/array | 38,969,984 | <p>I currently have 6 separate for loops which iterate over a list of numbers looking to match specific sequences of numbers within larger sequences, and replace them like this:</p>
<pre><code>[...0,1,0...] => [...0,0,0...]
[...0,1,1,0...] => [...0,0,0,0...]
[...0,1,1,1,0...] => [...0,0,0,0,0...]
</code></pre... | 0 | 2016-08-16T08:27:34Z | 38,970,350 | <pre><code># I would create a map between the string searched and the new one.
patterns = {}
patterns['010'] = '000'
patterns['0110'] = '0000'
patterns['01110'] = '00000'
# I would loop over the lists
lists = [[0,1,0,0,1,1,0,0,1,1,1,0]]
for lista in lists:
# i would join the list elements as a string
strin... | 2 | 2016-08-16T08:46:06Z | [
"python",
"arrays",
"list",
"design-patterns",
"iterator"
] |
Search and replace multiple specific sequences of elements in Python list/array | 38,969,984 | <p>I currently have 6 separate for loops which iterate over a list of numbers looking to match specific sequences of numbers within larger sequences, and replace them like this:</p>
<pre><code>[...0,1,0...] => [...0,0,0...]
[...0,1,1,0...] => [...0,0,0,0...]
[...0,1,1,1,0...] => [...0,0,0,0,0...]
</code></pre... | 0 | 2016-08-16T08:27:34Z | 38,970,429 | <p>While this question related to the questions <a href="http://stackoverflow.com/questions/425604/best-way-to-determine-if-a-sequence-is-in-another-sequence-in-python">Here</a> and <a href="http://stackoverflow.com/questions/2250633/python-find-a-list-within-members-of-another-listin-order">Here</a>, the question from... | 1 | 2016-08-16T08:49:54Z | [
"python",
"arrays",
"list",
"design-patterns",
"iterator"
] |
Change value of the selection field using on_change | 38,969,990 | <p>I am trying to change the value of my selection field using on_change. I have the code below.</p>
<p>.xml</p>
<pre><code><field name="product_id" on_change="onchange_partner_id_override(product_id, context)"
</code></pre>
<p>.py</p>
<pre><code>class sale_order_line(osv.osv):
_inherit = "sale.order.line"
... | 1 | 2016-08-16T08:27:49Z | 38,972,424 | <p>You need to override <code>product_id_change</code> method and specify the value of <code>price_select</code> field in <code>value</code> dict: </p>
<pre><code>def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
lang=False... | 2 | 2016-08-16T10:24:47Z | [
"python",
"openerp"
] |
Automatically update title of chart with matplotlib and pylab | 38,970,033 | <pre><code>import numpy as np
import matplotlib.pyplot as plt
%pylab inline
def fun (x): #piecewise functions
if x< -1:
return 2*x + 4
elif -1<= x <= 1:
return 2*x**2
elif x>1:
return 2
vfun = np.vectorize(fun)
a=-4 #as provided in question paper
b=5
N=50
x =... | -1 | 2016-08-16T08:30:02Z | 38,970,327 | <p>What about this?</p>
<pre><code>pylab.title("f(x) E ["+str(a)+","+str(b)+"], N="+str(N))
</code></pre>
<p>instead of</p>
<pre><code>pylab.title('My First Plot')
</code></pre>
| -1 | 2016-08-16T08:44:50Z | [
"python",
"matplotlib"
] |
Automatically update title of chart with matplotlib and pylab | 38,970,033 | <pre><code>import numpy as np
import matplotlib.pyplot as plt
%pylab inline
def fun (x): #piecewise functions
if x< -1:
return 2*x + 4
elif -1<= x <= 1:
return 2*x**2
elif x>1:
return 2
vfun = np.vectorize(fun)
a=-4 #as provided in question paper
b=5
N=50
x =... | -1 | 2016-08-16T08:30:02Z | 38,970,450 | <p>You can use <a href="https://docs.python.org/2/library/stdtypes.html#str.format" rel="nofollow">str.format()</a> to insert the current values of a, b and N:</p>
<pre><code>pylab.title('f(x) E [{0},{1}], N={2}'.format(a,b,N))
</code></pre>
| 1 | 2016-08-16T08:50:50Z | [
"python",
"matplotlib"
] |
Keeping format of text (.txt) files when reading and rewriting | 38,970,141 | <p>I have a <code>.txt</code> file containing formatting elements as <code>\n</code> for line breaks which I want to read and then rewrite its data until a specific line back to a new <code>.txt</code> file. My code looks like this:</p>
<pre><code>with open (filename) as f:
content=f.readlines()
with open("lf... | 1 | 2016-08-16T08:34:47Z | 38,970,454 | <p>You converted <code>content</code> to a string, while it's really a list of strings (lines).</p>
<p>Use <code>join</code> to convert the lines back to a string:</p>
<pre><code>file1.write(''.join(content))
</code></pre>
<p><code>join</code> is a string method, and it is activated in the example from an empty stri... | 3 | 2016-08-16T08:51:06Z | [
"python"
] |
win32gui.FindWindow Not finding window | 38,970,354 | <p>I'm trying to send a keystroke to an inactive TeraTerm Window using Pywin32. </p>
<p><a href="http://stackoverflow.com/a/38888131/3714940">This</a> answer led me to write this code:</p>
<pre><code>import win32gui
import win32con
import win32api
hwndMain = win32gui.FindWindow("Tera Term VT", None)
print hwndMain
h... | 1 | 2016-08-16T08:46:16Z | 38,970,546 | <p>The line </p>
<pre><code>shell.AppActivate("Tera Term VT")
</code></pre>
<p>works on the window title and therefore it works.<br>
You should be able to to the same with </p>
<pre><code>hwndMain = win32gui.FindWindow(None, "Tera Term VT")
</code></pre>
<p>that is, swapping the arguments so that it also works ba... | 1 | 2016-08-16T08:56:03Z | [
"python",
"windows",
"winapi",
"pywin32",
"teraterm"
] |
Heroku mLab MongoDB admin user not authorized for query in Flask application | 38,970,357 | <p>I have this section of code, which is part of my Flask application. I am using <code>flask_mongoengine</code>.</p>
<pre><code>app = Flask(__name__)
app.config.from_object('config')
db = MongoEngine(app)
from .models import *
@app.context_processor
def inject_config():
return dict(Config.objects.first(), vers... | 0 | 2016-08-16T08:46:20Z | 39,030,871 | <p>So, answering my own question: the issue was probably in the flask_mongoengine library. I switched to just mongoengine and it worked fine.</p>
| 0 | 2016-08-19T03:56:11Z | [
"python",
"mongodb",
"heroku",
"flask",
"flask-mongoengine"
] |
netCDF convert to NaN for conditional | 38,970,423 | <p>I want to convert values from a netCDF file into NaN called <code>LandMask_NaN</code> when they are greater than zero. However, there seems to be a type mismatch between <code>LandMask</code> and what numpy will convert to NaNs. Any help much appreciated, code and info below:</p>
<pre><code> import netCDF4 as nc
i... | 1 | 2016-08-16T08:49:45Z | 38,977,628 | <p>It'll be helpful if you share the netcdf file, but here are a few ideas of what's going on:</p>
<p>Variables are not currently being read-in as numpy arrays. You need to add indexing parameters to cast them to arrays. Without the file, I'm not sure what they are, but surely some are multi-dimensional. For example:... | 1 | 2016-08-16T14:30:28Z | [
"python",
"numpy",
null,
"netcdf4"
] |
Need to print the values of a dictionary by calling the keys within a range | 38,970,435 | <p>I made a dictionary with </p>
<pre><code>key = integer
value = string
</code></pre>
<p>I would like to make an .exe (probably it's a bit early for my level) where I can input 2 integers and it would print the values of the keys within the range I specified. ... | 0 | 2016-08-16T08:50:09Z | 38,970,536 | <p>The solution is quite short:</p>
<pre><code># this is your dictionary
d = {1: 'General 001-002', 3: 'Computer science', 7: .....}
start = 5
stop = 85
values = [d[k] for k in range(start, stop + 1) if k in d]
</code></pre>
<p>You get what you need in <code>values</code> - a list.</p>
<p>I omitted most of the dic... | 1 | 2016-08-16T08:55:27Z | [
"python",
"dictionary",
"exe"
] |
Need to print the values of a dictionary by calling the keys within a range | 38,970,435 | <p>I made a dictionary with </p>
<pre><code>key = integer
value = string
</code></pre>
<p>I would like to make an .exe (probably it's a bit early for my level) where I can input 2 integers and it would print the values of the keys within the range I specified. ... | 0 | 2016-08-16T08:50:09Z | 38,972,718 | <p>If the key integers are much larger than the number of items in the dictionary it may be inefficient to loop over every integer in the range looking for keys that are present in the dictionary. An alternative strategy is to filter the keys of the dictionary, sort them, and then build a list of the desired values. Eg... | 0 | 2016-08-16T10:39:19Z | [
"python",
"dictionary",
"exe"
] |
Change xaxis range values in a plot with matplotlib | 38,970,515 | <p>I am doing a plot of dataframe df_no_missing.</p>
<pre><code>df_no_missing.head()
TIMESTAMP datetime64[ns]
P_ACT_KW float64
PERIODE_TARIF object
P_SOUSCR float64
SITE object
TARIF object
depassement float64
dtype: obj... | 2 | 2016-08-16T08:54:28Z | 38,972,469 | <p>You can add <code>set_major_locator</code> before <code>set_major_formatter</code>:</p>
<pre><code>import matplotlib.dates as mdates
yearFmt = mdates.DateFormatter("%H:%M:%S")
minx = pd.to_datetime( '2015-08-01 23:10:00' )
minx = pd.to_datetime( '2015-08-01 23:50:00' )
ax.set_xlim( [ minx, maxx ] )
ax.xaxis.set_... | 0 | 2016-08-16T10:26:34Z | [
"python",
"matplotlib",
"plot"
] |
PyInstaller, onefile, no console. missing bootloader error | 38,970,626 | <p>I'm trying to compile my Kivy applications to a single windows exe. </p>
<p>A sample of my .spec file:</p>
<pre><code>from kivy.deps import sd12, glew
exe = EXE(pyz,Tree('C:\\Users\\me\\PycharmProjects\\test\\'),
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
*[Tree(... | 0 | 2016-08-16T08:59:19Z | 38,971,797 | <p>Missing runw file in bootloader windows 32</p>
| 1 | 2016-08-16T09:54:23Z | [
"python",
"kivy",
"pyinstaller"
] |
python merge multiple xmls to single CSV | 38,970,641 | <p>Here's a snippet from a script I'm trying to put together to make my life easier. I have a bunch of XML files from different API sources. They have different items in them and different amount of fields. What they do all have in common is a common field like "clientid". </p>
<p>What I want to do is end up with a CS... | 0 | 2016-08-16T09:00:15Z | 38,982,496 | <p>Consider iterating across the three files and conditionally check for client ids. Parse xml values to a list that you write to csv file:</p>
<pre><code>import csv
import xml.etree.ElementTree as ET
def parseXML():
projecttree = ET.parse('projects.xml')
clienttree = ET.parse('clients.xml')
teamtasktree... | 0 | 2016-08-16T18:56:45Z | [
"python",
"xml",
"csv",
"merge"
] |
python merge multiple xmls to single CSV | 38,970,641 | <p>Here's a snippet from a script I'm trying to put together to make my life easier. I have a bunch of XML files from different API sources. They have different items in them and different amount of fields. What they do all have in common is a common field like "clientid". </p>
<p>What I want to do is end up with a CS... | 0 | 2016-08-16T09:00:15Z | 39,049,541 | <p>Additionally, consider <a href="https://www.w3.org/Style/XSL/" rel="nofollow">XSLT</a>, the special purpose transformation language that can directly transform XML to CSV even parsing from other XML files using its <code>document()</code> function. Python's <a href="http://lxml.de/" rel="nofollow">lxml</a> module ca... | 0 | 2016-08-20T01:05:35Z | [
"python",
"xml",
"csv",
"merge"
] |
I cant to run my script automatically (cron) Raspberry Pi | 38,970,659 | <p>I need to run my script <code>time.py</code> every day.
I execute <code>crontab -e</code> and add</p>
<pre><code>15 19 * * * pi /usr/bin/python /home/Desktop/miBBDD/time.py
</code></pre>
<p>So my script should run every day at 19:15, but it doesn't.
If I execute <code>service cron status</code> I can see:<code>act... | 0 | 2016-08-16T09:00:58Z | 38,971,284 | <p>Have you edited the crontab with sudo? </p>
<p>Do a quick test: include a line in the crontab (sudo crontab -e) that calls a test line every minute, for example:</p>
<pre><code>* * * * * logger "Is it working?"
</code></pre>
<p>This line will execute every minute and you should see the result of it at /var/log/s... | 0 | 2016-08-16T09:30:50Z | [
"python",
"linux",
"cron",
"raspberry-pi2"
] |
I cant to run my script automatically (cron) Raspberry Pi | 38,970,659 | <p>I need to run my script <code>time.py</code> every day.
I execute <code>crontab -e</code> and add</p>
<pre><code>15 19 * * * pi /usr/bin/python /home/Desktop/miBBDD/time.py
</code></pre>
<p>So my script should run every day at 19:15, but it doesn't.
If I execute <code>service cron status</code> I can see:<code>act... | 0 | 2016-08-16T09:00:58Z | 38,971,515 | <p>I had similar issue some time ago. Delete the user part of your crontab file. </p>
<pre><code>15 19 * * * /usr/bin/python /home/Desktop/miBBDD/time.py
</code></pre>
<p>Compare with <a href="http://unix.stackexchange.com/questions/278486/crontab-task-not-trigerred/278930#278930">this answear</a>.</p>
<p>EDIT: just... | 0 | 2016-08-16T09:41:51Z | [
"python",
"linux",
"cron",
"raspberry-pi2"
] |
After creating NAN category, aggregation on groupby object went wrong | 38,970,712 | <p>I first create some data:</p>
<pre><code>df = pd.DataFrame(data = {"A":np.random.random_integers(1,10,10), "B":np.arange(1,11,1)})
df.A.ix[3,4] = np.nan
</code></pre>
<p>Then I got a pd dataframe with Nans</p>
<pre><code> A B
0 7 1
1 1 2
2 3 3
3 NaN 4
4 NaN 5
5 9 6
6 2 7
7 10 8
8 ... | 2 | 2016-08-16T09:04:05Z | 38,970,884 | <p><code>'count'</code> is going to skip <code>NaN</code>. You can use <code>'size'</code></p>
<pre><code>df.groupby(bin_S).agg(["size"])
</code></pre>
<p><a href="http://i.stack.imgur.com/9NeH6.png" rel="nofollow"><img src="http://i.stack.imgur.com/9NeH6.png" alt="enter image description here"></a></p>
| 3 | 2016-08-16T09:12:41Z | [
"python",
"pandas"
] |
Why i get wrong amount of documents? | 38,970,724 | <p>I need to find all users (unique ids) who has done 2 events "Level 1" and "Purchase Hard"</p>
<pre><code>x = list(db.events.distinct("uid", {"eventName": "Level 1"}) and db.events.distinct("uid", {"eventName": "Purchase Hard"}))
</code></pre>
<p>This code as a result gives around 1600 documents so as a result i sh... | 0 | 2016-08-16T09:04:42Z | 38,970,906 | <p>You are getting a fewer documents because your <strong><a href="https://docs.mongodb.com/manual/reference/operator/aggregation/match/#pipe._S_match" rel="nofollow"><code>$match</code></a></strong> filter is excluding the other event "Purchase Hard". You need to include it with the other event using the <strong><a hr... | 0 | 2016-08-16T09:13:34Z | [
"python",
"mongodb"
] |
How to decode a mime part of a message and get a **unicode** string in Python 2.7? | 38,970,760 | <p>Here is a method which tries to get the html part of an email message:</p>
<pre><code>from __future__ import absolute_import, division, unicode_literals, print_function
import email
html_mail_quoted_printable=b'''Subject: =?ISO-8859-1?Q?WG=3A_Wasenstra=DFe_84_in_32052_Hold_Stau?=
MIME-Version: 1.0
Content-type: m... | 3 | 2016-08-16T09:06:12Z | 39,063,834 | <blockquote>
<p>Unfortunately I get a byte string. I would like to have unicode string.</p>
</blockquote>
<p>The <code>decode=True</code> parameter to <code>get_payload</code> only decodes the <code>Content-Transfer-Encoding</code> wrapper, the <code>=</code>-encoding in this message. To get from there to characters... | 4 | 2016-08-21T11:46:33Z | [
"python",
"python-2.7",
"email",
"unicode"
] |
How can we append unbalanced row on Pandas dataframe in the fastest way? | 38,970,767 | <p>I am going to make pandas dataframe from unbalanced csv file</p>
<p>But the speed is too slow when I make it in a brute force way.</p>
<p>Here, I have the list of columns which can make Schema of Dataframe</p>
<p>And a bunch of rows in a file.</p>
<p>How could I make it fast?</p>
<p>(Should I make empty list in... | 2 | 2016-08-16T09:06:38Z | 38,971,477 | <p><code>pd.DataFrame</code> can build a DataFrame from a list of ragged rows:</p>
<pre><code>In [17]: pd.DataFrame([['a','b'],[1,2,3]])
Out[17]:
0 1 2
0 a b NaN
1 1 2 3.0
</code></pre>
<p>Moreover, it is faster to build the DataFrame with one call to <code>pd.DataFrame</code>
than many calls to <code>n... | 2 | 2016-08-16T09:39:52Z | [
"python",
"performance",
"pandas"
] |
Session data corrupted in django | 38,970,832 | <p>Every time when I'm going to my signup page, I'm receiving this error </p>
<pre><code>Session data corrupted
</code></pre>
<p>when I'm trying to signup anyway, POST request status is 302, but User is still created, but didn't save any email to registered user.</p>
<p>Why I'm getting that error and how can I fix ... | 1 | 2016-08-16T09:09:49Z | 38,972,036 | <p>You are getting this error because of this line: <a href="https://github.com/django/django/blob/master/django/contrib/sessions/backends/base.py#L109" rel="nofollow">https://github.com/django/django/blob/master/django/contrib/sessions/backends/base.py#L109</a></p>
<p>Apparently, there's something went terribly wrong... | 0 | 2016-08-16T10:06:19Z | [
"python",
"django",
"session"
] |
Session data corrupted in django | 38,970,832 | <p>Every time when I'm going to my signup page, I'm receiving this error </p>
<pre><code>Session data corrupted
</code></pre>
<p>when I'm trying to signup anyway, POST request status is 302, but User is still created, but didn't save any email to registered user.</p>
<p>Why I'm getting that error and how can I fix ... | 1 | 2016-08-16T09:09:49Z | 39,729,372 | <p>Sorry for getting late to this post, but by any chance, are you changing or did you changed the SECRET_KEY variable on your project, sessions used to be cyphered using this salt, so if you changed it your corrupted all your sessions, is not a big deal, sessions that were existing before this needs to log-in again</p... | 0 | 2016-09-27T16:03:01Z | [
"python",
"django",
"session"
] |
pass array of dictionaries to python | 38,970,840 | <p>I have a bash script that builds a dictionary kind of structure for multiple iterations as shown below:</p>
<pre><code>{ "a":"b", "c":"d", "e":"f"}
{ "a1":"b1", "c1":"d1", "e1":"f1", "g1":"h1" }
</code></pre>
<p>I have appended all of them to an array in shell script and they are to be fed as an input to python sc... | -1 | 2016-08-16T09:10:08Z | 38,971,335 | <p>seems problem of <code>plot_graph $var</code></p>
<p>The following code should work:</p>
<pre><code>var="({ 'a':'b', 'c':'d', 'e':'f'} { 'a1':'b1', 'c1':'d1', 'e1':'f1', 'g1':'h1' })"
echo $var
function plot_graph {
echo $1
RESULT="$1" python - <<END
from __future__ import print_function
import os
impo... | 0 | 2016-08-16T09:33:20Z | [
"python",
"arrays",
"dictionary"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.