Q_CreationDate stringlengths 23 23 | Title stringlengths 11 149 | Question stringlengths 25 6.53k | Answer stringlengths 15 5.1k | Score float64 -1 1.2 | Is_accepted bool 2
classes | N_answers int64 1 17 | Q_Id int64 0 6.76k |
|---|---|---|---|---|---|---|---|
2017-04-17 18:33:00.927 | Jupyter reload custom.css? | I'm using Jupyer 4.3.0. I find that when I update my ~/.jupyter/custom/custom.css, the changes are not reflected in my notebook until I kill jupyter-notebook and start it again. This is annoying, so how can I make Jupyter Notebook recognize the custom.css file changes without completely restarting the notebook? | The /custom/custom.css stopped working for me when I generated a config file, but if anyone stumbles to this problem too, the solution is to uncomment the line c.NotebookApp.extra_static_paths = [] in the jupyter_notebook_config.py file and add "./custom/" - or whatever path you chose for your custom css - inside the b... | 0 | false | 2 | 4,845 |
2017-04-18 07:54:11.413 | how to combine 2D arrays into a 3D array in python? | I have a project in which there is a for loop running about 14 times. In every iteration, a 2D array is created with this shape (4,3). I would like to concatenate those 2D arrays into one 3D array (with the shape of 4,3,14) so that every 2D array would be in different "layer".
How should that be implemented in Python? | If your arrays are only 'list', sumplt defines an empty list at the beginning and append item into it:
foo=[]
for i in range(14):
...
foo.append(tab) | -0.201295 | false | 1 | 4,846 |
2017-04-18 11:16:35.647 | how to make speech recognition chat bot using wit.ai? | I'm trying to build a chat bot using wit.ai, which will recognize the speech and convert into text in chat bot.
Is it possible with the GUI of wit.ai to make such kind of chat bot?
I actually converted the voice into text, but facing difficulty to integrate the voice input with chat bot. How to do this? | since the new release of messenger, you can convert speech into text, so if you are developing for messenger or another app with a good voice-to-text, you can rely on the app instead of trying doing it by yourself. In the end you're gonna have just text inputs, but people would be able to convert it's speech into text. | 0 | false | 1 | 4,847 |
2017-04-18 23:14:36.930 | Combining effects of dummy variables in a regression model | I am building a regression model with about 300 features using Python Sklearn. One of the features has over 100 categories and I end up having ~100 dummy columns for this feature.Now each of the dummy column has its own coefficient, or a feature ranking score (if using Random Forest or xgb) - which is something I dont ... | You may google SAS STAT manual /User guide. Check out any major regression procedures there that support Class statement. Underneath the Class it details Reference... option. They all detail how a design matrix is fashioned out. The way you fed your 100 dummies must have been obvious enough to trigger JMP to roll back ... | 0 | false | 1 | 4,848 |
2017-04-20 13:12:05.680 | AWS Device Farm- Appium Python - Order of tests | I'm using Appium-Python with AWS Device farm. And I noticed that AWS run my tests in a random order.
Since my tests are part dependent I need to find a way to tell AWS to run my tests in a specific order.
Any ideas about how can I accomplish that?
Thanks | I work for the AWS Device Farm team.
This seems like an old thread but I will answer so that it is helpful to everyone in future.
Device Farm parses the test in a random order. In case of Appium Python it will be the order what is received from pytest --collect-only.
This order may change across executions.
The onl... | 0 | false | 1 | 4,849 |
2017-04-20 23:40:09.207 | Integer overflow in universal hashing implementation | For one of my pet projects I would like to create an arbitrary number of different integer hashes. After a bit of research I figured that universal hashing is the way to go. However, I struggle with the (numpy) implementation. Say I'm trying to use the hash family h(a,b)(x) = ((a * x + b) mod p) mod m and my x can be a... | (x + y) % z == ((x % z) + (y % z)) % z. So you could take the modulus before doing the sum:
Cast a and x to uint64. (Multiply two uint32 will never overflow uint64).
Compute h = (a * x) % p + b
Return (h - p) if h > p else h. (Alternatively: return h % p) | 1.2 | true | 1 | 4,850 |
2017-04-21 15:25:29.450 | Python script to input the next number in a sequence every time it runs. | I am trying to write a script that will have a count that starts a 001, and increasing by one every time that the script is run.
I just help some help started this off, what can I do to set it up so that it knows where it start from every time? Is there is way that I can build it into the script to do this?
My bad id... | if you want some kind of state persistance then your options are limited:
save the state into a file as you suggest in your question (either a text file or spreadsheet, but spreadsheet is harder to do)
change your concept so that instead of "running the script" multiple times, the script is always running, but you giv... | 0.386912 | false | 1 | 4,851 |
2017-04-21 18:13:58.437 | Finding the position of center using pygame | I am trying to move an image from its center using pygame. I loaded the image using pygame but I have the top corner coordinates of the image. how do i get the coordinates of center. | You can also query the size of the image. Adjust the corner coordinates by half of the size in each direction. | 0 | false | 1 | 4,852 |
2017-04-22 19:05:21.440 | How to iterate/ loop through a large (>2GB) JSON dataset in R/ Python? | I was trying to do some exploratory analyses on a large (2.7 GB) JSON dataset using R, however, the file doesn't even load in the first place. When looking for solutions, I saw that I could process the data in smaller chunks, namely by iterating through the larger file or by down-sampling it. But I'm not really sure ho... | The jsonlite R package supports streaming your data. In that way there is no need to read all the json data into memory. See the documentation of jsonlite for more details, the stream_in function in particular.
Alternatively:
I would dump the json into a mongo database and process the data from that. You need to insta... | 0.386912 | false | 1 | 4,853 |
2017-04-24 03:07:01.457 | arr = [a,b] choose a, x% of time | I want to write a program with the following requirement.
arr = ['a', 'b']
How to write a python program which choose a from arr x% of time.
(For example 80% of time).
I have no idea how should I start. Please help.
I know random.choice(arr). But it will give a random choice I can not make it biased. | random.choices(['a', 'b'], weights=[0.8, 0.2], k=2) | 0 | false | 1 | 4,854 |
2017-04-24 06:08:09.263 | how to write the curses window content to the file in python? | I have created window in the curses and created my call flow (data).
window = curses.newwin(2500, 2500, 0, 0)
How should i copy the window content(exact replica) to the file ? | putwin() and getwin() are the functions for saving and restoring an individual window, and they're available in Python. | 0 | false | 1 | 4,855 |
2017-04-24 16:04:50.690 | How to change python version in anaconda spyder | I am using 3.6 Python version in anaconda spyder on my mac. But I want to change it to Python 2.7.
Can any one tell me how to do that? | Set python3 as a main version in the terminal:
ln -sf python3 /usr/bin/python
Install pip3:
apt-get install python3-pip
Update spyder:
pip install -U spyder
Enjoy | 0.201295 | false | 2 | 4,856 |
2017-04-24 16:04:50.690 | How to change python version in anaconda spyder | I am using 3.6 Python version in anaconda spyder on my mac. But I want to change it to Python 2.7.
Can any one tell me how to do that? | In Preferences, select Python Interpreter
Under Python Interpreter, change from "Default" to "Use the following Python interpreter"
The path there should be the default Python executable. Find your Python 2.7 executable and use that. | 0.201295 | false | 2 | 4,856 |
2017-04-24 19:34:41.733 | python: one kernel density plot which includes multiple columns in a single dataframe | I need to make a single gaussian kernel density plot of a dataframe with multiple columns which includes all columns of the dataframe. Does anyone know how to do this?
So far I only found how to draw a gaussian kernel plot of a single column with seaborn. ax = sns.kdeplot(df['shop1'])
However, neither ax = sns.kdeplot(... | I did find how to work around by transforming the dataframe's columns into one single column.
df.stack() | 0 | false | 1 | 4,857 |
2017-04-25 09:58:49.603 | Why amazon EC2 is as slow as my machine when running python code? | I'm using g2.2 xlarge instance of amazon.
I'm having this function that takes 3 minutes to run on my laptop which is so slow.
However, when running it on EC2 it takes the same time , sometimes even more.
Seeing the statistics , I noticed EC2 uses at its best 25% of CPU.
I paralleled my code, It's better but I ... | I think you need to profile your code locally and ensure it really is CPU bound. Could it be that time is spent on the network or accessing disk (e.g. reading the image to start with).
If it is CPU bound then explore how to exploit all the cores available (and 25% sounds suspicious - is it maxing out one core?). Pytho... | 0.999329 | false | 1 | 4,858 |
2017-04-25 22:54:56.227 | Cassandra: occasional permission errors | I use cqlengine with django. In some occasions Cassandra throws an error indicating that user has no permissions do to something. Sometimes this is select, sometimes this is update or sometimes it is something else. I have no code to share, because there is no specific line that does this. I am very sure that user has ... | Is the system_auth keyspace RF the same as the amount of nodes? Did you try to run a repair on the system_auth keyspace already? If not do so.
For me it sounds like a consistency issue. | 0 | false | 2 | 4,859 |
2017-04-25 22:54:56.227 | Cassandra: occasional permission errors | I use cqlengine with django. In some occasions Cassandra throws an error indicating that user has no permissions do to something. Sometimes this is select, sometimes this is update or sometimes it is something else. I have no code to share, because there is no specific line that does this. I am very sure that user has ... | If you have authentication enabled, make sure you set appropriate RF for keyspace system_auth (should be equal to number of nodes).
Secondly, make sure the user you have created has following permissions on all keyspaces. {'ALTER', 'CREATE', 'DROP', 'MODIFY', 'SELECT'}. If you have the user as a superuser make sure you... | 0 | false | 2 | 4,859 |
2017-04-26 03:07:18.517 | How to extract COMPLAINT features from texts in order to classify complaints from non-complaints texts | I have a corpus of around 6000 texts with comments from social network (FB, twitter), news content from general and regional news and magazines, etc. I have gone through first 300 of these texts and tag each of these 300 texts' content as either customer complaint or non-complaint.
Instead of naive way of bag of words... | I think you will find that bag-of-words is not so naive. It's actually a perfectly valid way of representing your data to give it to an SVM. If that's not giving you enough accuracy you can always include bigrams, i.e. word pairs, in your feature vector instead of just unigrams. | 0 | false | 1 | 4,860 |
2017-04-26 10:33:28.567 | How to stop/kill Airflow tasks from the UI | How can I stop/kill a running task on Airflow UI? I am using LocalExecutor.
Even if I use CeleryExecutor, how do can I kill/stop the running task? | As menioned by Pablo and Jorge pausing the Dag will not stop the task from being executed if the execution already started. However there is a way to stop a running task from the UI but it's a bit hacky.
When the task is on running state you can click on CLEAR this will call job.kill() the task will be set to shut_down... | 0.454054 | false | 2 | 4,861 |
2017-04-26 10:33:28.567 | How to stop/kill Airflow tasks from the UI | How can I stop/kill a running task on Airflow UI? I am using LocalExecutor.
Even if I use CeleryExecutor, how do can I kill/stop the running task? | from airflow gitter (@villasv)
" Not gracefully, no. You can stop a dag (unmark as running) and clear
the tasks states or even delete them in the UI. The actual running
tasks in the executor won't stop, but might be killed if the
executor realizes that it's not in the database anymore. " | 0.715303 | false | 2 | 4,861 |
2017-04-26 11:53:42.973 | how to design this security demands? | A python program P running on server S1, listening port 8443.
Some other services can send id_isa, ip pair to P. P could use this pair and make a ssh connection to the ip (create a ssh process).
How to make protect the id_rsa file even the machine S1 is cracked ? How to let root user can't get the id_rsa content (It se... | Why don't you just add an ssh-daemon on Port 8443 and use ssh-Agent forwarding?
That way the private key never gets written down on P and you don't have to write and maintain your own program. | 0 | false | 1 | 4,862 |
2017-04-27 14:14:02.810 | Is there a reason to create classes on seperate modules? | As I learn more about Python I am starting to get into the realm of classes. I have been reading on how to properly call a class and how to import the module or package.module but I was wondering if it is really needed to do this.
My question is this: Is it required to move your class to a separate module for a functio... | You can do as you please. If the code for your classes is short, putting them all in your main script is fine. If they're longish, then splitting them out into separate files is a useful organizing technique (that has the added benefit of the code in them no getting recompiled into byte-code everytime the the script th... | 0.201295 | false | 1 | 4,863 |
2017-04-28 01:07:43.320 | How to run python code at prescribed time and store output in database | I have written a piece of python code that scrapes the odds of horse races from a bookmaker's site. I wish to now:
Run the code at prescribed increasingly frequent times as the race draws closer.
Store the scraped data in a database fit for extraction and statistical analysis in R.
Apologies if the question is poorly... | In windows, you can use Task Scheduler or in Linux crontab. You can configure these to run python with your script at set intervals of time. This way you don't have a python script continuously running preventing some hangup in a single call from impacting all subsequent attempts to scrape or store in database.
To stor... | 0 | false | 1 | 4,864 |
2017-04-28 16:13:20.563 | How to recognize Chinese or English name using python | Given a bunch of names, how can we find out which are Chinese names and which are English names? For the Chinese names, I build a list of the Chinese last names to find out the Chinese names. For example, Bruce Lee, Lee is a Chinese last name, so we regard Bruce Lee is a Chinese name. However, the Chinese last names li... | If you have the lists of typical Chinese and English names and the problem is performance only, I suggest you convert the lists into sets and then ask for membership in both sets as this is much faster than finding out whether an element is present in a large list. | 0.386912 | false | 1 | 4,865 |
2017-04-29 14:20:47.563 | How can I open a Windows 10 app with a python script? | So, as you may know there are certain apps on Windows that can be installed from the app store, and are classified as Windows Trusted Apps. I am not sure, but I think these do not use the classic .exe format. So I am writing a python script to automate some stuff when I start my pc, and I need to start a certain Window... | You can use this new technique, its called winapps its used for searching, modifying, and uninstalling apps. Its download command on cmd windows is pip install winapps. | 0 | false | 1 | 4,866 |
2017-04-30 17:10:26.033 | Downloading Random.py Using Anaconda | I am trying to download the random module and was wondering if I copy a code and put it in a file editor, how do I go about installing it through pip? I placed the code in notepad and saved it on my desktop as random.py. What do I do now so that I can get this in installed through anaconda? I tried pip install random.p... | Use pip install random. That works with every Python distribution. | -0.135221 | false | 2 | 4,867 |
2017-04-30 17:10:26.033 | Downloading Random.py Using Anaconda | I am trying to download the random module and was wondering if I copy a code and put it in a file editor, how do I go about installing it through pip? I placed the code in notepad and saved it on my desktop as random.py. What do I do now so that I can get this in installed through anaconda? I tried pip install random.p... | If using python3, it will simply be
pip3 install random
as @Remi stated. | 0 | false | 2 | 4,867 |
2017-04-30 21:20:16.187 | Mathematical functions on Python 3 | I have a work to do on numerical analysis that consists on implementing algorithms for root-finding problems. Among them are the Newton method which calculates values for a function f(x) and it's first derivative on each iteraction.
For that method I need a way to the user of my application enter a (mathematical) func... | If you trust the user, you could input a string, the complete function expression as it would be done in Python, then call eval() on that string. Python itself evaluates the expression. However, the user could use that string to do many things in your program, many of them very nasty such as taking over your computer o... | 0.386912 | false | 1 | 4,868 |
2017-05-02 08:29:33.183 | How to dynamically schedule tasks in Django? | I need to build an app in Django that lets the user do some task everyday at the time they specify at runtime.
I have looked at Celery but couldn't find anything that will help. I found apply_async and I can get the task to execute once at the specificied duration but not recurrent. I am missing something but don't kn... | There is django-celery-beat package which allows you to dynamicly add tasks to database and then they are executed as you defined in database.(e.g. every 5 minutes) But currently they have bug which causes that task is not appended to celery queue when added to database. One suggested workaround is to restart celery pr... | 0.16183 | false | 1 | 4,869 |
2017-05-04 10:07:43.853 | How to convert date formatted as string to a number in excel using openpyxl | I process a report that consists of date fields. There are some instances wherein the date seen in the cell is not a number (how do I know? I use the isnumber() function from excel to check if a date value is really a number).
Using a recorded macro, for all the date columns, I do the text to columns function in excel ... | Sounds like you might want to take advantage of the type guessing in openpyxl. If so, open the workbook with guess_types=True and see if that helps. NB. this feature is more suited to working with text sources like CSV and is likely to be removed in future releases. | 0 | false | 1 | 4,870 |
2017-05-04 15:56:34.737 | Google analytics .dat file missing, falling back to noauth_local_webserver | I have an AWS EC2 machine that has been running nightly google analytics scripts to load into a database. It has been working fine up for months until this weekend. I have not made any changes to the code.
These are the two errors that are showing up in my logs:
/venv/lib/python3.5/site-packages/oauth2client/_helpers... | I am not sure why this is happening, But I have a list of steps which might help you.
check if this issue is caused by google analytics API version, google generally deprecates the previous versions of their API.
I am guessing that you are running this code on cron on your EC2 serv, make sure that you include the path... | 0.386912 | false | 1 | 4,871 |
2017-05-04 18:41:21.467 | white spaces while copying password into password filed | From experience I know that sometimes while copying and pasting a password into the password filed a white space is copied along with the password and this is causing errors (I don't know how common this is, but it happens). Now I'm learning Python (no previous programming experience) and came across rstrip() lstrip()... | I would use strip() to strip both sides :-) I think it's very annoying when you copy paste a password and it's not accepted because you mis-copied with some extra blank characters. | 0.201295 | false | 2 | 4,872 |
2017-05-04 18:41:21.467 | white spaces while copying password into password filed | From experience I know that sometimes while copying and pasting a password into the password filed a white space is copied along with the password and this is causing errors (I don't know how common this is, but it happens). Now I'm learning Python (no previous programming experience) and came across rstrip() lstrip()... | I would recommend not doing anything. I don't believe in editing any password submissions, except for sanitizing to prevent security risks. | 0 | false | 2 | 4,872 |
2017-05-04 19:24:28.433 | Appending to a text file in S3 | I know how to write and read from a file in S3 using boto. I'm wondering if there is a way to append to a file without having to download the file and re-upload an edited version? | There is no way to append data to an existing object in S3. You would have to grab the data locally, add the extra data, and then write it back to S3. | 1.2 | true | 1 | 4,873 |
2017-05-06 18:51:01.297 | How do I remove a file from a git repository with dulwich? | With dulwich I can stage a file using repo.stage, but how do I remove a file ?
I am looking for the equivalent of git rm | You can "stage" a file that no longer exists, which will remove it. Alternatively, there is also a dulwich.porcelain.remove function that provides the equivalent of git rm (i.e. removes the file if it exists and then unversions it). | 0 | false | 1 | 4,874 |
2017-05-07 21:12:03.533 | Connecting to a data stream with Python | I need to connect to a data stream written in C++ with my current program in Python, any advice or resources on how to connect? | Java has a native keyword that allows functions from c++ to be brought into java as methods. Python might have the same feature. | 1.2 | true | 1 | 4,875 |
2017-05-09 02:17:39.970 | Python - convert mysql timestamps type to matplotlib and graph | After doing a bit of research I am finding it difficult to find out how to use mysql timestamps in matplotlib.
Mysql fields to plot
X-axis:
Field: entered
Type: timestamp
Null: NO
Default: CURRENT TIMESTAMP
Sample: 2017-05-08 18:25:10
Y-axis:
Field: value
Type: float(12,6)
Null: NO
Sample: 123.332
What date format is m... | you can use datetime module,although i use now() function to extract datetime from mysql,but i consider the format is the same。
for instance
python>import datetime as dt
i put the datetime data into a list named datelist,and now you can use datetime.strptime function to convert the date format to what you want
python>... | 1.2 | true | 1 | 4,876 |
2017-05-09 06:03:48.510 | Retain edit data for one form when submitting a second | I have a page that I want to behave like this: First, the user only sees a single form, for the sake of example, lets say it allows the user to select the type of product. Upon submitting this form, a second form (whose contents depend on the product type) appears below it. The user can then either fill out the second ... | may be you can store the first form values in session and provide them as initial data for the first form when you are rendering the second form with error. For eg: data={"f1":request.session['abc'],"f2":request.session["xyz"]} form1 = abc(initial=data) | 0 | false | 1 | 4,877 |
2017-05-09 09:56:42.160 | How can I make a turtle not touch a line? | Our task is to create a turtle that always stays within a rectangle.
It would be really great if you could show me how I can make a turtle run away from a line another turtle has created.
Please don't fix the problem for me. | First, you need the bounds of the rectangle in some form -- it can be the lower left position plus a width and height or it can be the lower left position and the upper right position, etc. (It could even be the formulas of the four lines that make up the rectangle.)
Then write a predicate function that tests if an (x... | 1.2 | true | 1 | 4,878 |
2017-05-09 13:39:27.750 | Merging two DataFrames (CSV files) with different dates using Python | I would like to know how can I proceed in order to concatenate two csv files, here is the composition of this two files:
The first one contains some datas related to water chemical parameters, these measurements are taken in different dates.
The second one shows the different flow values of waste water, during a certa... | The first file is smth like:
Timestamp ; Flow1 ; Flow 2
2017/02/17 00:05 ; 540 ; 0
2017/02/17 00:10 ; 535 ; 0
2017/02/17 00:15 ; 543 ; 0
2017/02/17 00:20 ; 539 ; 0
CSV file #2:
Timestamp ; DOC ; Temperatute ; UV254;
2017/02/17 00:14 ; 668.9 ; 15,13 ; 239,23
2017/02/17 00:15 ; 669... | 0 | false | 1 | 4,879 |
2017-05-10 05:42:55.940 | Counting Records in Azure Table Storage (Year: 2017) | We have a table in Azure Table Storage that is storing a LOT of data in it (IoT stuff). We are attempting a simple migration away from Azure Tables Storage to our own data services.
I'm hoping to get a rough idea of how much data we are migrating exactly.
EG: 2,000,000 records for IoT device #1234.
The problem I am f... | Returning number of entities in the table storage is for sure not available in Azure Table Storage SDK and service. You could make a table scan query to return all entities from your table but if you have millions of these entities the query will probably time out. it is also going to have pretty big perf impact on you... | 1.2 | true | 1 | 4,880 |
2017-05-10 15:12:00.960 | Running multiple scenes in Pythonista | I am learning Python through Pythonista on the iPhone. The first thing I did was make a simple touch-screen joystick (controller). Im starting to work on the actual game, but i don't know how to merge or overlay the 2 scenes. (One is the actual game, the other is the controller I made in another file.) I have already ... | Instead of putting the joystick on a separate scene, you should draw it on a scene.Node. Then in your game scene, you can add it like another sprite, using Scene.add_child().
To convert the touch positions to the nodes coordinate system, you can use Node.point_from_scene(), and to convert back to the scene’s coordinate... | 0 | false | 1 | 4,881 |
2017-05-10 15:34:45.183 | Does gspread Support Accessing Spreadsheets on Team Drives? | I am trying to access a Spreadsheet on a Team Drive using gspread. It is not working. It works if the spreadsheet is on my Google Drive. I was wondering if gspread has the new Google Drive API v3 capability available to open spreadsheets on Team Drives. If so, how do I specify the fact I want to open a spreadsheet on ... | Make sure you're using the latest version of gspread. The one that is e.g. bundled with Google Colab is outdated:
!pip install --upgrade gspread
This fixed the error in gs.csv_import for me on a team drive. | 0 | false | 1 | 4,882 |
2017-05-10 16:54:23.553 | Using aws chalice to build a single page application? | Has anyone here ever worked with chalice? Its an aws tool for creating api's. I want to use it to create a single page application, but Im not sure how to actually serve html from it. I've seen videos where its explored, but I can't figure out how they actually built the thing. Anyone have any advice on where to go... | You wouldn't serve HTML from Chalice directly. It is explicitly designed to work in concert with AWS Lambda and API Gateway to serve dynamic, API-centric content. For the static parts of an SPA, you would use a web server (nginx or Apache) or S3 (with or without CloudFront).
Assuming you are interested in a purely "se... | 1.2 | true | 1 | 4,883 |
2017-05-10 23:09:25.163 | How extract vocabulary vectors from gensim's word2vec? | I want to analyze the vectors looking for patterns and stuff, and use SVM on them to complete a classification task between class A and B, the task should be supervised. (I know it may sound odd but it's our homework.) so as a result I really need to know:
1- how to extract the coded vectors of a document using a train... | If you have trained word2vec model, you can get word-vector by __getitem__ method
model = gensim.models.Word2Vec(sentences)
print(model["some_word_from_dictionary"])
Unfortunately, embeddings from word2vec/doc2vec not interpreted by a person (in contrast to topic vectors from LdaModel)
P/S If you have texts at the obj... | 0.673066 | false | 1 | 4,884 |
2017-05-11 17:44:03.573 | How to show input value next to it ? Python | So I'm sending an item to my html page and put a value off this item in an input.
What i want is when i change the input, i want to dynamically print the new value next to the input.
Something like that :
<input type='text' value="{{item.qty}}"/>
{{myNewInputValue}}
I know how to do this with angular but don't know... | Unfortunately you can't do this directly with Django. You'll have to set up an AJAX handler (probably on keypress) in order to do this. | 1.2 | true | 1 | 4,885 |
2017-05-12 14:11:18.177 | Creating a "pen drive program" with Python | I'm bringing you this issue: I'm trying to create a program to run in Windows using PyQT, to work on a pen drive. My idea is: I plug my pen drive, and everything that I need to run the program is there, including Python 3, PyQT, etc.. I don't want the user to install all the requirements, I just want one executable tha... | Just an idea - not sure if that would work under your specific conditions (PyQT etc), but couldn't you run it from the pen drive directly? As in create a Python virtual environment (for example using venv, with all the dependencies) on the pendrive and then call your program using the python interpreter in the installe... | 0 | false | 1 | 4,886 |
2017-05-12 15:15:55.723 | How does the Flask-Gunicorn-Nginx setup works under the hood? | I was wondering how exactly is the request handled, I mean,I think it's something like this:
Nginx receives the request, does initial handling based on configuration,passes to Gunicorn
Gunicorn receives it, and initiate a instance of the Flask app, with the request data
Flask app receives the request data, and does th... | Not quite. Basically flask is the webapp, it gets loaded when gunicorn starts up.
At that point the flask app is up and running and gunicorn itself can answer requests by sending them to the flask app within its python processes (ie, no net traffic).
Nginx sits on top of gunicorn and proxies requests between clients a... | 0.673066 | false | 1 | 4,887 |
2017-05-12 22:42:34.687 | How is eventlet tpool useful? | I am trying to understand what eventlet.tpool is useful for. The docs say that tpool.execute() lets you take a blocking function and run it in a new thread. However, the tpool.execute() method itself blocks until the thread is complete! So how is this possibly useful? If I have some blocking/long running function myfun... | You wrote the answer yourself, I can only rephrase it.
With regard to Eventlet, Gevent, Twisted, Asyncio and other cooperative multitasking libraries we use term "blocking" to denote that it blocks everything. Unpatched time.sleep(1) will block all coroutines/greenthreads as opposed to OS threads semantics where it wou... | 1.2 | true | 1 | 4,888 |
2017-05-13 14:16:53.670 | How to finding distance between camera and detected object using openCV in python? | I want to find out the distance between the camera and the people (detected using the HOG descriptor) in front of camera.I'm looking into more subtle approach rather than calibrating the camera and without knowing any distances before hand.
This can fall under the scenario of an autonomous car finding the distance betw... | I am sorry but finding a distance is a metrology problem, so you need to calibrate your camera. Calibrating is a relatively easy process which is necessary for any measurements.
Let's assume you only have one calibrated camera, if the orientation/position of this camera is fixed relatively to the ground plane, it is po... | -0.964028 | false | 1 | 4,889 |
2017-05-15 05:25:46.910 | Music genre classification with sklearn: how to accurately evaluate different models | I'm working on a project to classify 30 second samples of audio from 5 different genres (rock, electronic, rap, country, jazz). My dataset consists of 600 songs, exactly 120 for each genre. The features are a 1D array of 13 mfccs for each song and the labels are the genres.
Essentially I take the mean of each set of 13... | To evaluate a classifier's accuracy against another classifier, you need to randomly sample from the dataset for training and test. Use the test dataset to evaluate each classifier and compare the accuracy in one go.
Given a dataset stored in a dataframe , split it into training and test (random sampling is better to ... | 0 | false | 1 | 4,890 |
2017-05-15 13:01:29.727 | easy_install not working with no error | I'm trying to get new packages (request for example) and trying to do it through easy_install, but when I try to open it (both easy_install and easy_install-3.6) all I get is a blank terminal screen popping up for a second and than closing with nothing happening. What's wrong with it and how can I get new packages? | easy_install must be used as a command in the command prompt and it cannot be opened as an application. Go to the folder where easy_install is and open command-prompt in that folder. Now perform installation of any libraries using:
>easy_install pandas #example
Or you can set this path in your environment variables and... | 1.2 | true | 1 | 4,891 |
2017-05-15 20:22:39.577 | opengl gluLookAt with orientation in degrees instead of coordinates | I started to to something with opengl in pygame, but I'm stuck at the point where gluLookAt takes world coordinates to orient the camera, but I want to move the camera with the mouse, so I have values like "mouse moved 12 pixels to the right".
At the moment I have gluLookAt(player_object.x, player_object.y, player_obj... | You need to compute the player forward vector:
The forward vector is the vector that points in the forward direction seen from the player's eyes - it tells you in which direction the eyes of the player are looking.
The local forward vector (I call it lfw for now) is probably (0,0,1) because you specified the y axis as ... | 0.386912 | false | 1 | 4,892 |
2017-05-16 15:06:59.537 | Old version of a script is imported using import on Python | I am currently trying to load function from another .py file. I have in the same folder: algo.py and test_algo.py. I need to import all functions from algo in test_algo so I use the command:
from algo import *
The import is succesful however one function do_sthg() takes 3 arguments in algo but the imported version requ... | I have not been able to determine where the problem was so I just specificied the full path using the command getcwd from os. It has worked so far. It means I must have a hidden .pyc or .py~ file somewhere. | 0.201295 | false | 1 | 4,893 |
2017-05-16 16:12:35.157 | I want to use pyaudio to record wav more than hours | I use pyaudio with python2.7.13 to record wav ,but my pragram dead when I record more than 1 hour , how can I do if I want to record for more than 1 hour with py2.7. Thanks for your replay! | Surely you can record audio for more than an hour using pyaudio. Try invoking the recording function in a thread and put the main process in a loop or sleep for that period.
Note: Make sure you do not run out of memory. | 1.2 | true | 1 | 4,894 |
2017-05-16 19:37:43.113 | How do I grab console output from a program running in a screen session? | I'm currently in the process of hacking together a bit of bash and python3 to integrate my Minecraft server with my friends Discord. I managed to power through most of the planned features with nary a hitch, however now I've gotten myself stuck halfway into the chat integration. I can send messages from the Discord to ... | Well, the ideal solution would be to write a bukkit plugin/forge mod to do this, rather than doing this entirely from outside the actual server. That being said, however, your best bet is probably watching the log files, as JNevill says in the comment. | 1.2 | true | 1 | 4,895 |
2017-05-17 11:41:40.830 | How to run a python program from c++ | I am trying to make a program in c++, but i cant make the program because in one part of the code I need to run a python program from c++ and I dont know how to do it. I've been trying many ways of doing it but none of them worked. So the code should look sometihnglike this:somethingtoruntheprogram("pytestx.py"); or so... | There's POSIX popen and on Windows _popen, which is halfway between exec and system. It offers the required control over stdin and stdout, which system does not. But on the other hand, it's not as complicated as the exec family of functions. | 0 | false | 1 | 4,896 |
2017-05-18 10:59:28.437 | Answering business questions with machine learning models (scikit or statsmodels) | Thanks for your help on this.
This feels like a silly question, and I may be overcomplicating things. Some background information - I just recently learned some machine learning methodologies in Python (scikit and some statsmodels), such as linear regression, logistic regression, KNN, etc. I can work the steps of prep... | Why did customer service calls drop last month?
It depends on what type and features of data you have to analyze and explore the data. One of the basic things is to look at correlation between features and target variable to check if you can identify any feature that can correlate with the drop of calls. So exploring ... | 0 | false | 1 | 4,897 |
2017-05-18 22:11:15.123 | Pydub export error - Choose encoder manually | I'm trying to export a file as mp3 in pydub, but I get this error:
Automatic encoder selection failed for output stream #0:0. Default encoder for format mp3 is probably disabled. Please choose an encoder manually
How do I select an encoder manually, what is the default encoder, and how could I enable it?
PS: My Pydub... | The other solution did not work for me. The problem for me was that the ffmpeg version that came installed with Anaconda did not seem to be compiled with an encoder. So instead of:
DEA.L. mp3 MP3 (MPEG audio layer 3) (decoders: mp3 mp3float mp3_at ) (encoders: libmp3lame )
I saw:
DEA.L. mp3 ... | 0.673066 | false | 1 | 4,898 |
2017-05-20 17:43:44.273 | Trying to open Google Earth via a Script, file path nonexistent | I am trying to build a script that opens the Google Earth.app which I can see in Finder, but when I go to the applications folder it is not present. I looked at some other posts to find the filepath of Google Earth.app via sudo find / -iname *.app, which was /Applications/Google Earth.app. When I try and find this file... | Two problems going on here:
1) That path is probably correct. You're not using find correctly, in particular. You need to do sudo find / -name "*.app" (note the quotes around *app). From the man page:
-iname pattern
Like -name, but the match is case insensitive. For example, the patterns 'fo*' and 'F??' match th... | 1.2 | true | 1 | 4,899 |
2017-05-20 18:28:01.750 | How to import opencv in python (not from virtualenv) [UBUNTU] | I have problem about importing OpenCV to my project.
Not actually problem, but I didn't find how to do that. I know it's trivial, but I really don't know.
I have opencv downloaded and compiled in my home directory.
I know how to import it in virtualenv, but how to import it directly from original - non virtualenv pytho... | To import opencv in your python project import cv2 | 0 | false | 1 | 4,900 |
2017-05-20 20:19:38.823 | Restoring job-queue between telegram-bot restarts | I've built a small telegram bot using python-telegram-bot.
When a conversation is started,I add a periodical job to the job queue and then message back to the user every X minutes.
Problem is when my bot goes offline (maintenance, failures, etc), the jobqueue is lost and clients do not receive updates anymore unless th... | you have lots of options. at first you need to store all chat_ids. you can do it in database or simple text file.
then you need a trigger in order to start sending messages. I'm not familiar with your technology but i just create simple service in order to do it. | 0 | false | 1 | 4,901 |
2017-05-21 19:23:59.493 | I installed a pip package, how to know the module name to import? | I am doing a python webpage scraper .
Some tutorial told me to use this package: BeautifulSoup. So I installed it using pip.
Then, in my script, I try to import BeautifulSoup as bs. But I was warned that no module named BeautifulSoup.
Is there a reliable way to get module name out of an installed package? | Try this from bs4 import BeautifulSoup
Edit: Was already answered by @jonsharpe and @Vinícius Aguiar in the comments under the question. | -0.386912 | false | 1 | 4,902 |
2017-05-22 23:41:36.987 | How to receive answer from Google Assistant as a String, not as an audio stream | I am using the python libraries from the Assistant SDK for speech recognition via gRPC. I have the speech recognized and returned as a string calling the method resp.result.spoken_request_text from \googlesamples\assistant\__main__.py and I have the answer as an audio stream from the assistant API with the method resp.... | Currently (Assistant SDK Developer Preview 1), there is no direct way to do this. You can probably feed the audio stream into a Speech-to-Text system, but that really starts getting silly.
Speaking to the engineers on this subject while at Google I/O, they indicated that there are some technical complications on their ... | 0.986614 | false | 1 | 4,903 |
2017-05-23 01:40:11.107 | How to encode categorical with many levels on scikit-learn? | guys.
I have a large data set (60k samples with 50 features). One of this features (which is really relevant for me) is job names. There are many jobs names that I'd like to encode to fit in some models, like linear regression or SVCs. However, I don't know how to handle them.
I tried to use pandas dummy variables and ... | One another solution is that, you can do a bivariate analysis of the categorical variable with the target variable. What yo will get is a result of how each level affects the target. Once you get this you can combine those levels that have a similar effect on the data. This will help you reduce number of levels, as wel... | 0 | false | 1 | 4,904 |
2017-05-23 11:17:28.483 | Strip certain content of columns in multiple columns | I am currently in the phase of data preparation and have a certain issue I would like to make easy.
The content of my columns: 10 MW / color. All the columns which have this content are named with line nr. [int] or a [str]
What I want to display and which is the data of interest is the color. What I did was following:... | Ok just solved the question:
with df.shape I found out what the dimensions are and then started a for loop:
for i in range(1,x):
df[df.columns[i]]= df[df.columns[i]].str.split('/').[-1]
If you have any more efficient ways let me know :) | 1.2 | true | 1 | 4,905 |
2017-05-23 16:39:07.330 | Error while Registering the script to be run at start-up, how to resolve? | I am from electrical engineering and currently working on a project using UP-Board, I have attached LEDs, switch, Webcam, USB flash drive with it. I have created an executable script that I want to run at startup.
when I try to run the script in terminal using the code sudo /etc/init.d/testRun start it runs perfectly.... | The thing to remember is that you run the script as you but like chron startup does not, so you need to:
Ensure that the executable flags are set for all users and that it is in a directory that everybody has access to.
Use the absolute path for every thing, including the script.
Specify what to run it with, again wit... | 0 | false | 1 | 4,906 |
2017-05-23 17:08:16.163 | How to extract cluster id from Dirichlet process in PyMC3 for grouped data? | I am using PyMC3 to cluster my grouped data. Basically, I have g vectors and would like to cluster the g vectors into m clusters. However, I have two problems.
The first one is that, it seems PyMC3 could only deal with one-dimensional data but not vectors. The second problem is, I do not know how to extract the cluster... | If I understand you correctly, you're trying to extract which category (1 through k) a data point belongs to. However, a Dirichlet random variable only produces a probability vector. This should be used as a prior for a Categorical RV, and when that is sampled from, it will result in a numbered category. | 0 | false | 1 | 4,907 |
2017-05-25 17:55:31.487 | how to replace the desktop interface with a python application | I am creating a GUI interface that will be using a 7" touch display with a raspberry pi 3. I want the GUI to take the place of the desktop, I do not want it displayed in a window on the desktop. any thoughts on how to do that. I have read the raspberry pi documentation to edit the rc.local script to start the applica... | Your pi boots up and displays a console - just text - by running a program (getty). Then you run another application called a graphical display manager which then runs a window manager. On a pi it is usually gnome but there are many others,.. this window manager is what displays your GUI window. What you want is obviou... | 1.2 | true | 1 | 4,908 |
2017-05-25 19:07:32.590 | Determining Thousandths in a number | If an aircraft is flying VFR in the US, if the heading is east, the altitude must be an odd thousand plus 500 feet (1500, 3500, 5500, etc). If flying west, the altitude must be an even thousand plus 500 feet (2500, 4500, 6500, etc). If I input a given altitude, but it is the wrong (odd or even) for the heading, how do ... | You could divide your altitude by 1000.0 and cast to an int which would drop the decimal:
if int(altitude/1000.0) % 2 == 0
Then you can do whatever you want with that information. | 0 | false | 1 | 4,909 |
2017-05-26 18:06:17.477 | sqlalchemy automatically extend query or update or insert upon table definition | in my app I have a mixin that defines 2 fields like start_date and end_date. I've added this mixin to all table declarations which require these fields.
I've also defined a function that returns filters (conditions) to test a timestamp (e.g. now) to be >= start_date and < end_date. Currently I'm manually adding these ... | I tried extending Query but had a hard time. Eventually (and unfortunately) I moved back to my previous approach of little helper functions returning filters and applying them to queries.
I still wish I would find an approach that automatically adds certain filters if a table (Base) has certain columns.
Juergen | 0 | false | 1 | 4,910 |
2017-05-27 13:50:02.190 | Catching characters that do not pass regex validation | In a Django website of mine, I allow usernames that are alphanumeric, and/or contain @ _ . + -. Moreover, whitespaces are allowed too. I've written a simple regex to ensure this: '^[\w\s.@+-]+$'.
It might be an obvious question, but how do I capture characters that do not pass regex validation? I want to display such ... | Using the carat inside of square brackets (e.g. [^...]) makes it an inverse. So, for example, [A-Za-z0-9_] would match alpha numerics and underscores, whereas [^A-Za-z0-9_] would match anything that is not alpha numerics or underscores. In your case, the regex you seem to want is r'^[^\w\s\.\@\+\-]+$'. | 0.201295 | false | 1 | 4,911 |
2017-05-29 00:21:31.407 | How to simulate mouseMovement in-game? | I've just started learning python few days ago and I'd like to know how to simulate mouse movements inside games that have forced mouse coordinates.
directx environments?
I've currently tested pyautogui, ctypes, wxpython. I've also tried using directpython11 but I've had trouble installing it, ton of dll errors.
Can't ... | Found a perfect solution, it will require some extra stuff to run but its the shortest way.
Haven't found anyone who actually knows how to simulate mouse but decided to ask Sentdex for help and he recommended using vJoy to simulate controller.
So you need to simulate a controller instead of mouse by using a combinati... | 1.2 | true | 1 | 4,912 |
2017-05-29 12:12:21.593 | detect card symbol using opencv python | I'm trying to detect the difference between a spade, club, diamond and hart. the number on the card is irrelevant, just the suit matters.
i've tried color detection by looking at just the red or black colors, but that still leaves me with two results per color. how could i make sure i can detect each symbol individuall... | As the card symbol is at fixed positions, you may try below (e.g. in OpenCV 3.2 Python):
Crop the symbol at top left corner, image = image[h1:h2,w1:w2]
Threshold the symbol colors to black, the rest to white, thresh = mask = cv2.inRange(image,(0,0,0),(100,100,100))
Perform a find contour detection, _, contours, hier... | 0 | false | 1 | 4,913 |
2017-05-29 13:35:27.947 | how to use subprocess.check_output() in Python to list any file name as "abc*" | I have couple of file with same name, and I wanted to get the latest file
[root@xxx tmp]# ls -t1 abclog*
abclog.1957
abclog.1830
abclog.1799
abclog.1742
I can accomplish that by executing below command.
[root@xxx tmp]# ls -t1 abclog*| head -n 1
abclog.1957
But when I am trying to execute the same in python , getting ... | Make sure you execute this in the directory where the files exist. If you just fire up Idle to run this code, you will not be in that directory. | 0 | false | 1 | 4,914 |
2017-05-30 10:19:18.420 | Accessing Area.Name Throws Error | I'm just trying to find a way to access the name property of an Area element inside Revit Python Shell, tried looking on Jeremy Tammik's amazingly informative blog, tried AUGI, Revit API docs, been looking for 2 days now...
Tried accessing via a bunch of ways, FilteredElementsCollector(doc).OfCategory(BuiltInCategory.O... | To answer my own question, I actually never thought of looking through the code of other Revit Python scripts... in this case of PyRevit, which is in my opinion far more eloquently written than RPS, raelly looking forward for their console work to be done!
Basically, I had mistakenly used GetParameter('parameter') inst... | 0.135221 | false | 1 | 4,915 |
2017-05-31 06:10:48.543 | What are the ximgproc_DisparityWLSFilter.filter() Arguments? | I get a ximgproc_DisparityWLSFilter from cv2.ximgproc.createDisparityWLSFilter(left_matcher),
but I cannot get ximgproc_DisparityWLSFilter.filter() to work.
The error I get is
OpenCV Error: Assertion failed (!disparity_map_right.empty() && (disparity_map_right.depth() == CV_16S) && (disparity_map_right.channels() == ... | Unlike c++, Python doesn't work well with pointers. So the arguments are
Filtered_disp = ximgproc_DisparityWLSFilter.filter(left_disp,left, None,right_disp)
Note that it's no longer a void function in Python!
I figured this out through trial and error though. | 0 | false | 1 | 4,916 |
2017-06-01 02:06:47.637 | Serving dynamic webpages using aws? | I'm new to AWS in general, and would like to learn how to deploy a dynamic website with AWS. I'm coming from a self-hosted perspective (digitalocean + flask app), so I'm confused on what exactly the process would be for AWS.
With self-hosting solution, the process is something like:
User makes a request to my server (... | The recommended way to host a server with lambda and without EC2 is:
Host your front static files on S3 (html, css, js).
Configure your S3 bucket to be a static web server
Configure your lambdas for dynamic treatments and open it to the outside with API-gateway
your JS call the lambda through API-gateway, so don't... | 0.201295 | false | 2 | 4,917 |
2017-06-01 02:06:47.637 | Serving dynamic webpages using aws? | I'm new to AWS in general, and would like to learn how to deploy a dynamic website with AWS. I'm coming from a self-hosted perspective (digitalocean + flask app), so I'm confused on what exactly the process would be for AWS.
With self-hosting solution, the process is something like:
User makes a request to my server (... | You definitely have to weigh the pros and cons of serving the dynamic website via API GW and Lambda.
Pros:
Likely cheaper at low volume
Don't have to worry about scaling
Lambda Functions are easier to manage than even beanstalk.
Cons:
There will be some latency overhead
In some ways less flexible, although Python ... | 0.201295 | false | 2 | 4,917 |
2017-06-01 04:52:51.047 | How to select all the text in a page in QuteBrowser? | I need to map to select the document like in a normal browser. I tried using ggVG ( vim equivalent) but 'V' didn't work. Does anyone know how to do it? | Lower-case v should work (unless you use the QtWebEngine backend). Otherwise, Ctrl-A in insert mode does.
However, Stackoverflow is for programming questions - this isn't about programming. ;-) | 1.2 | true | 1 | 4,918 |
2017-06-01 17:00:37.357 | What the right way to localize the price in the Django-shop? | I know easy way, make a few different fields for needed currencies, but that's not only ugly, but the currencies will be hardcoded. It seems to me be more elegant through django-parler, but I do not quite understand how to do it. | The simplest way to localize prices in django-SHOP, is to use the MoneyInXXX class. This class can be generated for each currency using the MoneyMaker factory.
Whenever an amount of a Money class is formatted, it is localized properly. | 0.201295 | false | 1 | 4,919 |
2017-06-04 16:50:53.883 | How to uninstall Python indent plug-in from Notepad++? | I currently installed via plug-in manager of Notepad++ the Python Indent plug-in
I cannot uninstall it.
It's in update pane of Notepad++ plug-in manager, I check it and update it.
After update installation it is there again and not in installed plug-ins.
So it cannot be uninstalled.
Any idea how to remove it? | Yeah, I had also this problem of a plugin crashing my notepad++ every minute, but I used notepad++ portable, instead, you just go to the directory where it's installed and look for the plugins directory, notepad++ should offer an inner functionality of doing this. | 0 | false | 1 | 4,920 |
2017-06-04 20:06:53.037 | How does django know which user owns what data? | If for example I want to show a zero(0) for all users to see, and I want all users to add one(1) to the number With their Identity only shown for superusers. And how to make sure that each user only can add one time, and of course what is the Security requirements that have to be done to prevent unautohrized Access to ... | The web is stateless. This means that if a browser requests the same page twice, a traditional web server has no real way of knowing if it's the same user.
Enter sessions. Django has an authentication system which requires each user to log in. When the user is logged in they're given a session. A session is made of two... | 1.2 | true | 1 | 4,921 |
2017-06-05 11:28:59.797 | Celery best way manage/get eta of task | I want to get eta of task in celery each time with get request. There is no direct api in celery to get task scheduled time (except inspect() - but it's seems very costly to me)
How can i manage eta of particular task? The downside of storing eta time in Django model is not consistent ( either i couldnt store taks_id b... | I don't think there is a magic way to do this.
What I do in my app is just log the execution time for each task and return that as an ETA. If you wanted to get a little more accurate you could also factor in the redis queue size and the task consumption rate. | 1.2 | true | 1 | 4,922 |
2017-06-05 19:26:22.667 | Beginner VPS Vultr/ServerPilot -> How to change the homepage & access the files I uploaded? | So I just bought a VPS server from Vultr. Then I went on ServerPilot, and installed it on my server.
Now I can access, via SFTP, all the files on my server.
But how can I access these files from my web-browser via Internet? I mean, when I type in the IP address of my Vultr Server, I land on the ServerPilot page "your a... | you can connect to your server/serverpilot app via SSH/SFTP.
Filezilla, codeanywhere are options that allow you to do this. | 0.386912 | false | 1 | 4,923 |
2017-06-05 21:04:02.797 | Pyinstaller .exe throws Windows Defender [no publisher] | I developed a Python code and I converted it to an .exe with pyinstaller but the problem is that there is no publisher so each time a computer runs my program, Windows Defender throws an alert that says that there is no publisher so the program is not sure...
Does anyone know how to change the publisher of an .exe from... | This is a known False Positive with Windows Defender. This happens to my files as well when tested on a Windows 10 VM, and it happens to others as well. Also, Windows Defender 'Smartscreen' may block any unsigned file even when using another Antivirus, but you should be able to click more information and then continue
... | 0 | false | 1 | 4,924 |
2017-06-06 10:15:25.503 | Running python code on server | I'm building a website with some backprocessing with python. I want to know how to execute my python code from the server ?
There is no direct link between my HTML pages and my python code.
Let's say I want to do an addition with python in the server, how can I do that ?
Thanks so much in advence :) | is your server is linux or windows?
for linux: you can add a script to run your script on runlevel 3 or 5
write a script put it under /etc/init.d/ folder then link your script /etc/rc3.d or /etc/rc5.d to be start | 0 | false | 1 | 4,925 |
2017-06-06 10:43:39.630 | Create Matrix with gaussian-distributed ellipsis in python | I have a 100x100 Matrix with Zeros. I want to add a 10x20 ellipsis around a specific point in the Matrix - lets say at position 40,60. The Ellipsis should be filled with values from 0 to 1. (1 in the center - 0 at the edge) - The numbers should be gaussian-distributed.
Maybe someone can give me a clue, how to start wit... | You need to draw samples from a multi-variate gaussian distribution. The function you can use is numpy.random.multivariate_normal
You mean value matrix should be [40, 60]. The covariance C matrix should be 2X2. Regarding its values:
C[1, 1], C[2, 2]: decides the width of the ellipse along each axis. Choose it so that 3... | 0 | false | 1 | 4,926 |
2017-06-07 23:26:18.517 | Reading c++ 2d array in python swig | C++ part
I have a class a with a public variable 2d int array b that I want to print out in python.(The way I want to access it is a.b)
I have been able to wrap the most part of the code and I can call most of the functions in class a in python now.
So how can I read b in python? How to read it into an numpy array with... | You'll find that passing things back and forth between languages is much easier if you use a one-dimensional array in which you access elements using, e.g. arr[y*WIDTH+x].
Since you are operating in C++ you can even wrap these arrays in classes with nice operator()(int x, int y) methods for use on the C++ side.
In fact... | 0 | false | 1 | 4,927 |
2017-06-08 01:45:54.483 | Assignment 3 in Procedural Programming | I'm doing procedural programming and for my final assignment I have to create an application that will allow the user to do the following:
Allow the user to enter the customer’s details: name, postcode and loyalty card details
Check if the card has expired
Check the loyalty card number is valid by:
Allowing the u... | To get the last digit, you have to divide the number by 10 and get the remainder.
For example, to get the last digit of 123, you can do 123 % 10 which results to 3.
To remove the last digit, you have to divide the number by 10 and discard the remainder.
For example, to remove the last digit of 123, you can do 123 // 10... | 0 | false | 1 | 4,928 |
2017-06-08 16:24:27.640 | How to choose parameters for svm in sklearn | I'm trying to use SVM from sklearn for a classification problem. I got a highly sparse dataset with more than 50K rows and binary outputs.
The problem is I don't know quite well how to efficiently choose the parameters, mainly the kernel, gamma anc C.
For the kernels for example, am I supposed to try all kernels and... | Yes, this is mostly a matter of experimentation -- especially as you've told us very little about your data set: separability, linearity, density, connectivity, ... all the characteristics that affect classification algorithms.
Try the linear and Gaussian kernels for starters. If linear doesn't work well and Gaussian ... | 0 | false | 1 | 4,929 |
2017-06-10 01:04:21.160 | Cluster with t2.micro instances in AWS | I am new to Amazon Web Services (AWS) & I am using the free tier t2.micro right now ( 1 CPU and 1 GB memory). Doing some backtesting/ simulation stuff and it seems free tier is quite inadequate. Pretty slow actually. Thus thinking of options which will help me to run my code at a faster speed for few hours.
Option 1 :... | Much of what you are asking depends upon your use-case. For example, if you have work continually arriving then you will need capacity continually available. However, if it is more batch-oriented then you could start/stop capacity and even use the new Amazon Batch service that can allocate resources when needed and rem... | 1.2 | true | 1 | 4,930 |
2017-06-10 03:50:09.270 | Price column object to int in pandas | I have a column called amount with holds values that look like this: $3,092.44 when I do dataframe.dtypes() it returns this column as an object how can i convert this column to type int? | This will also work: dframe.amount.str.replace("$","").astype(int) | 0 | false | 1 | 4,931 |
2017-06-11 18:29:26.513 | Stanford NLP Output Formatting | Using the Stanford NLP, I want my text to go through lemmatization and coreference resolution.
So for an input.txt: "Stanford is located in California. It is a great University, founded in 1891."
I would want the output.txt: "Stanford be located in California. Stanford be a great University, found in 1891."
I... | If you are using the command line you can use -outputFormat text to get a human readable version or -outputFormat json to get a json version. In Java code you can use edu.stanford.nlp.pipeline.StanfordCoreNLP.prettyPrint() or edu.stanford.nlp.pipeline.StanfordCoreNLP.jsonPrint() to print out an Annotation. | 0 | false | 1 | 4,932 |
2017-06-12 16:16:09.073 | CNTK & Python: How to do reflect or symmetric padding instead of zero padding? | In the cntk.layers package we have the option to do zero padding:
pad (bool or tuple of bools, defaults to False) – if False, then the filter will be shifted over the “valid” area of input, that is, no value outside the area is used. If pad=True on the other hand, the filter will be applied to all input positions, and ... | There is a new pad operation (in master; will be released with CNTK 2.2) that supports reflect and symmetric padding. | 0 | false | 1 | 4,933 |
2017-06-13 09:13:03.480 | CNTK: The new clone do not match the cloned inputs of the clonee Block Function | I have trained a model in CNTK. Then I clone it and change some parameters; when I try to test the quantized model, I get
RuntimeError: Block Function 'softplus: -> Unknown': Inputs
'Constant('Constant70738', [], []), Constant('Constant70739', [], []),
Parameter('alpha', [], []), Constant('Constant70740', [], [])' of... | This line
cloneModel.parameters[0] = cloneModel.parameters[0]*4
tries to replace the first parameter with an expression (a CNTK graph) that multiplies the parameter by 4. I don't think that's the intent here. Rather, you want to do the above on the .value attribute of the parameter. Try this instead:
cloneModel.para... | 0 | false | 1 | 4,934 |
2017-06-13 16:10:10.957 | Generate a random nonlinear function going through given points in python | I have two given points (3.0, 3.2) and (7.0, 4.59) .
My job here is very simple but I don't even know how to start. I just need to plot 4 nonlinear functions that go through these two points.
Did somebody have a similar problem before? How does one even start? | It looks more like a math problem to me here, since you ask "how to start".
you know that a function's plot is just a lot of points (x, y) where y=f(x).
And I know that for any two pairs of points (not vertically aligned), I have an infinity of second-degree functions (parabolas) going through these two points.
they ar... | 0 | false | 1 | 4,935 |
2017-06-13 17:43:51.270 | Package management for coexisting Python 2 and 3 | I have been using Python 2.7 for a while now and installing packages using pip install without any issue. I just started using python 3 for a certain code and realized how confusing having different versions of Python can get.
I have Fedora 25, the default Python version is 2.7.13 and the default Python 3 version is Py... | pip3 install and python3 -m pip install — both work perfectly and don't have any impact on Python 2. You can have as many Pythons in your system as you want; I for one have Python 2.7, 3.4, 3.5 and 3.6. To distinguish different versions of pip I use versioned names: pip3.4 install.
And of course I use virtual environme... | 0.995055 | false | 1 | 4,936 |
2017-06-14 14:04:21.340 | How do I properly share my Python Packages using Eclipse+pydev+egit? | So I have a few Packages that I have made and I want to share them with my friends and I want to put them in separate github repositories, now I know how to make a project in eclipse, I already have my packages in the project and I also cloned the empty github repository in my local computer now when i connect the proj... | On git, you always work with the repo as a whole (even if you see only a part of it on Eclipse).
So, to do what you want, you have to actually create a new repo and copy the sources you want and then push from there (there are ways to do that with git saving the history too if that's important to you).
You might want t... | 0 | false | 1 | 4,937 |
2017-06-14 20:25:44.573 | Import a column from excel into python and run autocorrelation on it | I have a 1 column excel file. I want to import all the values it has in a variable x (something like x=[1,2,3,4.5,-6.....]), then use this variable to run numpy.correlate(x,x,mode='full') to get autocorrelation, after I import numpy.
When I manually enter x=[1,2,3...], it does the job fine, but when I try to copy paste... | You can use Pandas to import a CSV file with the pd.read_csv function. | 0 | false | 1 | 4,938 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.