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
Listing third party libraries in project
38,848,834
<p>I've been working on a Python project for a while which uses quite some third party libraries. I want to deploy my project to another server, but I don't know by heart which projects I use and digging through every line of source code would be too much work.</p> <p>Is there a way to generate a list of <strong>third...
2
2016-08-09T10:56:07Z
38,848,876
<p>Provided that you're using a virtual environment to keep your dependencies separate from the globally installed pip packages, you should be able to use pip's <code>freeze</code> command, like so:</p> <pre><code>pip freeze &gt; dependencies.txt </code></pre> <p>If you haven't been using a virtual environment, then ...
1
2016-08-09T10:58:21Z
[ "python", "pip" ]
google api client python import taskqueue
38,848,896
<p>python version <code>2.7.9</code></p> <p>installed version <code>1.5.1</code></p> <p><code>pip install --upgrade google-api-python-client</code></p> <p>from <a href="https://cloud.google.com/appengine/docs/python/taskqueue/push/creating-tasks" rel="nofollow">here</a> trying to import task queue like so </p> <pre...
1
2016-08-09T10:58:55Z
38,853,148
<p>The <a href="https://cloud.google.com/sdk/release_notes" rel="nofollow">Google Cloud SDK - Release Notes</a> tracks the version of the GAE components, search for the <code>App Engine components updated to</code> pattern.</p> <p>The version of the most recent GAE components in the current Cloud SDK version (120.0.0)...
0
2016-08-09T14:10:25Z
[ "python", "google-app-engine", "pip", "google-cloud-sdk" ]
google api client python import taskqueue
38,848,896
<p>python version <code>2.7.9</code></p> <p>installed version <code>1.5.1</code></p> <p><code>pip install --upgrade google-api-python-client</code></p> <p>from <a href="https://cloud.google.com/appengine/docs/python/taskqueue/push/creating-tasks" rel="nofollow">here</a> trying to import task queue like so </p> <pre...
1
2016-08-09T10:58:55Z
38,970,027
<p>I have downloaded the sdk from here <a href="https://cloud.google.com/appengine/downloads" rel="nofollow">https://cloud.google.com/appengine/downloads</a></p> <p>after downloaded added it to my project source files .</p> <p>and added the path to the home directory in my python code like so </p> <pre><code>import ...
0
2016-08-16T08:29:40Z
[ "python", "google-app-engine", "pip", "google-cloud-sdk" ]
Get specific file with glob
38,849,001
<p>I am trying to locate a specific .xml file with glob. But the path comes from an object, and it doesn't seem to work.</p> <p>I followed this example: <a href="http://stackoverflow.com/questions/3608411/python-how-can-i-find-all-files-with-a-particular-extension">Python: How can I find all files with a particular ex...
-1
2016-08-09T11:03:59Z
38,849,033
<pre><code>glob.glob(ren_folder+'/'s*.xml) </code></pre> <p>You are closing the flie name string prematurely, it should be:</p> <pre><code>glob.glob(ren_folder+'/s*.xml') </code></pre>
2
2016-08-09T11:05:52Z
[ "python", "xml", "glob" ]
Get specific file with glob
38,849,001
<p>I am trying to locate a specific .xml file with glob. But the path comes from an object, and it doesn't seem to work.</p> <p>I followed this example: <a href="http://stackoverflow.com/questions/3608411/python-how-can-i-find-all-files-with-a-particular-extension">Python: How can I find all files with a particular ex...
-1
2016-08-09T11:03:59Z
38,849,037
<p>Does this work?</p> <pre><code>glob.glob(os.path.join(ren_folder, 's*.xml')) </code></pre>
1
2016-08-09T11:05:58Z
[ "python", "xml", "glob" ]
Recursively read through a folder tree and determine which folders have files
38,849,190
<p>I've written a program to look through images inside a folder and extract the embedded EXIF data. Currently I'm using the code below to get paths for all the files inside a folder, the variable 'folder_name' is input by the user. The list created is then used by the program to cycle through all the images.</p> <pre...
0
2016-08-09T11:13:00Z
38,849,357
<p>You can work around case-sensitivity by applying the <code>.lower()</code> string method to both strings before comparing them.</p>
0
2016-08-09T11:23:05Z
[ "python", "python-2.7", "folders" ]
Recursively read through a folder tree and determine which folders have files
38,849,190
<p>I've written a program to look through images inside a folder and extract the embedded EXIF data. Currently I'm using the code below to get paths for all the files inside a folder, the variable 'folder_name' is input by the user. The list created is then used by the program to cycle through all the images.</p> <pre...
0
2016-08-09T11:13:00Z
38,849,367
<p>You can try <a href="https://docs.python.org/2/library/os.html#os.walk" rel="nofollow">os.walk</a> + <a href="https://docs.python.org/2/library/mimetypes.html#mimetypes.guess_type" rel="nofollow">mimetypes.guess_type</a> like so</p> <pre><code>import os import os.path import mimetypes top="." imagefiles=[] for root...
1
2016-08-09T11:23:31Z
[ "python", "python-2.7", "folders" ]
Sqlalchemy.exc.OperationalError: (psycopg2.OperationalError)
38,849,252
<p>My Flask app(postgresql db) is working fine in local. I pushed my code to server and there I tried to <code>run.py db migrate</code>, it throws me these errors</p> <pre><code>Traceback (most recent call last): File "run.py", line 11, in &lt;module&gt; create_app().run() File "/usr/local/lib/python2.7/dist-p...
0
2016-08-09T11:17:44Z
38,972,526
<p>Fixed it with a `sudo. </p> <pre><code>sudo run.py db migrate </code></pre> <p>I know it is weird but yes, sudo did the trick</p>
0
2016-08-16T10:29:30Z
[ "python", "postgresql", "flask-sqlalchemy", "flask-restful" ]
Matplotlib: How to make a dotted line consisting of dots (circles)?
38,849,258
<p>I have two smooth dependences y1(x) and y2(x) where x's are distributed irregularly. I want these dependences to be described with dotted lines (<code>linestyle = ':'</code>). What i get now in a *.pdf file is shown <a href="http://i.stack.imgur.com/s9qPA.png" rel="nofollow">here</a>:</p> <p>Here's the code:</p> <...
2
2016-08-09T11:18:14Z
38,854,746
<p>Remove <code>linewidth</code>. Then it prints little squares - good enough?</p> <p>You can also round-off the squares with <code>dash_capstyle = "round"</code>.</p>
0
2016-08-09T15:24:22Z
[ "python", "matplotlib" ]
How to jump on specific Page usinig Beautifulsoup
38,849,300
<p>I want to get data for Product which are search by user in python.I am able to get data from any Urls but depending upon search Jump on that page and Get data Using beautifulsoup.</p> <p>I Try this for get data : </p> <pre><code>from bs4 import BeautifulSoup import requests import urllib2 url="http://amazon.in" ...
0
2016-08-09T11:20:16Z
38,856,198
<p>You just need to do a get request passing the correct params:</p> <pre><code>import requests from bs4 import BeautifulSoup params = {"url":"search-alias=aps","field-keywords":"iphone 5"} url = "http://www.amazon.in/s/ref=nb_sb_noss_2" soup = BeautifulSoup(requests.get(url, params=params).content) ul = soup.selec...
0
2016-08-09T16:37:28Z
[ "python", "beautifulsoup", "web-crawler" ]
Python flask use buttons to trigger scripts
38,849,318
<p>I was investigating the web, mainly getting my self confused about several things.</p> <p>First - what I need. my company runs java applications on our linux servers that non technological people uses. sometimes we have to restart those programs, but first kill them.</p> <p>I've built small tool (runs on linux) th...
0
2016-08-09T11:21:32Z
38,886,090
<p>Take a look at the example below I hope that helps</p> <p>if you are using inline javascript, then you don't have to use this variable and can access <code>url_for()</code> from the ajax request. If you are using a separate javascript file, then you have to put this variable in your template since <code>.js</code> ...
0
2016-08-11T01:52:41Z
[ "python", "linux", "button", "flask", "webpage" ]
how to call python method from server action in odoo 9
38,849,404
<p>I want try to call the python method from server action in same module . but there is no error found but the method is not called . I also follow this link <a href="https://www.odoo.com/forum/help-1/question/how-to-open-a-form-with-ir-action-server-which-executes-python-code-61910" rel="nofollow">for call the python...
1
2016-08-09T11:25:41Z
38,866,996
<pre><code> &lt;!-- server action : can be called from menu and open a view from a python methode so we can change --&gt; &lt;!-- server action : the context of the action --&gt; &lt;record id="idOfServerAction" model="ir.actions.server"&gt; &lt;field name="name"&gt;Action Title&lt;/fi...
0
2016-08-10T07:35:39Z
[ "python", "xml", "odoo-9" ]
how to call python method from server action in odoo 9
38,849,404
<p>I want try to call the python method from server action in same module . but there is no error found but the method is not called . I also follow this link <a href="https://www.odoo.com/forum/help-1/question/how-to-open-a-form-with-ir-action-server-which-executes-python-code-61910" rel="nofollow">for call the python...
1
2016-08-09T11:25:41Z
38,919,683
<p>I got the answer , when you want to trigger any server action you just follow this code , that may be help you .</p> <p>.xml </p> <pre><code>&lt;record id="action_email_data_parser_server" model="ir.actions.server" &gt; &lt;field name="name"&gt;[Server Action] Create Leads from Mail&lt;/field&gt; &lt;field...
1
2016-08-12T13:51:24Z
[ "python", "xml", "odoo-9" ]
Python: reading float80 values
38,849,469
<p>I have an array of 10-bytes (80-bits) Little Endian float values (or <code>float80</code>). How can i read this values in python 3?</p> <p>The package <code>struct</code> does not support <code>float80</code> (may be I read the docs carelessly).</p> <p>The package <code>array</code> as same as package "struct" doe...
2
2016-08-09T11:28:23Z
38,850,175
<p>Let me rewrite my answer in a more logical way:</p> <p><code>ctypes c_longdouble</code> is machine dependent because the longdouble float type is not set in stone by the C standard and is dependent on the compiler :( but it is still your best you can have right now for high precision floats...</p> <p>If you plan t...
2
2016-08-09T12:02:43Z
[ "python", "floating-point", "long-double" ]
Python: reading float80 values
38,849,469
<p>I have an array of 10-bytes (80-bits) Little Endian float values (or <code>float80</code>). How can i read this values in python 3?</p> <p>The package <code>struct</code> does not support <code>float80</code> (may be I read the docs carelessly).</p> <p>The package <code>array</code> as same as package "struct" doe...
2
2016-08-09T11:28:23Z
39,785,867
<p><code>numpy</code> <a href="http://docs.scipy.org/doc/numpy-dev/user/basics.types.html#extended-precision" rel="nofollow">can use 80-bit float if the compiler and platform support them</a>:</p> <blockquote> <p>Whether [supporting higher precision] is possible in numpy depends on the hardware and on the developm...
0
2016-09-30T07:20:46Z
[ "python", "floating-point", "long-double" ]
Compare two excel files in Pandas and return the rows which have the same values in TWO columns
38,849,538
<p>I have a couple of excel files. Both the files have two common columns: Customer_Name and Customer_No. The first excel file has around 800k rows while the second has only 460. I want to get a dataframe which has the common data in both the files, ie obtain the rows from the first file that has both the Customer_Name...
-1
2016-08-09T11:31:50Z
38,849,591
<p>Use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.merge.html" rel="nofollow"><code>merge</code></a>:</p> <pre><code>df = pd.merge(df1, df2, on=['Customer_Name','Customer_No']) </code></pre> <p>If you have different column names use <code>left_on</code> and <code>right_on</code>:</p> <pre><...
2
2016-08-09T11:34:09Z
[ "python", "excel", "python-2.7", "pandas" ]
Compare two excel files in Pandas and return the rows which have the same values in TWO columns
38,849,538
<p>I have a couple of excel files. Both the files have two common columns: Customer_Name and Customer_No. The first excel file has around 800k rows while the second has only 460. I want to get a dataframe which has the common data in both the files, ie obtain the rows from the first file that has both the Customer_Name...
-1
2016-08-09T11:31:50Z
38,849,663
<p>IIUC and you don't need extra columns from the second file - it will be used just for joining, you can do it this way:</p> <pre><code>common_cols = ['Customer_Name','Customer_No'] df = (pd.read_excel(filename1) .join(pd.read_excel(filename2, usecols=common_cols), on=common_cols)...
0
2016-08-09T11:37:39Z
[ "python", "excel", "python-2.7", "pandas" ]
Compare two excel files in Pandas and return the rows which have the same values in TWO columns
38,849,538
<p>I have a couple of excel files. Both the files have two common columns: Customer_Name and Customer_No. The first excel file has around 800k rows while the second has only 460. I want to get a dataframe which has the common data in both the files, ie obtain the rows from the first file that has both the Customer_Name...
-1
2016-08-09T11:31:50Z
38,849,772
<p>I think the direct way will be like this:</p> <pre><code>df_file1 = pd.read_csv(file1, index_col) # set Customer_No df_file2 = pd.read_csv(file2, index_col) # set Customer_No for index, row in df_file1.iterrows(): if row.get_value('Customer_name) in df_file2['Customer_name'].values: </code></pre> <p>here you c...
0
2016-08-09T11:42:53Z
[ "python", "excel", "python-2.7", "pandas" ]
Joint two array to one array?
38,849,653
<p>a:</p> <pre><code>[[1,2,3], [4,5,6]] </code></pre> <p>b:</p> <pre><code>[[7,8,9], [10,11,12]] </code></pre> <p>How can I get an array like:</p> <pre><code>[[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]] </code></pre> <p>using a and b?</p>
-3
2016-08-09T11:37:08Z
38,850,275
<p>You can use <a href="https://docs.python.org/3/tutorial/datastructures.html" rel="nofollow">python's append method</a>:</p> <pre><code>x = [] x.append(a) x.append(b) </code></pre> <p>Or in short (mentioned by @Kasramvd in the comments):</p> <pre><code>x = [a, b] </code></pre>
2
2016-08-09T12:07:37Z
[ "python" ]
Joint two array to one array?
38,849,653
<p>a:</p> <pre><code>[[1,2,3], [4,5,6]] </code></pre> <p>b:</p> <pre><code>[[7,8,9], [10,11,12]] </code></pre> <p>How can I get an array like:</p> <pre><code>[[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]] </code></pre> <p>using a and b?</p>
-3
2016-08-09T11:37:08Z
38,850,350
<p>You can use the append over empty list to add as many list as you want. See below example.</p> <pre><code>&gt;&gt;&gt; final_list = [] &gt;&gt;&gt; a = [[1,2,3], [4,5,6]] &gt;&gt;&gt; b = [[7,8,9], [10,11,12]] &gt;&gt;&gt; final_list.append(a) &gt;&gt;&gt; final_list.append(b) &gt;&gt;&gt; final_list [[[1,2,3],[4,5...
0
2016-08-09T12:10:12Z
[ "python" ]
Joint two array to one array?
38,849,653
<p>a:</p> <pre><code>[[1,2,3], [4,5,6]] </code></pre> <p>b:</p> <pre><code>[[7,8,9], [10,11,12]] </code></pre> <p>How can I get an array like:</p> <pre><code>[[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]] </code></pre> <p>using a and b?</p>
-3
2016-08-09T11:37:08Z
38,852,351
<p>As mentioned by other answers, if you want <code>[[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]]</code>, call <code>append</code> or simply write <code>c = [a, b]</code>.</p> <p>However, the title reads "<strong>Joint</strong> two array to one array?", so I suppose what you actually expect is <code>[[1,2,3],[4,5,6],[7,8,9...
0
2016-08-09T13:36:32Z
[ "python" ]
parse date-time while reading 'csv' file with pandas
38,849,676
<p>I am trying to parse dates while I am​ reading my data from cvs file. The command that I use is </p> <pre><code>df = pd.read_csv('/Users/n....', names=names, parse_dates=['date'])​ ) </code></pre> <p>And it is working on my files generally. But I have couple of data sets which has variety in date formats. I...
1
2016-08-09T11:38:15Z
38,849,974
<p>Like this:</p> <pre><code>df = pd.read_csv(file, names=names) df['date'] = pd.to_datetime(df['date]) </code></pre>
0
2016-08-09T11:52:26Z
[ "python", "date", "csv", "pandas" ]
parse date-time while reading 'csv' file with pandas
38,849,676
<p>I am trying to parse dates while I am​ reading my data from cvs file. The command that I use is </p> <pre><code>df = pd.read_csv('/Users/n....', names=names, parse_dates=['date'])​ ) </code></pre> <p>And it is working on my files generally. But I have couple of data sets which has variety in date formats. I...
1
2016-08-09T11:38:15Z
38,850,852
<p>Pandas <code>read_csv</code> accepts <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html" rel="nofollow"><code>date_parser</code></a> argument which you can define your own date parsing function. So for example in your case you have 2 different datetime formats you can simply do:</p> ...
1
2016-08-09T12:31:27Z
[ "python", "date", "csv", "pandas" ]
pandas applying multicolumnindex to dataframe
38,849,812
<p>The situation is that I have a few files with time_series data for various stocks with several fields. each file contains</p> <pre><code>time, open, high, low, close, volume </code></pre> <p>the goal is to get that all into one dataframe of the form</p> <pre><code>field open high...
1
2016-08-09T11:44:49Z
38,850,014
<p>I think you can first get all files to list <code>files</code>, then with list comprehension get all DataFrames and <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.concat.html" rel="nofollow"><code>concat</code></a> them by columns <code>(axis=1)</code>. If add parameter <code>keys</code>, you ...
1
2016-08-09T11:54:01Z
[ "python", "pandas", "indexing" ]
Django dates getting sorted wrong DRF
38,849,826
<p>I have a django models-</p> <pre><code>class CompanyForLineCharts(models.Model): company = models.TextField(null=True) class LineChartData(models.Model): foundation = models.ForeignKey(CompanyForLineCharts, null=True) date = models.DateField(auto_now_add=False) price = models.FloatField(null=True) </code><...
1
2016-08-09T11:45:28Z
38,851,054
<p>@edit I'm sorry, but it shouldn't change anything I just checked Documentation and default values of <code>auto_now_add</code> and <code>auto_now</code> are <code>False</code>. <br><br> <code>DateField(auto_now_add=False)</code> -> <code>DateField(auto_now_add=False, auto_now=False)</code> should solve your problem....
0
2016-08-09T12:41:06Z
[ "python", "django", "date", "django-rest-framework" ]
From hexadecimal string to character (jis encoding)
38,849,828
<p>I have an hexadecimal string "\x98\x4F" that is the JIS encoding of the japanese kanji 楼.<br> How can I print the kanji in python starting from the encoding?<br> I tried </p> <pre><code>print b'\x98\x4F'.encode('euc_jp') </code></pre> <p>but without success... any clue? Regards</p>
1
2016-08-09T11:45:34Z
38,849,995
<p>In Python 2 use <code>str.decode()</code> with the <code>shift-jis</code> encoding:</p> <pre><code>&gt;&gt;&gt; s = "\x98\x4F".decode('shift-jis') &gt;&gt;&gt; s u'\u697c' &gt;&gt;&gt; print s 楼 </code></pre> <p>This <em>decodes</em> the jis encoded data into a Python unicode string. Printing that string display...
1
2016-08-09T11:53:19Z
[ "python", "encoding" ]
Using arabic characters in sparql in python?
38,849,861
<p>I developed my own ontology in arabic, and now i wanna do some sparql request using <strong>rdflib</strong> and <strong>sparql</strong>. The problem is when i make a request without using the Arabic language on my ontology i got answers without problems ,but when i want to do a specific request on properties using t...
0
2016-08-09T11:47:28Z
38,855,698
<p>i found the correct syntax for that :).</p> <p>i just change this line:</p> <pre><code>"FILTER(regex(?ministere_lord,'وزارة المالية'))}", ) </code></pre> <p>by this one:</p> <pre><code>"FILTER (regex(?ministere_lord,'""" +u"وزارة المالية"+ """')) }""" , ) </code></pre> <p>so the sparql ...
0
2016-08-09T16:10:00Z
[ "python", "sparql", "arabic", "rdflib" ]
Django forgets .using database on resolving foreign key
38,849,878
<p>I have a model for my legacy database created by manage.py inspectdb, which accesses the database named 'edlserver' in settings, one of many databases used for the project. I cannot change the database layout.</p> <p>It has the following classes (among other irrelevant ones):</p> <p>One for Logging entries.</p> <...
2
2016-08-09T11:48:14Z
38,850,051
<p>The problem is that obj here is an instance of <code>Logs</code></p> <pre><code>def get_job_name(self, obj): return obj['id_job__id_job_type__name'] </code></pre> <p>Django models look like dictionaries, smell like dictionaries but they are not dictionaries. The correct usage is:</p> <pre><code> return obj.jo...
1
2016-08-09T11:56:19Z
[ "python", "mysql", "django", "django-rest-framework", "serializer" ]
Django forgets .using database on resolving foreign key
38,849,878
<p>I have a model for my legacy database created by manage.py inspectdb, which accesses the database named 'edlserver' in settings, one of many databases used for the project. I cannot change the database layout.</p> <p>It has the following classes (among other irrelevant ones):</p> <p>One for Logging entries.</p> <...
2
2016-08-09T11:48:14Z
38,850,368
<p>Foreign keys add an attribute to the model that is itself a model instance. To follow the complete relation from <code>Logs</code> to <code>JobType</code>, simply use attribute lookups:</p> <pre><code>def get_job_name(self, obj): return obj.job.job_type.name </code></pre> <p>This would be the normal use-case. ...
2
2016-08-09T12:10:54Z
[ "python", "mysql", "django", "django-rest-framework", "serializer" ]
Python K-medoids visualisation
38,849,906
<p>This code I get from the internet. I apply to my data and work. So I try to show the visualisation of this method but I can't find the relevant code of visualisation for the k-medoids.</p> <pre><code>from nltk.metrics import distance as distance import Pycluster as PC words = ['apple', 'Doppler', 'applaud', 'append...
-2
2016-08-09T11:49:30Z
38,852,486
<p>Your input data are <em>words</em>.</p> <p>How would you visualize them? They are not coordinate vectors.</p>
0
2016-08-09T13:42:59Z
[ "python", "cluster-analysis" ]
Curious behaviour while writing to files
38,849,913
<p>I have a question about Python's behavior while opening and writing data in files. I have a large code that is built to run even for hours and it involves writing text in ASCII files. The code uses the <code>with open</code> method and keeps a file open during the program's run. Sometimes I need to stop the executio...
1
2016-08-09T11:49:53Z
38,850,023
<p>For a start, you might want to ensure that you're indeed writing to the disk, instead of to a buffer.</p> <p>One way of doing so is by using <code>infile2.flush()</code>:</p> <pre><code>infile2.write(str(b)) infile2.flush() # &lt;- here print "Writing completed!" </code></pre> <p>A different way is to <a href="ht...
1
2016-08-09T11:54:40Z
[ "python", "file-io", "with-statement" ]
Loading dynamic model attributes in the form - django
38,849,987
<p>So I'm building an Ads app. Basically, users log in, and they can post an ad for something. I've posted the models below but basically I have a category (say, electronics or real estate), then a subcategory(electronics->Laptop or real estate-> house,apartment etc.) The problem is, different items have different att...
1
2016-08-09T11:53:02Z
38,850,313
<p>JSONFields are good for structured metadata that Python won't introspect very often.</p> <p>In your case I would suggest creating another table for field configuration, link this table to category and have a table for values in products. In a simplified form:</p> <pre><code>class CategoryAtrribute(models.Model): ...
1
2016-08-09T12:09:05Z
[ "python", "django", "django-forms", "django-views" ]
How do i change color based on value of an HTML table generated from a pd.DataFrame using to_html
38,849,992
<p>I have a pandas dataFrame which I am converting to an HTML table using <code>to_html()</code> however I would like to color certain cells based on values in the HTML table that I return. </p> <p>Any idea how to go about this? </p> <p>Eg: All cells in a column called 'abc' that have a value greater than 5 must appe...
2
2016-08-09T11:53:18Z
38,857,277
<p>here is one way to do this:</p> <pre><code>df = pd.DataFrame(np.random.randint(0,10, (5,3)), columns=list('abc')) def color_cell(cell): return 'color: ' + ('red' if cell &gt; 5 else 'green') html = df.style.applymap(color_cell, subset=['a']).render() with open('c:/temp/a.html', 'w') as f: f.write(html) <...
0
2016-08-09T17:44:27Z
[ "python", "html", "css", "pandas" ]
Ansible install error on Mac
38,850,141
<p>Installing Ansible on the Mac (10.11.6) I get to the "installing Python modules" section here <a href="http://docs.ansible.com/ansible/intro_installation.html" rel="nofollow">http://docs.ansible.com/ansible/intro_installation.html</a> and get this error:</p> <pre><code>sudo pip install paramiko PyYAML Jinja2 httpli...
1
2016-08-09T12:01:04Z
38,850,494
<p>If you don't mind user install, call <code>pip install --user ansible</code> and enjoy.<br> Mac OS has some troubles installing global packages after El Capitan upgrade.</p>
0
2016-08-09T12:16:56Z
[ "python", "osx", "ansible" ]
Ansible install error on Mac
38,850,141
<p>Installing Ansible on the Mac (10.11.6) I get to the "installing Python modules" section here <a href="http://docs.ansible.com/ansible/intro_installation.html" rel="nofollow">http://docs.ansible.com/ansible/intro_installation.html</a> and get this error:</p> <pre><code>sudo pip install paramiko PyYAML Jinja2 httpli...
1
2016-08-09T12:01:04Z
38,876,325
<p>There is a version conflict on USX with the installed version of six. The installed version (the version that comes with OSX) will work, but pip does not know it will work. Do not try to install six with pip. When you go to install Ansible, use the following command:</p> <pre><code>sudo -H pip install ansible --upg...
0
2016-08-10T14:31:40Z
[ "python", "osx", "ansible" ]
Ansible install error on Mac
38,850,141
<p>Installing Ansible on the Mac (10.11.6) I get to the "installing Python modules" section here <a href="http://docs.ansible.com/ansible/intro_installation.html" rel="nofollow">http://docs.ansible.com/ansible/intro_installation.html</a> and get this error:</p> <pre><code>sudo pip install paramiko PyYAML Jinja2 httpli...
1
2016-08-09T12:01:04Z
39,040,959
<p>OSX recently made changes so that you will likely encounter (sooner or later) incompatibilities between python modules that reside on the system and stuff you need to install. Ansible is a good example as it has dependencies that no longer play nice with what's already installed.</p> <p>The clean solution is to use...
0
2016-08-19T14:00:35Z
[ "python", "osx", "ansible" ]
Pandas: delete string with condition
38,850,142
<p>I have df</p> <pre><code>ID url code 111 vk.com 1 111 twitter.com 1 222 facebook.com 1 222 vk.com 1 222 avito.ru 3 </code></pre> <p>Desire output:</p> <pre><code>ID url code 111 vk.com 1 222 facebook.com 1 222 avito.ru 3 </code></pre> <p>I need to delete...
0
2016-08-09T12:01:06Z
38,850,361
<p>You can use <code>drop_duplicates()</code> and specify a subset of columns to use.</p> <pre><code>df.drop_duplicates(['ID', 'code'], keep='first') </code></pre> <p>This will only consider the <code>ID</code> and <code>code</code> column and will keep the first occurrence, removing the other duplicates.</p>
2
2016-08-09T12:10:30Z
[ "python", "pandas" ]
Multi-Cursor editing with QScintilla
38,850,277
<p>I'd like to create a little QScintilla widget supporting multi-cursor-editing like in SublimeText. As far as i know Scintilla already supports multiple cursors but I haven't seen any example out there.</p> <p>So, could anyone please post a little example showing the basics of multiple cursors with QScintilla?</p>
-1
2016-08-09T12:07:39Z
38,884,748
<p>The multi-cursor feature is available in Scintilla, but QScintilla doesn't provide direct wrappers for this feature. However, you can "reimplement" your wrappers, since almost everything can be done with the <code>SendScintilla</code> method.</p> <pre><code>from PyQt5.Qsci import QsciScintilla from PyQt5.QtWidgets ...
1
2016-08-10T22:44:33Z
[ "python", "pyqt", "pyqt5", "qscintilla" ]
Invalid syntax error with numba installed with pip
38,850,278
<p>When I try to run this Python code inside my <code>virtualenv</code>:</p> <pre><code>#!./env/bin/python3 from numba import jit @jit(nopython=True) print("Hello World") </code></pre> <p>I got the following error:</p> <pre><code>(env) root@LANTI-PC:/mnt/c/www/python/flask/app# ./test.py File "./test.py", line 6...
-2
2016-08-09T12:07:41Z
38,850,515
<p>Please remove your usage of <code>@jit</code> decorator, because there are no function to decorate there, they's why the error. Decorators wrap the functions so without them they are useless and erronous.</p>
1
2016-08-09T12:17:51Z
[ "python", "python-3.x", "pip", "virtualenv", "numba" ]
python script to send OSC to SuperCollider using Neuroskys mindwave and NeuroPy module
38,850,287
<p>I'm trying to send multiple OSC messages to <a href="https://pypi.python.org/pypi/SC" rel="nofollow">Supercollider</a> using the variables (1-13) from <a href="https://pypi.python.org/pypi/NeuroPy/0.1" rel="nofollow">neuroPy</a>. It works fine with only one variable. How can I utilize more variables.</p> <pre><code...
1
2016-08-09T12:08:00Z
38,854,108
<p>You do not need to send multiple OSC messages, you can send one OSC message with all the values in. In fact, this will be a much better way to do it, because all the updated values will arrive synchronously, and less network traffic will be needed.</p> <p>Your code currently does the equivalent of</p> <pre><code>m...
2
2016-08-09T14:53:18Z
[ "python", "osc", "supercollider", "neuropy" ]
Django - AttributeError: 'module' object has no attribute 'admin'
38,850,498
<p>I'm in trouble.</p> <p><strong>Python version:</strong> 3.4.4</p> <p><strong>Django version:</strong> 1.10</p> <p><strong>DB type/version:</strong> SqlLite3</p> <p><strong>Installed apps:</strong> accounting, registry, ...</p> <p><strong>Models (accounting):</strong> Bank, Fee, ...</p> <p><strong>Models (regis...
0
2016-08-09T12:17:03Z
38,850,784
<p>This is a question about Python imports.</p> <p>When you import a package, you don't automatically get access to all the modules underneath it; you need to import those specifically. So instead of doing <code>import accounting</code> and then trying to access <code>accounting.admin</code>, you need to explicitly do...
2
2016-08-09T12:28:48Z
[ "python", "django", "order", "admin" ]
Maximise the Slope using CVXPY
38,850,557
<p>I'm trying to use CVXPY to maximise the Sharpe Ratio of a stock portfolio. </p> <p>The variable w is a portfolio weight vector, Sigma is an nxn correlation matrix, mu - is the average return of each portfolio stock, and rf - the risk-free rate (a scalar value).</p> <p>At first, I tried to construct the problem as:...
0
2016-08-09T12:18:59Z
38,855,216
<p>I believe this is not convex. From what I understand there are several ways to attack this problem</p> <ol> <li>Use a general purpose NLP solver (this is the method I used)</li> <li>Trace the efficient frontier to find the point on this frontier with the best Sharpe Ratio</li> <li>Under some conditions, this proble...
1
2016-08-09T15:46:46Z
[ "python", "optimization", "cvxpy" ]
Is it possible to create and reference objects in list comprehension?
38,850,748
<p>I have a list of urls that I want the net locations.</p> <pre><code>urls = ["http://server1:53000/cgi-bin/mapserv?map=../maps/Weather.wms.map", "http://server2:53000/cgi-bin/mapserv?map=../maps/Weather.wms.map"] </code></pre> <p>I would normally just write something like this:</p> <pre><code>servers = []...
3
2016-08-09T12:27:08Z
38,850,776
<p>There is no need to assign to an intermediary name, just access the <code>.netloc</code> attribute on the return value of <code>urlparse()</code> directly:</p> <pre><code>servers = [urlparse(url).netloc for url in urls] </code></pre> <p>It's a perfectly pythonic thing to do it this way.</p>
7
2016-08-09T12:28:25Z
[ "python", "python-2.7", "list-comprehension" ]
Is it possible to create and reference objects in list comprehension?
38,850,748
<p>I have a list of urls that I want the net locations.</p> <pre><code>urls = ["http://server1:53000/cgi-bin/mapserv?map=../maps/Weather.wms.map", "http://server2:53000/cgi-bin/mapserv?map=../maps/Weather.wms.map"] </code></pre> <p>I would normally just write something like this:</p> <pre><code>servers = []...
3
2016-08-09T12:27:08Z
38,851,092
<p>Is this specific case, there is simply no need for the intermediary variable <code>o</code>, as your loop could be simplified to this</p> <pre><code>for url in urls: servers.append(urlparse(url).netloc) </code></pre> <p>which can then be directly transformed to a list comprehension, as in <a href="http://stack...
2
2016-08-09T12:43:02Z
[ "python", "python-2.7", "list-comprehension" ]
Convert three I;16B images into one image
38,850,749
<p>I have 3 images of type <code>I;16B</code> and I am correctly reading them into <code>Python</code> via <code>PIL</code>:</p> <pre><code>#!/usr/bin/en python import sys from PIL import Image mode2bpp = {'1':1, 'L':8, 'P':8, 'RGB':24, 'RGBA':32, 'CMYK':32, 'YCbCr':24, 'I':32, 'F':32} if __name__=="__main__": ...
0
2016-08-09T12:27:11Z
39,942,590
<p>For now, Pillow doesn't support multichannel images with more than 8 bits per channel. You can only convert every image to 'L' mode and merge they together with <code>Image.merge()</code>.</p>
0
2016-10-09T10:32:54Z
[ "python", "python-imaging-library", "tiff" ]
python merge multiple json requests to a single file and save it
38,850,816
<p>I know this request is a bit heavy. Not sure if anyone can help, but if so I'd appreciate it.</p> <p>I'm attempting to work with XML data in python which is new to me. I'm trying to write a script that parses several json requests and combines them into one. I want to feed this file into a proprietary system every ...
0
2016-08-09T12:30:05Z
38,852,153
<p>Principe answer about how to compile items and invoices data into a single dictionary :</p> <p></p> <pre><code># The container for compiled items/invoices items = {} # Process an items request for data in jsondata["items"]: items[data["id"]] = data items[data["id"]]["invoices"] = {} # Process an invoices...
0
2016-08-09T13:27:21Z
[ "python", "arrays", "json", "merge", "python-requests" ]
nonlinear pyplot imshow colors
38,850,826
<p>I spent few hours on this but can't find solution.</p> <p>I have 2D array of data and I want to plot it as heatmap using <code>imshow()</code> function. How can I achieve effect like this? I mean nonlineary distributed colors on colorbar to get better contrast.</p> <p>I found <a href="https://stackoverflow.com/que...
0
2016-08-09T12:30:20Z
38,868,398
<p>Use the norm parameter:</p> <p><code>plt.imshow(your_data, cmap='afmhot_r', norm=colors.PowerNorm(gamma=0.2))</code></p> <p>Read more: <a href="http://matplotlib.org/users/colormapnorms.html" rel="nofollow">http://matplotlib.org/users/colormapnorms.html</a></p>
0
2016-08-10T08:46:39Z
[ "python", "matplotlib", "imshow" ]
Check if value is in categorical series of float range
38,850,859
<p>I got the following pandas DataFrame : </p> <pre><code> bucket value 0 (15016, 18003.2] 368 1 (12028.8, 15016] 132 2 (18003.2, 20990.4] 131 3 (9041.6, 12028.8] 116 4 (50.128, 3067.2] 82 5 (3067.2, 6054.4] 79 6 (6054.4, 9041.6] 54 7 (20990.4, 23977.6] 28 8 (23977....
1
2016-08-09T12:31:53Z
38,851,020
<p>you can apply <code>pd.cut()</code> <strong>using the same bins</strong> (or, better, as <a href="http://stackoverflow.com/questions/38850859/check-if-value-is-in-categorical-series-of-float-range/38851020?noredirect=1#comment65066380_38851020">@ayhan suggested</a> save bins when you create <code>bucket</code> colum...
1
2016-08-09T12:39:52Z
[ "python", "pandas", "dataframe", "category" ]
K-fold cross validation implementation python
38,850,885
<p>I am trying to implement the k-fold cross-validation algorithm in python. I know SKLearn provides an implementation but still... This is my code as of right now.</p> <pre><code>from sklearn import metrics import numpy as np class Cross_Validation: @staticmethod def partition(vector, fold, k): size = vector.sh...
2
2016-08-09T12:32:52Z
38,855,536
<p>The reason why your validation score is low is subtle.</p> <p>The issue is how you have partitioned the dataset. Remember, when doing cross-validation you should <em>randomly</em> split the dataset. It is the randomness that you are missing.</p> <p>Your data is loaded category by category, which means in your inpu...
1
2016-08-09T16:01:18Z
[ "python", "machine-learning", "scikit-learn", "cross-validation" ]
Converting multiple DataFrames into a Panel
38,850,935
<p>I have tons of excel files. Each of these files contains one or more variables <strong>for all subjects at a certain point in time</strong>. For each variable, I have, say, 10 files (storing the value of the variable at 10 different points in time). My ultimate goal is to set up a panel series.</p> <p>Suppose there...
0
2016-08-09T12:35:47Z
38,856,391
<p>A <code>Panel</code> is essentially a stack of <code>DataFrame</code> objects, allowing the data to be explored in three dimensions. Thus, it does not matter how many variables or subjects are represented in each of your files, as long as each file represents only one point in time. Import each file into a <code>Dat...
0
2016-08-09T16:48:14Z
[ "python", "pandas", "panel-data" ]
Python/Django date field in html input tag
38,850,951
<p>I'm trying to display a date in an input field as so:</p> <pre><code>&lt;tr&gt;&lt;td&gt;Date of Birth&lt;/td&gt;&lt;td&gt;&lt;input type="date" name="DOB" value="{{m.dob|date:"d/m/Y"}}" required=True&gt;&lt;/td&gt;&lt;/tr&gt; </code></pre> <p>where m.dob is defined in the model as:</p> <pre><code>dob = models.Da...
1
2016-08-09T12:36:25Z
38,851,078
<p>You can use <code>default</code> like so:</p> <pre><code>date = models.DateField(_("Date"), default="{{"+datetime.date.today+"}}") </code></pre>
0
2016-08-09T12:42:13Z
[ "python", "html", "django" ]
Python/Django date field in html input tag
38,850,951
<p>I'm trying to display a date in an input field as so:</p> <pre><code>&lt;tr&gt;&lt;td&gt;Date of Birth&lt;/td&gt;&lt;td&gt;&lt;input type="date" name="DOB" value="{{m.dob|date:"d/m/Y"}}" required=True&gt;&lt;/td&gt;&lt;/tr&gt; </code></pre> <p>where m.dob is defined in the model as:</p> <pre><code>dob = models.Da...
1
2016-08-09T12:36:25Z
38,851,993
<p>Dude, your question is not clear. But for now, I am assuming you are new to Django.</p> <p>Your DB value is not populating in the template. In order to show the value, you must do two steps:</p> <ul> <li>First query the model object</li> <li>Pass it through additional context dictionary from the Django view.</li> ...
0
2016-08-09T13:20:42Z
[ "python", "html", "django" ]
Python/Django date field in html input tag
38,850,951
<p>I'm trying to display a date in an input field as so:</p> <pre><code>&lt;tr&gt;&lt;td&gt;Date of Birth&lt;/td&gt;&lt;td&gt;&lt;input type="date" name="DOB" value="{{m.dob|date:"d/m/Y"}}" required=True&gt;&lt;/td&gt;&lt;/tr&gt; </code></pre> <p>where m.dob is defined in the model as:</p> <pre><code>dob = models.Da...
1
2016-08-09T12:36:25Z
38,856,785
<p>The problem is <code>value="{{m.dob|date:'d/m/Y'}}"</code> which must be specified as <code>value="{{m.dob|date:'Y-m-d'}}"</code></p>
1
2016-08-09T17:12:16Z
[ "python", "html", "django" ]
Python - matplotlib subplots in tripcolor case
38,851,009
<p>I m trying to organize and ajust my three subplots obtained with tripcolor od Delaunay triangulation. The problem is i cant use the function : plt.tight_layout(pad=0.5, w_pad=2.5, h_pad=2.0) to set the windows size, it doesnt work in this case. The result corresponds to : <a href="http://i.stack.imgur.com/WIuKM.png...
-1
2016-08-09T12:39:26Z
38,851,483
<p>Finally i used gridspec and i can modify easily the size!</p> <pre><code>import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec fig = plt.figure(figsize=(16, 6)) gs = gridspec.GridSpec(1, 3,width_ratios=[1.2,1,1]) ax1 = plt.subplot(gs[0]) i1 =ax1.tripcolor(triang, Epst_eq2, shading='flat', cmap=...
0
2016-08-09T13:00:01Z
[ "python", "matplotlib", "delaunay" ]
Using sed to interpret multiple lines on condition
38,851,010
<p>I'm stuck on constructing a <strong>sed</strong> expression that will parse a python file's imports and extract the names of the modules.</p> <p>This is a simple example that I solved using (I need the output to be the module names without 'as' or any spaces..):</p> <pre><code>from testfunctions import mod1, mod2 ...
1
2016-08-09T12:39:31Z
38,852,168
<p>Try this; </p> <pre><code> sed -n -r '/from/,/^\s*$/p;' *.py | sed ':x; /\\$/ { N; s/\\\n//; tx }' | sed 's/^.*.import//g;s/ */ /g' </code></pre>
1
2016-08-09T13:27:57Z
[ "python", "regex", "bash", "sed", "grep" ]
Using sed to interpret multiple lines on condition
38,851,010
<p>I'm stuck on constructing a <strong>sed</strong> expression that will parse a python file's imports and extract the names of the modules.</p> <p>This is a simple example that I solved using (I need the output to be the module names without 'as' or any spaces..):</p> <pre><code>from testfunctions import mod1, mod2 ...
1
2016-08-09T12:39:31Z
38,858,870
<p>Thanks everyone for your help. I didn't know a module such as <code>ast</code> exists.. It really helped me achieve my goal.</p> <p>I put together a simple version of the solution I needed, just for reference if anyone else encounters this question as well:</p> <pre class="lang-python prettyprint-override"><code>i...
1
2016-08-09T19:24:29Z
[ "python", "regex", "bash", "sed", "grep" ]
Python process HTML / CGI form input
38,851,019
<p>I am trying to process HTML form input. I have a CGI file that I want to collect all the data from, including the check boxes and radio buttons. I am trying to use cgi.FieldStorage but something is not working. </p> <p>Here is an example of what I am trying to do:</p> <pre><code>form = cgi.FieldStorage() name = fo...
0
2016-08-09T12:39:52Z
38,976,380
<p><del>I think you are missing this <code>print ("Content-type:text/html\r\n\r\n")</code> for python 3 and this <code>print "Content-type:text/html\r\n\r\n"</code> for python 2.</del></p> <p>So you want to prevent the user to change the checkbox value? If yes than here is a way :</p> <pre><code>&lt;label id='checky'...
0
2016-08-16T13:33:25Z
[ "python", "html", "xml", "cgi" ]
Adding a column header to a csv in python
38,851,031
<p>I have a csv that contains just 1 column of domain names that range from about 300 to 1500 lines, looking similar to the following:</p> <pre><code>google.com abc.net yahoo.com cnn.com twitter.com </code></pre> <p>All I need to do is add a column header of "domain" so my csv will look like:</p> <pre><code>domain g...
3
2016-08-09T12:40:24Z
38,851,052
<p>You can add parameter <code>names</code> to <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html" rel="nofollow"><code>read_csv</code></a> and <code>index=False</code> to <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Datarame.to_csv.html" rel="nofollow"><code>to...
0
2016-08-09T12:41:04Z
[ "python", "csv", "pandas" ]
Adding a column header to a csv in python
38,851,031
<p>I have a csv that contains just 1 column of domain names that range from about 300 to 1500 lines, looking similar to the following:</p> <pre><code>google.com abc.net yahoo.com cnn.com twitter.com </code></pre> <p>All I need to do is add a column header of "domain" so my csv will look like:</p> <pre><code>domain g...
3
2016-08-09T12:40:24Z
38,851,103
<p>you need to set <code>index=False</code> when writing <code>to_csv</code> to remove the additional column:</p> <pre><code>x.to_csv('out.csv',index=False) </code></pre>
2
2016-08-09T12:43:24Z
[ "python", "csv", "pandas" ]
Adding a column header to a csv in python
38,851,031
<p>I have a csv that contains just 1 column of domain names that range from about 300 to 1500 lines, looking similar to the following:</p> <pre><code>google.com abc.net yahoo.com cnn.com twitter.com </code></pre> <p>All I need to do is add a column header of "domain" so my csv will look like:</p> <pre><code>domain g...
3
2016-08-09T12:40:24Z
38,851,148
<p>If all you are doing is adding one line, you don't really need pandas to do this. Here is an example using the normal python file writing modules:</p> <pre><code>with open('domains.csv', 'rb') as csvfile: rows = [r for r in csvfile] rows = ['domain'] + rows with open('domains.csv', 'wb') as csvfile: fo...
1
2016-08-09T12:45:32Z
[ "python", "csv", "pandas" ]
Adding a column header to a csv in python
38,851,031
<p>I have a csv that contains just 1 column of domain names that range from about 300 to 1500 lines, looking similar to the following:</p> <pre><code>google.com abc.net yahoo.com cnn.com twitter.com </code></pre> <p>All I need to do is add a column header of "domain" so my csv will look like:</p> <pre><code>domain g...
3
2016-08-09T12:40:24Z
38,851,432
<p>You could use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_csv.html" rel="nofollow"><code>header</code></a> parameter in <code>to_csv</code> as you have just 1 column in your dataframe.</p> <pre><code>df = pd.read_csv(data, header=None) df.to_csv('out.csv', header=['domain'], i...
1
2016-08-09T12:58:03Z
[ "python", "csv", "pandas" ]
Python: is throwing an exception a correct use case in this example?
38,851,047
<p>I wonder is if throwing exceptions is the best way to communicate something to the user, in case the user is another programmer. </p> <p>I'm developing a small library to create text-based games (think Dwarf Fortress, but extremely more simple). Of course, I want stuff to move inside the map. It's very simple and t...
2
2016-08-09T12:40:54Z
38,851,265
<p>In my opinion throwing exceptions are better way to inform that some error occurred. Especially if your function does not return any value. Imagine that developer after each call have to check type of returned value. It is much clearer. Check <a href="http://docs.quantifiedcode.com/python-code-patterns/latex/The-Lit...
2
2016-08-09T12:50:24Z
[ "python", "python-3.x", "exception" ]
Python: is throwing an exception a correct use case in this example?
38,851,047
<p>I wonder is if throwing exceptions is the best way to communicate something to the user, in case the user is another programmer. </p> <p>I'm developing a small library to create text-based games (think Dwarf Fortress, but extremely more simple). Of course, I want stuff to move inside the map. It's very simple and t...
2
2016-08-09T12:40:54Z
38,852,399
<p>This usage case seems to be all right for exceptions. Some people say that:</p> <blockquote> <p>"Exceptions should be exceptional"</p> </blockquote> <p>but in Python, use of exceptions to perform flow control is not regarded as a bad practice (read more <a href="http://stackoverflow.com/questions/16138232/is-it-...
3
2016-08-09T13:39:05Z
[ "python", "python-3.x", "exception" ]
ConfigParser.NoSectionError: No section: 'metadata' in installing mysql-python
38,851,059
<p>When I try install mysql-python to CentOs6.5 it casts a error</p> <pre><code>python /sw/ple.bkp/workspace/tianfd/TEMP/MySQL-python-1.2.5/setup.py install Traceback (most recent call last): File "/sw/ple.bkp/workspace/tianfd/TEMP/MySQL-python1.2.5/setup.py", line 17, in &lt;module&gt;metadata, options = get_conf...
0
2016-08-09T12:41:16Z
38,851,302
<p>This seems to be the case of <code>ConfigParser</code> not being able to read the <code>metadata.cfg</code> file. Try setting the right permissions to this file as well as <code>site.cfg</code>.</p>
0
2016-08-09T12:51:47Z
[ "python", "mysql", "mysql-python" ]
Importing Module python
38,851,068
<p>I have added:</p> <pre><code>export PYTHONPATH="${PYTHONPATH}:/home/twittercap/alchemyapi" </code></pre> <p>to my ~/.profile file (ubuntu server environment) and it shows when I run</p> <pre><code>import sys print sys.path </code></pre> <p>but it won't let me import the module using</p> <pre><code>from alchemya...
1
2016-08-09T12:41:33Z
38,862,175
<p><strong>Resolved:</strong> Git cloned again and didn't rename - either the rename messed it up, or else the files corrupted the first time - thanks for your suggestions though!</p>
0
2016-08-09T23:49:53Z
[ "python", "linux", "alchemyapi" ]
Convert number to date format using Python
38,851,091
<p>I am reading data from a text file with more that 14000 rows and there is a column which has eight (08) digit numbers in it. The format for some of the rows are like:</p> <ul> <li>01021943 </li> <li>02031944 </li> <li>00041945 </li> <li>00001946</li> </ul> <p>The problem is that when I use to_date function it conv...
0
2016-08-09T12:43:00Z
38,851,425
<p>As a first guess solution you could just parse it as a string into a datetime instance. Something like:</p> <pre><code>from datetime import datetime EXAMPLE = u'01021943' dt = datetime(int(EXAMPLE[4:]), int(EXAMPLE[2:4]), int(EXAMPLE[:2])) </code></pre> <p>...not caring very much about performance issues.</p>
1
2016-08-09T12:57:47Z
[ "python", "pandas", "python-datetime" ]
Convert number to date format using Python
38,851,091
<p>I am reading data from a text file with more that 14000 rows and there is a column which has eight (08) digit numbers in it. The format for some of the rows are like:</p> <ul> <li>01021943 </li> <li>02031944 </li> <li>00041945 </li> <li>00001946</li> </ul> <p>The problem is that when I use to_date function it conv...
0
2016-08-09T12:43:00Z
38,851,447
<pre><code>import datetime def to_date(num_str): return datetime.datetime.strptime(num_str,"%d%m%Y") </code></pre> <p>Note this will also throw exceptions for zero values because the expected behavior is not clear for this input.<br> If you want a different behavior for zero values, you can implement it with <cod...
1
2016-08-09T12:58:32Z
[ "python", "pandas", "python-datetime" ]
Convert number to date format using Python
38,851,091
<p>I am reading data from a text file with more that 14000 rows and there is a column which has eight (08) digit numbers in it. The format for some of the rows are like:</p> <ul> <li>01021943 </li> <li>02031944 </li> <li>00041945 </li> <li>00001946</li> </ul> <p>The problem is that when I use to_date function it conv...
0
2016-08-09T12:43:00Z
38,851,500
<p>You can add parameter <code>dtype</code> to <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html" rel="nofollow"><code>read_csv</code></a> for converting column <code>col</code> to <code>string</code> and then use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.to...
2
2016-08-09T13:00:42Z
[ "python", "pandas", "python-datetime" ]
How to Import Exceptions from Package (Openpyxl)?
38,851,120
<p>I am trying to catch a sheet error exception for the package I am using (Openpyxl). I tried importing the exception like so <code>from openpyxl.utils import SheetTitleException</code> but I get the error <code>"ImportError: cannot import name SheetTitleException"</code>. When I tried importing it just with <code>fro...
0
2016-08-09T12:44:04Z
38,851,173
<p>The title of the page you linked to says "openpyxl.utils.exceptions".</p> <p>Therefore you should be doing:</p> <pre><code>from openpyxl.utils.exceptions import SheetTitleException </code></pre>
4
2016-08-09T12:46:38Z
[ "python", "exception-handling", "openpyxl" ]
How to Import Exceptions from Package (Openpyxl)?
38,851,120
<p>I am trying to catch a sheet error exception for the package I am using (Openpyxl). I tried importing the exception like so <code>from openpyxl.utils import SheetTitleException</code> but I get the error <code>"ImportError: cannot import name SheetTitleException"</code>. When I tried importing it just with <code>fro...
0
2016-08-09T12:44:04Z
38,851,209
<p>If it's anything like other module exception handling that i've done it should be</p> <pre><code>from openpyxl.utils.exceptions import SheetTitleException </code></pre> <p>then to use it</p> <pre><code>except SheetTitleException as e: # do something </code></pre>
1
2016-08-09T12:48:01Z
[ "python", "exception-handling", "openpyxl" ]
Python - integration with rpy2 and 'must be atomic' error
38,851,184
<p>While using package rpy2, I get the error </p> <blockquote> <p>Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/dist-packages/rpy2/robjects/functions.py", line 86, in <strong>...
0
2016-08-09T12:47:11Z
38,873,782
<p>When doing</p> <pre><code>file.R_func.rdc([1,2,3,4,5],[1,3,4,5,6],20,1.67) </code></pre> <p>an implicit conversion of Python objects is performed before passing them as parameters to the underlying R function.</p> <p>By default, <code>[1,2,3,4,5]</code> (which is a Python <code>list</code>) will be converted to a...
0
2016-08-10T12:42:50Z
[ "python", "rpy2" ]
Django: Filter a QuerySet and select results foreign key
38,851,352
<p>In Django, I have two models:</p> <pre><code>class A(models.Model): # lots of fields class B(models.Model): a = models.ForeignKey(A) member = models.BooleanField() </code></pre> <p>I need to construct a query that filters B and selects all A, something like this:</p> <pre><code>result = B.objects.fil...
0
2016-08-09T12:54:23Z
38,851,406
<p>I assume you are looking for something like </p> <pre><code>result = A.objects.filter(b__member=True) </code></pre>
4
2016-08-09T12:57:10Z
[ "python", "django", "django-models" ]
Django: Filter a QuerySet and select results foreign key
38,851,352
<p>In Django, I have two models:</p> <pre><code>class A(models.Model): # lots of fields class B(models.Model): a = models.ForeignKey(A) member = models.BooleanField() </code></pre> <p>I need to construct a query that filters B and selects all A, something like this:</p> <pre><code>result = B.objects.fil...
0
2016-08-09T12:54:23Z
38,851,489
<p>An alternative to Andrey Zarubin's answer would be to iterate over the queryset you had and create a list of a objects.</p> <pre><code>b_objects = B.objects.filter(member=True) a_objects = [result.a for result in b_objects] </code></pre>
1
2016-08-09T13:00:07Z
[ "python", "django", "django-models" ]
Django: Filter a QuerySet and select results foreign key
38,851,352
<p>In Django, I have two models:</p> <pre><code>class A(models.Model): # lots of fields class B(models.Model): a = models.ForeignKey(A) member = models.BooleanField() </code></pre> <p>I need to construct a query that filters B and selects all A, something like this:</p> <pre><code>result = B.objects.fil...
0
2016-08-09T12:54:23Z
38,852,440
<p>Below code will not filter everything but it will filter all the values with respect to field, might be you are looking for same</p> <p>B.objects.filter(member=True).filter(a__somefield='some value')</p>
0
2016-08-09T13:40:52Z
[ "python", "django", "django-models" ]
Maintaining a Lite and Pro Version of Python Project with Git/PyCharm
38,851,381
<h2>Background</h2> <p>I am wrapping up a python project, and I am considering releasing a it with pro/lite versions. I don't want duplicate code laying around, of course, but I can't release a free version with many of the capabilities of the pro version only disabled with a few <em>if</em> checks: the code is for a ...
5
2016-08-09T12:55:34Z
38,860,222
<p>Here's basic idea, based on you segregating out code into different modules. Right now, the concept is having 2 different download points. But it doesn't have to be, that's your call.</p> <p>Regardless of which packaging/distribution approach you take, you'll have to separate out codelines into different code mod...
2
2016-08-09T20:52:42Z
[ "python", "git", "pycharm", "code-duplication" ]
Copying from a binary file using Python inserts new bytes (?)
38,851,533
<p>I am trying to open a file created by a measurement equipment, find the bytes correspoding to metadata, then write everything else to a new binary file. (The metadata part is not the problem: I know the headers and can find them easily. Let's not worry about that.)</p> <p>The problem is: when I open the file and wr...
1
2016-08-09T13:02:02Z
38,852,230
<p>Welcome to the world of end of line markers! When a file is open in text mode under Windows, any raw <code>\n</code> (hex 0x0a) will be written as <code>\r\n</code> (hex 0x0d 0x0a).</p> <p>Fortunately it is easy to fix: just open the file in binary mode (note the <strong>b</strong>):</p> <pre><code>with open(..., ...
3
2016-08-09T13:31:06Z
[ "python", "binaryfiles" ]
Convert ui-select selected values to integar list
38,851,548
<p>I've used <strong>angular-ui-select</strong> that is selecting some IDs of int type like this <code>9,2,3</code>. I'm trying to pass these values as <code>integer</code> list to python file like this</p> <pre><code>param += '"lstRole":[' + $scope.multipleDemo.roles +']'; </code></pre> <p>It throws error </p> <p...
0
2016-08-09T13:02:29Z
38,851,912
<p>try this in your python function:</p> <pre><code>json_str = request.body.decode('utf-8') py_str = json.loads(json_str) print(py_str["lstRole"]) </code></pre>
0
2016-08-09T13:17:56Z
[ "python", "angularjs", "list" ]
Heroku Gunicorn Procfile
38,851,564
<p>I have a hard time finding documentation for creating Procfiles using flask with gunicorn and Heroku. Somewhere I found that the syntax is: <code>web: gunicorn my_folder.my_module:app</code>. But I can't make it work. It only works for me when my python script: <code>hello.py</code> is in the root folder of the app....
0
2016-08-09T13:03:05Z
38,853,025
<p>Have a look at <a href="https://github.com/zachwill/flask_heroku" rel="nofollow">this template</a>. It has a Procfile and is ready to be pushed to Heroku. You can learn from it, or just fork it and base your app on the template.</p>
0
2016-08-09T14:04:45Z
[ "python", "heroku", "flask", "gunicorn" ]
Data alignment in plotting bar chart from dictionary in python
38,851,621
<p>I'm trying to plot 2 axes in a bar chart using 2 different dictionaries, that has exactly the same keys, using matplotlib. I wasn't able to make sure that the items (keys and values) of the two dictionaries are in the same order.</p> <p>code example:</p> <pre><code>ind = numpy.arange(len(types_dict)) # the x loca...
0
2016-08-09T13:05:38Z
38,853,898
<p>You're defining lists rather than dictionaries because you're using square brackets. If you want dictionaries, you'll need to wrap your data in {}. In Python, list order is preserved, dict order is not, unless you use an <a href="https://docs.python.org/2/library/collections.html#collections.OrderedDict" rel="nofoll...
0
2016-08-09T14:43:00Z
[ "python", "dictionary", "matplotlib", "bar-chart" ]
Find consecutive zeros in Python, based on time
38,851,641
<p>I have a pandas <code>df1</code> with a <code>datetime</code> column and a <code>count</code> column. If there is a string of 0s for a consecutive hour, and less than 2 minutes of data > 0 within that hour (a 'spike tolerance'), it is considered invalid. </p> <p>The <code>datetime</code> is in 5 second intervals bu...
1
2016-08-09T13:06:35Z
38,852,095
<p>transposed and turn it into a series:</p> <pre><code>y = df.T.unstack() </code></pre> <p>Then to make up for lack of contiguous groupby in pandas:</p> <pre><code>y * (y.groupby((y != y.shift()).cumsum()).cumcount() + 1) OUT: 0 0 1 0 2 1 3 2 4 3 5 0 6 0 7 1 8 0 9 1 10 2 ...
0
2016-08-09T13:24:41Z
[ "python", "datetime", "pandas" ]
Python run command line
38,851,647
<p>I'm trying to run a command line script. I have : command.py </p> <pre><code>import subprocess proc = subprocess.Popen('python3 hello.py', stdout=subprocess.PIPE) tmp = proc.stdout.read() print(tmp) </code></pre> <p>and hello.py</p> <pre><code>print("hello") </code></pre> <p>but it returns error</p> <blockquote...
0
2016-08-09T13:06:48Z
38,852,031
<p>The problem is that <code>Popen</code> cannot find <code>python3</code> in your path.</p> <p>If the primary error was that <code>hello.py</code> wasn't found, you would have this error instead in <code>stderr</code> (that is not read)</p> <pre><code>python: can't open file 'hello.py': [Errno 2] No such file or dir...
1
2016-08-09T13:21:59Z
[ "python", "python-3.x" ]
How to parse a repeatable option with two arguments with Python’s argparse?
38,851,656
<p>How can I get <code>argparse</code> to parse an option with two arguments, which might exist multiple times? Like this:</p> <pre><code>$ cmd --repo origin here --repo other there --repo upstream url3 </code></pre> <p>And the parsed arguments should be accessible for example like this:</p> <pre><code>args.repo = [...
0
2016-08-09T13:07:21Z
38,851,802
<p>You should use append action.</p> <p>From argparse documentation:</p> <p><code>append</code> - This stores a list, and appends each argument value to the list. This is useful to allow an option to be specified multiple times. </p> <p>Example usage:</p> <pre><code>&gt;&gt;&gt; parser = argparse.ArgumentParser() &...
1
2016-08-09T13:13:10Z
[ "python", "command-line-arguments", "argparse", "command-line-parsing" ]
How to parse a repeatable option with two arguments with Python’s argparse?
38,851,656
<p>How can I get <code>argparse</code> to parse an option with two arguments, which might exist multiple times? Like this:</p> <pre><code>$ cmd --repo origin here --repo other there --repo upstream url3 </code></pre> <p>And the parsed arguments should be accessible for example like this:</p> <pre><code>args.repo = [...
0
2016-08-09T13:07:21Z
38,851,969
<pre><code>import argparse parser = argparse.ArgumentParser() parser.add_argument('--repo', nargs=2, action='append') parser.parse_args('--repo origin here --repo other there'.split()) </code></pre> <p>Result:</p> <pre><code>Namespace(repo=[['origin', 'here'], ['other', 'there']]) </code></pre>
2
2016-08-09T13:20:01Z
[ "python", "command-line-arguments", "argparse", "command-line-parsing" ]
Python 3.5 | split List and export to Excel or CSV
38,851,819
<p>I scrape a website with Python 3.5 (BeautifulSoup) and the result is a list. The values are stored in a variable called "project_titles".</p> <p>The values look like:</p> <pre><code>project_titles = ['I'm Back. Raspberry Pi unique Case for your Analog Cameras', 'CitizenSpring - App to crowdsource &amp; map safe dr...
0
2016-08-09T13:14:07Z
38,852,025
<p>Since you already have a list of strings conforming to the columns required in your CSV file you can simply write the list out using the <a href="https://docs.python.org/3.5/library/csv.html#module-csv" rel="nofollow"><code>csv</code></a> module:</p> <pre><code>import csv project_titles = ["I'm Back. Raspberry Pi ...
2
2016-08-09T13:21:51Z
[ "python", "excel", "python-3.x", "csv", "beautifulsoup" ]
Python 3.5 | split List and export to Excel or CSV
38,851,819
<p>I scrape a website with Python 3.5 (BeautifulSoup) and the result is a list. The values are stored in a variable called "project_titles".</p> <p>The values look like:</p> <pre><code>project_titles = ['I'm Back. Raspberry Pi unique Case for your Analog Cameras', 'CitizenSpring - App to crowdsource &amp; map safe dr...
0
2016-08-09T13:14:07Z
38,852,059
<p>Since <code>project_titles</code> is already a list containing the strings you want, it's easy to use <code>pandas</code> (can be installed together with one of the scientific pthon distributions, see scipy.org) with the following short code:</p> <pre><code>import pandas as pd project_titles = ["I'm Back. Raspberr...
1
2016-08-09T13:23:10Z
[ "python", "excel", "python-3.x", "csv", "beautifulsoup" ]
Python 3.5 | split List and export to Excel or CSV
38,851,819
<p>I scrape a website with Python 3.5 (BeautifulSoup) and the result is a list. The values are stored in a variable called "project_titles".</p> <p>The values look like:</p> <pre><code>project_titles = ['I'm Back. Raspberry Pi unique Case for your Analog Cameras', 'CitizenSpring - App to crowdsource &amp; map safe dr...
0
2016-08-09T13:14:07Z
38,852,247
<p>You can try a very simple code</p> <pre><code>project_titles = ["I'm Back. Raspberry Pi unique Case for your Analog Cameras", 'CitizenSpring - App to crowdsource &amp; map safe drinking water', 'Shoka Bell: The Ultimate City Cycling Tool'] with open('data.csv',"w") as fo: fo.writelines(",".join(project_titles)...
0
2016-08-09T13:31:54Z
[ "python", "excel", "python-3.x", "csv", "beautifulsoup" ]
Django 1.8 CSS load incompletely
38,851,939
<p>I have looked up almost every solution about Django CSS, JS, images file not load. However, I think my project is something different.</p> <p>I want to make a RWD site but it doesn't work on the small screen. No menu, No change the template.</p> <p>I can see the CSS works but is not entirely. <a href="http://i.sta...
0
2016-08-09T13:18:50Z
38,852,154
<p>Try changing your href in html like this:</p> <pre><code>&lt;link rel="stylesheet" href="{{STATIC_URL}}css/skel-noscript.css" /&gt; </code></pre> <p>Let me know if this doesn't work.</p> <p>Edit: What is your BASE_DIR settings? Can you try with following settings.</p> <pre><code># Static Files STATIC_ROOT = join...
0
2016-08-09T13:27:23Z
[ "python", "html", "css", "django" ]
Django 1.8 CSS load incompletely
38,851,939
<p>I have looked up almost every solution about Django CSS, JS, images file not load. However, I think my project is something different.</p> <p>I want to make a RWD site but it doesn't work on the small screen. No menu, No change the template.</p> <p>I can see the CSS works but is not entirely. <a href="http://i.sta...
0
2016-08-09T13:18:50Z
38,858,437
<p>Try doing this in your <strong>index.html</strong> file:</p> <pre><code>&lt;!DOCTYPE HTML&gt; {% load staticfiles %} &lt;!-- Ex Machina by TEMPLATED templated.co @templatedco Released for free under the Creative Commons Attribution 3.0 license (templated.co/license) --&gt; &lt;html&gt; &lt;head&gt; ...
0
2016-08-09T18:57:08Z
[ "python", "html", "css", "django" ]
python kmeans on string
38,851,979
<p>i am new to kmeans clustering method. i try to cluster a 1 dimension string array data in python. </p> <p>Below is my data:</p> <pre><code>expertise=[' Bioactive Surfaces and Scaffolds for Regenerative Medicine', 'Drug/gene delivery science', 'RNA nanomedicine', 'Immuno/bio/nano-engineering', 'Biomaterials', 'Nan...
-4
2016-08-09T13:20:19Z
38,852,530
<p>you will first have to define how you wanna cluster your data. The scikit-learn's simple KMeans clustering is designed to work on numbers. However scikit-learn can be also be used to cluster documents by topics using a bag-of-words approach. This is done by extracting the features using scipy.sparse matrix instead o...
0
2016-08-09T13:44:33Z
[ "python", "scikit-learn", "k-means" ]
python kmeans on string
38,851,979
<p>i am new to kmeans clustering method. i try to cluster a 1 dimension string array data in python. </p> <p>Below is my data:</p> <pre><code>expertise=[' Bioactive Surfaces and Scaffolds for Regenerative Medicine', 'Drug/gene delivery science', 'RNA nanomedicine', 'Immuno/bio/nano-engineering', 'Biomaterials', 'Nan...
-4
2016-08-09T13:20:19Z
38,852,539
<p>There is almost no sense in what you are trying to do. How do you think two clustered groups should look like?</p> <p>If you can't plot data you won't be able to cluster it. Find a way to present strings in some numerical way (for example length, occurrence of letters depending on what you want to get) and then clu...
0
2016-08-09T13:45:01Z
[ "python", "scikit-learn", "k-means" ]
python - Yield improperly usage
38,852,074
<p>Im pretty sure im using yield improperly:</p> <pre><code>#!/usr/bin/env python # -*- coding: utf-8 -*- import logging from gensim import corpora, models, similarities from collections import defaultdict from pprint import pprint # pretty-printer from six import iteritems import openpyxl import string from operato...
0
2016-08-09T13:23:48Z
38,852,397
<p>the problem is not the <code>yield</code> per se, is what is yielded, the error said is from <code>for termid, _ in bow</code> this line said that you expect that <code>bow</code> contain a list of tuples or any other object containing exactly 2 element like <code>(1,2),[1,2],"12",...</code> but as it end giving to ...
1
2016-08-09T13:38:56Z
[ "python", "parsing", "yield", "gensim" ]
python - Yield improperly usage
38,852,074
<p>Im pretty sure im using yield improperly:</p> <pre><code>#!/usr/bin/env python # -*- coding: utf-8 -*- import logging from gensim import corpora, models, similarities from collections import defaultdict from pprint import pprint # pretty-printer from six import iteritems import openpyxl import string from operato...
0
2016-08-09T13:23:48Z
38,853,302
<p>It looks like your problem is that <code>TfidfModel</code> expects a <code>corpus</code> that is a <code>list</code> of <code>doc2bow</code> outputs (themselves <code>list</code>s of two-<code>tuple</code>s). Your original working code used <code>doc2bow</code> correctly to convert from your plain strings to the cor...
1
2016-08-09T14:16:54Z
[ "python", "parsing", "yield", "gensim" ]
Python Script "machine/user-level scripts" difference
38,852,194
<p>The <a href="http://npppythonscript.sourceforge.net/docs/latest/usage.html" rel="nofollow" title="documentation">documentation</a> says </p> <blockquote> <p>The script called startup.py (in either the “machine” directory or “user” directory - see Installation)</p> </blockquote> <p>but all I can see in ...
1
2016-08-09T13:29:23Z
38,852,289
<p>As for me, the default Python Script installation did not work at all. </p> <p>I suggest installing <a href="https://sourceforge.net/projects/npppythonscript/files/Python%20Script%201.0.8.0/" rel="nofollow">Python Script 1.0.8.0</a>. </p> <p>Then, once you go to the <em>Plugins</em> -> <em>Python Script</em> -> <e...
1
2016-08-09T13:33:50Z
[ "python", "notepad++" ]
different amount of rows after merging two dataframes with pandas
38,852,207
<p>I have a dataframe which I merge with another dataframe by the column <code>EQ_NR</code>.</p> <p>Here is the Structure of the first dataframe: (Rows: 320816)</p> <pre><code> FAK_ART FAK_DAT LEIST_DAT KD_CRM MW_BW EQ_NR \ 0 ZPAF 2015-12-10 2015-12-31 T-HOME ICP B 1001380363 1 ...
2
2016-08-09T13:29:58Z
38,852,237
<p>There is problem with duplicates in joining column <code>EQ_NR</code>.</p> <p>In sample there are duplicated values <code>1001380363</code> and <code>1001380594</code>.</p> <p>Sample:</p> <pre><code>import pandas as pd df1 = pd.DataFrame({'EQ_NR':[1001380363,1001380363,1001380363, 1001380365], ...
1
2016-08-09T13:31:27Z
[ "python", "pandas", "dataframe", "merge" ]
different amount of rows after merging two dataframes with pandas
38,852,207
<p>I have a dataframe which I merge with another dataframe by the column <code>EQ_NR</code>.</p> <p>Here is the Structure of the first dataframe: (Rows: 320816)</p> <pre><code> FAK_ART FAK_DAT LEIST_DAT KD_CRM MW_BW EQ_NR \ 0 ZPAF 2015-12-10 2015-12-31 T-HOME ICP B 1001380363 1 ...
2
2016-08-09T13:29:58Z
38,852,934
<p>if you want to add only one column you can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.map.html" rel="nofollow">map()</a> method:</p> <pre><code>In [290]: df1['TA2'] = df1.EQ_NR.map(df2.set_index('EQ_NR').TA) In [291]: df1 Out[291]: FAK_ART FAK_DAT LEIST_DAT KD_CRM...
0
2016-08-09T14:01:12Z
[ "python", "pandas", "dataframe", "merge" ]
HeatMap visualization
38,852,220
<p>I have a dataframe df1</p> <pre><code>df1.info() &lt;class 'pandas.core.frame.DataFrame'&gt; RangeIndex: 38840 entries, 0 to 38839 Data columns (total 7 columns): TIMESTAMP 38840 non-null datetime64[ns] ACT_TIME_AERATEUR_1_F1 38696 non-null float64 ACT_TIME_AERATEUR_1_F3 38697 non-null flo...
0
2016-08-09T13:30:29Z
38,853,129
<p>It's because <code>TIMESTAMP</code> is not your index, from the <code>sns.heatmap</code> docstring:</p> <blockquote> <p>yticklabels : list-like, int, or bool, optional If True, plot the row names of the dataframe. If False, don't plot the row names. If list-like, plot these alternate labels as the ...
0
2016-08-09T14:09:33Z
[ "python", "heatmap", "seaborn" ]
Define pidfile in DaemonContext disable logger in python
38,852,265
<p>i'm trying to create a daemon service in python with log to file opption using logging. If i add the pidfile parameter to daemon.DaemonContext constructor, logger is not log any messages to logger.log file. But if i remove that parameter, everything is working. runs without any errors. Can anyone know why pidfile ...
0
2016-08-09T13:32:46Z
38,867,793
<p>I succeed to solve the problem. The problem was that no pidfile was created with the command:</p> <pre><code>pidfile=lockfile.FileLock('/var/run/myDaemon.pid') </code></pre> <p>The solution is to use daemon.pidfile module instead of the lockfile module:</p> <pre><code>pidfile=daemon.pidfile.PIDLockFile('/var/run/...
0
2016-08-10T08:17:25Z
[ "python", "logging", "daemon", "lockfile" ]
Read and push a table again to sql:Pandas
38,852,273
<p>I am reading a table from my sql server with Pandas such as </p> <pre><code>df= pd.read_sql('table1', engine) </code></pre> <p>where engine is my pyodbc connection and then again I am pushing it to sql server </p> <pre><code>df.to_sql('table2', engine, if_exists='replace') </code></pre> <p>which gives me an er...
0
2016-08-09T13:33:25Z
38,853,079
<p>Set <code>index=Flase</code> while writing <code>to_sql</code> because index values should be unique.</p>
2
2016-08-09T14:06:57Z
[ "python", "pandas", "dataframe", "sqlalchemy" ]
Binary representation over serial Python3
38,852,468
<p>I'm writing various bytes over serial in the form of ascii representations.</p> <p>Heres an example: <code>bytes_to_write = '\aa' # Will write 01010101</code></p> <p>Now one part of what I send involves me calculating the 4 bytes that need to be transferred, I calculate the bytes using the below function:</p> <pr...
0
2016-08-09T13:41:44Z
38,854,281
<p><code>decode</code> isn't working because there is no ascii representation of <code>part_3</code>; an ascii character must be an int between 0 and 127 inclusive. It looks like <code>part_3</code> in this example is <code>b'\x80\xac\xff!'</code>; the first three bytes are 128, 172 and 255, none of which are valid asc...
0
2016-08-09T15:01:15Z
[ "python", "python-3.x", "binary", "pyserial" ]
How to efficiently insert bulk data into Cassandra using Python?
38,852,492
<p>I have a Python application, built with Flask, that allows importing of many data records (anywhere from 10k-250k+ records at one time). Right now it inserts into a Cassandra database, by inserting one record at a time like this:</p> <pre><code>for transaction in transactions: self.transaction_table.insert_reco...
0
2016-08-09T13:43:13Z
38,853,615
<p>You can use batch statements for this, an example and documentation is available from the <a href="https://datastax.github.io/python-driver/api/cassandra/query.html#cassandra.query.BatchStatement" rel="nofollow">datastax documentation</a>. You can also use some child workers and/or async queries on top of this.</p> ...
1
2016-08-09T14:31:06Z
[ "python", "cassandra" ]