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 |
|---|---|---|---|---|---|---|---|
2016-09-23 11:32:25.740 | force eclipse to use Python 3.5 autocompletion | I changed the interpreter for my python projects from 2.x to 3.5 recently. The code interpretes correctly with the 3.5 version.
I noticed that the autocompletion function of Eclipse still autocompletes as if I am using 2.x Python version. For example: print gets autocompleted without parenthesis as a statement and not ... | If you are using PyDev, make sure that interpreter grammar is set to 3.0 (right click project -> Properties -> PyDev - Interpreter/Grammar) | 1.2 | true | 1 | 4,503 |
2016-09-23 15:59:10.440 | Python sending files from a user directory to another user directory | I am very new to Python. I am curious to how I would be able to copy some files from my directory to another Users directory on my computer using python script? And would I be correct in saying I need to check the permissions of the users and files? So my question is how do I send files and also check the permissions a... | shutil is a very usefull thing to use when copying files.
I once needed to have a python script that moved all .mp3 files from a directory to a backup, deleted the original directory, created a new once, and moved the .mp3 files back in. shutil was perfect for thise.
The formatting for the command is how @Kieran has st... | 0.201295 | false | 1 | 4,504 |
2016-09-24 17:38:10.730 | How can a class hold an array of classes in django | I have been having trouble using django. Right now, I have a messagebox class that is suppose to hold messages, and a message class that extends it. How do I make it so messagebox will hold messages?
Something else that I cannot figure out is how classes are to interact. Like, I have a user that can send messages. Shou... | You're confusing two different things here. A class can easily have an attribute that is a list which contains instances of another class, there is nothing difficult about that.
(But note that there is no way in which a Message should extend MessageBox; this should be composition, not inheritance.)
However then you go... | 0.995055 | false | 1 | 4,505 |
2016-09-25 20:46:20.627 | Proper model defination in django for a widget manager | I have a model called widgetManager and 2 widget models called emailWidget and TextWidget. Now a single instance of widgetManager can have multiple instances of emailWidget and TextWidget. How can this be achieved with the following in mind
Till now i only have two but there can be more in future
The order of widget i... | If I understood your description correctly, you want a relationship where there can be many emailWidget or TextWidget for one instance of widgetManager.
What you can do in this case is add a ForeignKey field for widgetManager to emailWidget and TextWidget. This way, you can have many instances of the widgets while the... | 1.2 | true | 1 | 4,506 |
2016-09-25 21:08:00.110 | pip command by default using python 3...how to change it to python 2? | I am using macOS Sierra 10.12 and after I upgraded my OS I can no longer install packages for python 3 using pip. Before I used to use pip for python2 and pip3 for python 3 as I have both versions of Python. But now I can no longer use pip to install libraries for python2.
Can anyone help me how can I change my defaul... | install pip for Python2.7 with easy_install:
sudo easy_install-2.7 pip
now you can use pip for the same specific version of Python:
sudo pip2.7 install BeautifulSoup | 0.201295 | false | 1 | 4,507 |
2016-09-26 04:15:04.160 | Building Fortran extension for Python 3.5 or C extension for 2.7 | I have a Python 2.7 project that has thus far been using gfortran and MinGW to build extensions. I use MinGW because it seems to support write statements and allocatable arrays in the Fortran code while MSVC does not.
There is another project I would like to incorporate into my own (Netgen) but it is currently set up f... | I built Boost.Python libraries 1.61.0 from source for Python 2.7 using VC 14.0. Then used those in the build process for Netgen (again using VC 14.0) and pointed to the Python 2.7 library and include directories (as opposed to Python 3.5). This has thus far worked in Python 2.7 with my existing code. | 0 | false | 1 | 4,508 |
2016-09-26 22:34:13.827 | How to make kbhit() work in the Spyder environment | Has anyone come across a way to emulate kbhit() in the Spyder environment on Windows? Somehow the development environment gets between the Python program and the keyboard, so any simple way of doing it (i.e. msvcrt.kbhit()) does not work. | Set this configuration in Spyder:
Run > Run Configuration Per File > Execute In An External System Terminal
In my experience "msvcrt.kbhit" only works in CMD. | 0.201295 | false | 1 | 4,509 |
2016-09-26 22:46:17.710 | Read/Write TCP options field | I want to read and write custom data to TCP options field using Scapy. I know how to use TCP options field in Scapy in "normal" way as dictionary, but is it possible to write to it byte per byte? | You can not directly write the TCP options field byte per byte, however you can either:
write your entire TCP segment byte per byte: TCP("\x01...\x0n")
add an option to Scapy's code manually in scapy/layers/inet.py TCPOptions structure
These are workarounds and a definitive solution to this would be to implement a by... | 1.2 | true | 1 | 4,510 |
2016-09-27 03:22:46.107 | How to put an overlay on a video | I am currently working in Python and using OpenCV's videocapture and cv.imshow to show a video. I am trying to put an overlay on this video so I can draw on it using cv.line, cv.rectangle, etc. Each time the frame changes it clears the image that was drawn so I am hoping if I was to put an overlay of some sort on top o... | What you need are 2 Mat objects- one to stream the camera (say Mat_cam), and the other to hold the overlay (Mat_overlay).
When you draw on your main window, save the line and Rect objects on Mat_overlay, and make sure that it is not affected by the streaming video
When the next frame is received, Mat_cam will be update... | 0 | false | 2 | 4,511 |
2016-09-27 03:22:46.107 | How to put an overlay on a video | I am currently working in Python and using OpenCV's videocapture and cv.imshow to show a video. I am trying to put an overlay on this video so I can draw on it using cv.line, cv.rectangle, etc. Each time the frame changes it clears the image that was drawn so I am hoping if I was to put an overlay of some sort on top o... | I am not sure that I have understood your question properly.What I got from your question is that you want the overlay to remain on your frame, streamed from Videocapture, for that one simple solution is to declare your "Mat_cam"(camera streaming variable) outside the loop that is used to capture frames so that "Mat_c... | 0 | false | 2 | 4,511 |
2016-09-27 11:02:46.513 | Are Python modules compiled? | Trying to understand whether python libraries are compiled because I want to know if the interpreted code I write will perform the same or worse.
e.g. I saw it mentioned somewhere that numpy and scipy are efficient because they are compiled. I don't think this means byte code compiled so how was this done? Was it compi... | Python can execute functions written in Python (interpreted) and compiled functions. There are whole API docs about writing code for integration with Python. cython is one of the easier tools for doing this.
Libraries can be any combination - pure Python, Python plus interfaces to compiled code, or all compiled. Th... | 0.135221 | false | 1 | 4,512 |
2016-09-27 14:09:00.927 | modify and write large file in python | Say I have a data file of size 5GB in the disk, and I want to append another set of data of size 100MB at the end of the file -- Just simply append, I don't want to modify nor move the original data in the file. I know I can read the hole file into memory as a long long list and append my small new data to it, but it's... | Let's start from the second point: if the list you store in memory is larger than the available ram, the computer starts using the hd as ram and this severely slow down everything. The optimal way of outputting in your situation is fill the ram as much as possible (always keeping enough space for the rest of the softwa... | 0 | false | 1 | 4,513 |
2016-09-28 05:42:31.530 | How to measure similarity between two python code blocks? | Many would want to measure code similarity to catch plagiarisms, however my intention is to cluster a set of python code blocks (say answers to the same programming question) into different categories and distinguish different approaches taken by students.
If you have any idea how this could be achieved, I would appre... | One approach would be to count then number of functions, objects, keywords possibly grouped into categories such as branching, creating, manipulating, etc., and number variables of each type. Without relying on the methods and variables being called the same name(s).
For a given problem the similar approaches will ten... | 0.386912 | false | 1 | 4,514 |
2016-09-29 00:44:17.923 | manually building installing python packages in linux so they are recognized | My system is SLES 11.4 having python 2.6.9.
I know little about python and have not found where to download rpm's that give me needed python packages.
I acquired numpy 1.4 and 1.11 and I believe did a successful python setup.py build followed by python setup.py install on numpy.
Going from memory I think this installed... | think i figured it out. Apparently SLES 11.4 does not include the development headers in the default install from their SDK for numpy 1.8.
And of course they don't offer matplotlib along with a bunch of common python packages.
The python packages per the SLES SDK are the system default are located under/usr/lib64/pyth... | 0 | false | 1 | 4,515 |
2016-09-29 11:23:43.900 | Check if Entry widget is selected | I'm making a program on the Raspberry Pi with a touchscreen display.
I'm using Python Tkinter that has two entry widgets and one on screen keypad. I want to use the same keypad for entering data on both entry widgets.
Can anyone tell me how can i check if an entry is selected? Similar like clicking on the Entry using... | There is always a widget with the keyboard focus. You can query that with the focus_get method of the root window. It will return whatever widget has keyboard focus. That is the window that should receive input from your keypad. | 1.2 | true | 1 | 4,516 |
2016-09-29 13:42:07.020 | Is it possible to include interpreter path (or set any default code) when I create new python file in Pycharm? | I haven't been able to find anything and I am not sure if this is the place I should be asking...
But I want to include the path to my interpreter in every new project I create. The reason being is that I develop locally and sync my files to a linux server. It is annoying having to manually type #! /users/w/x/y/z/bi... | You should open File in the main menu and click Default Settings, collapse the Editor then click File and Code Templates, in the Files tab click on the + sign and create a new Template, give the new template a name and extension, in the editor box put your template content, in your case #! /users/w/x/y/z/bin/python app... | 1.2 | true | 2 | 4,517 |
2016-09-29 13:42:07.020 | Is it possible to include interpreter path (or set any default code) when I create new python file in Pycharm? | I haven't been able to find anything and I am not sure if this is the place I should be asking...
But I want to include the path to my interpreter in every new project I create. The reason being is that I develop locally and sync my files to a linux server. It is annoying having to manually type #! /users/w/x/y/z/bi... | Click on the top-right tab with your project name, then go Edit Configurations and there you can change the interpreter. | 0 | false | 2 | 4,517 |
2016-09-29 14:49:55.217 | Adding a text box to an excel chart using openpyxl | I'm trying to add a text box to a chart I've generated with openpyxl, but can't find documentation or examples showing how to do so. Does openpyxl support it? | I'm not sure what you mean by "text box". In theory you can add pretty much anything covered by the DrawingML specification to a chart but the practice may be slightly different.
However, there is definitely no built-in API for this so you'd have to start by creating a sample file and working backwards from it. | 0 | false | 1 | 4,518 |
2016-09-29 20:27:59.523 | how to export data to unix system location using python | I am trying to write the file to my company's project folder which is unix system and the location is /department/projects/data/. So I used the following code
df.to_csv("/department/projects/data/Test.txt", sep='\t', header = 0)
The error message shows it cannot find the locations. how to specify the file location in U... | I have find the solution. It might because I am using Spyder from anaconda. As long as I use "\" instead of "\", python can recognize the location. | 1.2 | true | 1 | 4,519 |
2016-09-29 22:02:24.740 | how to generate a responsive PDF with Django? | how to generate a responsive PDF with Django?.
I want to generate a PDF with Django but i need that is responsive, that is to say, the text of the PDF has that adapted to don't allow space empty.
for example to a agreement this change in the text, then, i need to adapt the to space of paper leaf. | PDF is not built to be responsive, it is built to display the same no matter where it is viewed.
As @alxs pointed out in a comment, there are a few features that PDF viewing applications have added to simulate PDFs being responsive. Acrobat's Reflow feature is the best example of this that I am aware of and even it str... | 0.673066 | false | 1 | 4,520 |
2016-10-01 00:19:15.287 | In Python, how can I get a line number corresponding to a given character location? | If I have a text that I've read into memory by using open('myfile.txt').read(), and if I know a certain location in this file, say, at character 10524, how can I find the line number of that location? | Examine the text preceding your desired position and count the number of \n characters. | 0.265586 | false | 1 | 4,521 |
2016-10-01 09:56:48.570 | How to go about incremental scraping large sites near-realtime | I want to scrape a lot (a few hundred) of sites, which are basically like bulletin boards. Some of these are very large (up to 1.5 million) and also growing very quickly. What I want to achieve is:
scrape all the existing entries
scrape all the new entries near real-time (ideally around 1 hour intervals or less)
For ... | For example: I have a site with 100 pages and 10 records each. So I scrape page 1, and then go to page 2. But on fast growing sites, at the time I do the request for page 2, there might be 10 new records, so I would get the same items again. Nevertheless I would get all items in the end. BUT next time scraping this sit... | 0.386912 | false | 1 | 4,522 |
2016-10-01 10:46:11.987 | ValueError: Could not find a default download directory of nltk | I have problem on import nltk.
I configured apache and run some sample python code, it worked well on the browser.
The URL is : /localhost/cgi-bin/test.py.
When I import the nltk in test.py its not running. The execution not continue after the "import nltk" line.And it gives me that error ValueError: Could not find a d... | The Problem is raised probably because you don't have a default directory created for your ntlk downloads. If you are on a Windows Platform, All you need to do is to create a directory named "nltk_data" in any of your root directory and grant write permissions to that directory. The Natural Language Tool Kit initially ... | 1.2 | true | 1 | 4,523 |
2016-10-03 17:11:54.947 | Automate file downloading using a chrome extension | I have a .csv file with a list of URLs I need to extract data from. I need to automate the following process: (1) Go to a URL in the file. (2) Click the chrome extension that will redirect me to another page which displays some of the URL's stats. (3) Click the link in the stats page that enables me to download the dat... | There is a python package called mechanize. It helps you automate the processes that can be done on a browser. So check it out.I think mechanize should give you all the tools required to solve the problem. | 0 | false | 1 | 4,524 |
2016-10-04 11:51:11.397 | Using pip on Windows installed with both python 2.7 and 3.5 | I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version? | The answer from Farhan.K will work. However, I think a more convenient way would be to rename python35\Scripts\pip.exe to python35\Scripts\pip3.exe assuming python 3 is installed in C:\python35.
After renaming, you can use pip3 when installing packages to python v3 and pip when installing packages to python v2. Without... | 0.050976 | false | 4 | 4,525 |
2016-10-04 11:51:11.397 | Using pip on Windows installed with both python 2.7 and 3.5 | I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version? | You will have to use the absolute path of pip.
E.g: if I installed python 3 to C:\python35, I would use:
C:\> python35\Scripts\pip.exe install packagename
Or if you're on linux, use pip3 install packagename
If you don't specify a full path, it will use whichever pip is in your path. | 1.2 | true | 4 | 4,525 |
2016-10-04 11:51:11.397 | Using pip on Windows installed with both python 2.7 and 3.5 | I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version? | I tried many things , then finally
pip3 install --upgrade pip worked for me as i was facing this issue since i had both python3 and python2.7 installed on my system.
mind the pip3 in the beginning and pip in the end.
And yes you do have to run in admin mode the command prompt and make sure if the path is set properl... | -0.050976 | false | 4 | 4,525 |
2016-10-04 11:51:11.397 | Using pip on Windows installed with both python 2.7 and 3.5 | I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version? | 1-open command prompt and change direction using the command cd C:\Python35\Scripts
2- write the command pip3 install --upgrade pip
3- close the command prompt and reopen it again to return to the default direction and use the command pip3.exe install package_name to install any package you want | -0.050976 | false | 4 | 4,525 |
2016-10-04 20:22:27.530 | How to DISABLE Jupyter notebook matplotlib plot inline? | Well, I know I can use %matplotlib inline to plot inline.
However, how to disable it?
Sometime I just want to zoom in the figure that I plotted. Which I can't do on a inline-figure. | %matplotlib auto should switch to the default backend. | 0.545705 | false | 2 | 4,526 |
2016-10-04 20:22:27.530 | How to DISABLE Jupyter notebook matplotlib plot inline? | Well, I know I can use %matplotlib inline to plot inline.
However, how to disable it?
Sometime I just want to zoom in the figure that I plotted. Which I can't do on a inline-figure. | Use %matplotlib notebook to change to a zoom-able display. | 1.2 | true | 2 | 4,526 |
2016-10-05 18:06:56.533 | In-house made package and environmental variables link | I created a python package for in-house use which relies upon some environmental variables (namely, the user and password to enter an online database). for my company, the convenience of installing a package rather than having it in every project is significant as the functions inside are used in completely separate p... | I think I'll just detail in the readme file what to insert and where. I tried to find a difficult solution when it was really simple and straightforward | 0 | false | 1 | 4,527 |
2016-10-05 19:49:37.127 | django-tables2 flooding database with queries | im using django-tables2 in order to show values from a database query. And everythings works fine. Im now using Django-dabug-toolbar and was looking through my pages with it. More out of curiosity than performance needs. When a lokked at the page with the table i saw that the debug toolbar registerd over 300 queries fo... | Im posting this as a future reference for myself and other who might have the same problem.
After searching for a bit I found out that django-tables2 was sending a single query for each row. The query was something like SELECT * FROM "table" LIMIT 1 OFFSET 1 with increasing offset.
I reduced the number of sql calls ... | 1.2 | true | 1 | 4,528 |
2016-10-06 08:54:28.433 | wxpython treectrl show bitmap picture on hover | So i'm programming python program that uses wxPython for UI, with wx.TreeCtrl widget for selecting pictures(.png) on selected directory. I would like to add hover on treectrl item that works like tooltip, but instead of text it shows bitmap picture.
Is there something that already allows this, or would i have to create... | Take a look at the wx.lib.agw.supertooltip module. It should help you to create a tooltip-like window that displays custom rich content.
As for triggering the display of the tooltip, you can catch mouse events for the tree widget (be sure to call Skip so the tree widget can see the events too) and reset a timer each ti... | 1.2 | true | 1 | 4,529 |
2016-10-06 21:51:44.013 | Inputs on how to achieve REST based interaction between Java and Python? | I have a Java process which interacts with its REST API called from my program's UI. When I receive the API call, I end up calling the (non-REST based) Python script(s) which do a bunch of work and return me back the results which are returned back as API response.
- I wanted to convert this interaction of UI API -> JA... | Furthermore, in the future you might want to separate them from the same machine and use network to communicate.
You can use http requests.
Make a contract in java of which output you will provide to your python script (or any other language you will use) send the output as a json to your python script, so in that way ... | 0 | false | 1 | 4,530 |
2016-10-06 22:31:47.993 | how do I insert data to an arbitrary location in a binary file without overwriting existing file data? | I've tried to do this using the 'r+b', 'w+b', and 'a+b' modes for open(). I'm using with seek() and write() to move to and write to an arbitrary location in the file, but all I can get it to do is either 1) write new info at the end of the file or 2) overwrite existing data in the file.
Does anyone know of some other... | What you're doing wrong is assuming that it can be done. :-)
You don't get to insert and shove the existing data over; it's already in that position on disk, and overwrite is all you get.
What you need to do is to mark the insert position, read the remainder of the file, write your insertion, and then write that remai... | 0.386912 | false | 1 | 4,531 |
2016-10-09 05:21:57.423 | Failed to write all bytes for MSVCR100.dll | I made a python console exe. It cannot work on windows2008 R2 server.
I copy MSVCR100.dll and MSVCP100.dll from another computer onto the dir containing the exe file. It has been working correctly a long time.
Today, when start it show that "Failed to write all bytes for MSVCR100.dll"
I don't know what caused it and ho... | The "Failed to write all bytes for (random DLL name)" error generally indicates that the disk is full. Would be nice if Microsoft had bothered to add an extra sentence indicating such, but this is usually the problem.
If your disk isn't full, then it may be a permissions issue -- make sure the user you're running the p... | 0 | false | 1 | 4,532 |
2016-10-10 00:18:44.023 | Visual Studio Python "Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT | I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple "Hello World" script and I'm receiving this error:
Failed to launch the Python Process, please validate the path 'python'
followed by this in the debug console:
Error: spawn python ENOENT
Could someone please help me ... | For those who are having this error after the recent (May-June of 2017) update of Visual Studio Code.
Your old launch.json file might be causing this issue, due to the recent updates of launch.json file format and structure.
Try to delete launch.json file in the .vscode folder. The .vscode folder exists in your workspa... | 0.135221 | false | 5 | 4,533 |
2016-10-10 00:18:44.023 | Visual Studio Python "Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT | I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple "Hello World" script and I'm receiving this error:
Failed to launch the Python Process, please validate the path 'python'
followed by this in the debug console:
Error: spawn python ENOENT
Could someone please help me ... | Simply restart your VB studio code. Those show that some packages have been downloaded but not yet installed until reboot it. | 0.067922 | false | 5 | 4,533 |
2016-10-10 00:18:44.023 | Visual Studio Python "Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT | I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple "Hello World" script and I'm receiving this error:
Failed to launch the Python Process, please validate the path 'python'
followed by this in the debug console:
Error: spawn python ENOENT
Could someone please help me ... | Figured it out, if you just started python then you probably did not add python to your path.
To do so uninstall python and then reinstall it. This time click "add python to path" at the bottom of the install screen. | 0 | false | 5 | 4,533 |
2016-10-10 00:18:44.023 | Visual Studio Python "Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT | I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple "Hello World" script and I'm receiving this error:
Failed to launch the Python Process, please validate the path 'python'
followed by this in the debug console:
Error: spawn python ENOENT
Could someone please help me ... | Do not uninstall!
1) Go to location that you installed the program.
*example: C:\Program Files (x86)\Microsoft VS Code
copy the location.
2) right click on computer> properties >Advanced System Settings> Environment variables > under user variables find "path" click> edit> under variable value: go to the end of the li... | 0.443188 | false | 5 | 4,533 |
2016-10-10 00:18:44.023 | Visual Studio Python "Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT | I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple "Hello World" script and I'm receiving this error:
Failed to launch the Python Process, please validate the path 'python'
followed by this in the debug console:
Error: spawn python ENOENT
Could someone please help me ... | Add python path by following these steps.
1. Go to uninstall a program.
2. Go to Python 3.6.1 (this is my python version). Select and click on Uninstall/change.
3.Click on Modify.
4. Click next > In advanced options > tick add Python to environment variable. Click install. Restart VS code. | 0.067922 | false | 5 | 4,533 |
2016-10-10 12:46:26.873 | One of threads rewrites console input in Python | I have a problem with console app with threading. In first thread i have a function, which write symbol "x" into output. In second thread i have function, which waiting for users input. (Symbol "x" is just random choice for this question).
For ex.
Thread 1:
while True:
print "x"
time.sleep(1)
Th... | In a console, standard output (produced by the running program(s)) and standard input (produced by your keypresses) are both sent to screen, so they may end up all mixed.
Here your thread 1 writes 1 x by line every second, so if your take more than 1 second to type HELLO then that will produce the in-console output tha... | 1.2 | true | 1 | 4,534 |
2016-10-11 01:29:20.587 | Recommender engine in python - incorporate custom similarity metrics | I am currently building a recommender engine in python and I faced the following problem.
I want to incorporate collaborative filtering approach, its user-user variant. To recap, its idea is that we have an information on different users and which items they liked (if applicable - which ratings these users assigned to ... | I would keep it simple and separate:
Your focus is collaborative filtering, so your recommender should generate scores for the top N recommendations regardless of location.
Then you can re-score using distance among those top-N. For a simple MVP, you could start with an inverse distance decay (e.g. final-score = cf-sc... | 1.2 | true | 1 | 4,535 |
2016-10-11 04:29:47.253 | Python: Plot a sparse matrix | I have a sparse matrix X, shape (6000, 300). I'd like something like a scatterplot which has a dot where the X(i, j) != 0, and blank space otherwise. I don't know how many nonzero entries there are in each row of X. X[0] has 15 nonzero entries, X[1] has 3, etc. The maximum number of nonzero entries in a row is 16.
Atte... | plt.matshow also turned out to be a feasible solution. I could also plot a heatmap with colorbars and all that. | 0 | false | 2 | 4,536 |
2016-10-11 04:29:47.253 | Python: Plot a sparse matrix | I have a sparse matrix X, shape (6000, 300). I'd like something like a scatterplot which has a dot where the X(i, j) != 0, and blank space otherwise. I don't know how many nonzero entries there are in each row of X. X[0] has 15 nonzero entries, X[1] has 3, etc. The maximum number of nonzero entries in a row is 16.
Atte... | It seems to me heatmap is the best candidate for this type of plot. imshow() will return u a colored matrix with color scale legend.
I don't get ur stretched ellipses problem, shouldnt it be a colored squred for each data point?
u can try log color scale if it is sparse. also plot the 12 classes separately to analyze... | 0 | false | 2 | 4,536 |
2016-10-11 07:25:02.260 | How to update pandas when python is installed as part of ArcGIS10.4, or another solution | I recently installed ArcGIS10.4 and now when I run python 2.7 programs using Idle (for purposes unrelated to ArcGIS) it uses the version of python attached to ArcGIS.
One of the programs I wrote needs an updated version of the pandas module. When I try to update the pandas module in this verion of python (by opening co... | I reinstalled python again directly from python.org and then installed pandas which seems to work.
I guess this might stop the ArcMap version of python working properly but since I'm not using python with ArcMap at the moment it's not a big problem. | 0 | false | 1 | 4,537 |
2016-10-12 02:41:49.150 | How can I get the google search snippets using Python? | I am now trying the python module google which only return the url from the search result. And I want to have the snippets as information as well, how could I do that?(Since the google web search API is deprecated) | I think you're going to have to extract your own snippets by opening and reading the url in the search result. | 0 | false | 1 | 4,538 |
2016-10-12 14:55:54.937 | Import Project from Spyder2 to Spyder3 | The past few months, I've been working on a project using Spyder2 IDE with Python 2.7. However, now I'm being instructed to look into ways of translating the program from Python 2.7 to Python 3.5, which means I'm using Anaconda3 now instead of Anaconda2, and that means I'm using Spyder3 as the default IDE instead of Sp... | There is an easy solution to this, at least for simple cases and as of May 2017 (Spyder 3.1.2): Create a new empty project in Spyder 3. The new project directory will then have a subdirectory named ".spyproject" with these files in it: codestyle.ini, encoding.ini, vcs.ini, workspace.ini. Copy the entire .spyproject s... | 0.386912 | false | 1 | 4,539 |
2016-10-13 06:34:34.130 | How to implement a message system? | I am running a website where user can send in-site message (no instantaneity required) to other user, and the receiver will get a notification about the message.
Now I am using a simple system to implement that, detail below.
Table Message:
id
content
receiver
sender
Table User:
some info
notification
some info
Whe... | I think you will need to read about pub/sub for messaging services. For php, you can use libraries such as redis.
So for e.g, user1 subscribe to topic1, any user which publish to topic1, user1 will be notified, and you can implement what will happen to the user1. | 0 | false | 1 | 4,540 |
2016-10-13 12:17:34.737 | Add a library in Spark in Bluemix & connect MongoDB , Spark together | 1) I have Spark on Bluemix platform, how do I add a library there ?
I can see the preloaded libraries but cant add a library that I want.
Any command line argument that will install a library?
pip install --package is not working there
2) I have Spark and Mongo DB running, but I am not able to connect both of them.
... | In a Python notebook:
!pip install <package>
and then
import <package> | 1.2 | true | 1 | 4,541 |
2016-10-14 00:21:55.157 | Run a python application/script on startup using Linux | I've been learning Python for a project required for work. We are starting up a new server that will be running linux, and need a python script to run that will monitor a folder and handle files when they are placed in the folder.
I have the python "app" working, but I'm having a hard time finding how to make this scr... | You can set up the script to run via cron, configuring time as @reboot
With python scripts, you will not need to compile it. You might need to install it, depending on what assumptions your script makes about its environment. | 1.2 | true | 1 | 4,542 |
2016-10-14 15:18:52.487 | Updating Python version that's compiled from source | I run a script on several CentOS machines that compiles Python 2.7.6 from source and installs it. I would now like to update the script so that it updates Python to 2.7.12, and don't really know how to tackle this.
Should I do this exactly the same way, just with source code of higher version, and it will overwrite the... | Replacing 2.7.6 with 2.7.12 would be fine using the procedure you linked.
There should be no real problems with libraries installed with pip easy_install as the version updates are minor.
Worst comes to worst and there is a library conflict it would be because the python library used for compiling may be different and... | 0.386912 | false | 1 | 4,543 |
2016-10-16 15:27:56.803 | How to use the NumPy installed by Pacman in virtualenv? | My system is Archlinux.
My project will use NumPy, and my project is in a virtual environment created by virtualenv.
As it is difficult to install NumPy by pip, I install it by Pacman:
sudo pacman -S python-scikit-learn
But how can I use it in virtualenv? | You can create the virtualenv with the --system-site-packages switch to use system-wide packages in addition to the ones installed in the stdlib. | 1.2 | true | 1 | 4,544 |
2016-10-18 03:26:29.703 | how to install previous version of xarray | I am reading other's pickle file that may have data type based on xarray. Now I cannot read in the pickle file with the error "No module named core.dataset".
I guess this maybe a xarray issue. My collaborator asked me to change my version to his version and try again.
My version is 0.8.2, and his version 0.8.0. So how ... | Use "conda install xarray==0.8.0" if you're using anaconda, or "pip install xarray==0.8.0" otherwise. | 0.386912 | false | 1 | 4,545 |
2016-10-18 13:02:57.647 | Display Sum of overdue payments in Customer Form view for each customer | In accounting -> Customer Invoices, there is a filter called Overdue. Now I want to calculate the overdue payments per user and then display it onto the customer form view.
I just want to know how can we apply the condition of filter in python code. I have already defined a smart button to display it with a (total invo... | Your smart button on partners should use a new action, like the button for customer or vendor bills. This button definition should include context="{'default_partner_id': active_id} which will allow to change the partner filter later on, or the upcoming action definition should include the partner in its domain.
The ac... | 1.2 | true | 1 | 4,546 |
2016-10-19 00:48:48.457 | Multiple instances of celerybeat for autoscaled django app on elasticbeanstalk | I am trying to figure out the best way to structure a Django app that uses Celery to handle async and scheduled tasks in an autoscaling AWS ElasticBeanstalk environment.
So far I have used only a single instance Elastic Beanstalk environment with Celery + Celerybeat and this worked perfectly fine. However, I want to ha... | I guess you could single out celery beat to different group.
Your auto scaling group runs multiple django instances, but celery is not included in the ec2 config of the scaling group.
You should have different set (or just one) of instance for celery beat | 0.201295 | false | 2 | 4,547 |
2016-10-19 00:48:48.457 | Multiple instances of celerybeat for autoscaled django app on elasticbeanstalk | I am trying to figure out the best way to structure a Django app that uses Celery to handle async and scheduled tasks in an autoscaling AWS ElasticBeanstalk environment.
So far I have used only a single instance Elastic Beanstalk environment with Celery + Celerybeat and this worked perfectly fine. However, I want to ha... | In case someone experience similar issues: I ended up switching to a different Queue / Task framework for django. It is called django-q and was set up and working in less than an hour. It has all the features that I needed and also better Django integration than Celery (since djcelery is no longer active).
Django-q is ... | 1.2 | true | 2 | 4,547 |
2016-10-19 08:47:26.880 | Split and shift RGB channels in Python | What I'm trying to do is recreating what is commonly called an "RGB shift" effect, which is very easy to achieve with image manipulation programs.
I imagine I can "split" the channels of the image by either opening the image as a matrix of triples or opening the image three times and every time operate just on one cha... | Per color plane, replace the pixel at (X, Y) by the pixel at (X-1, Y+3), for example. (Of course your shifts will be different.)
You can do that in-place, taking care to loop by increasing or decreasing coordinate to avoid overwriting.
There is no need to worry about transparency. | 1.2 | true | 1 | 4,548 |
2016-10-19 20:51:40.127 | Stream data from AWS IoT to AWS Lambda using Python? | I am Publishing data from Raspberry Pi to AWS IoT and I can see the updates there.
Now, I need to get that data into AWS Lambda and connect it to AWS SNS to send a message above a threshold. I know about working with SNS and IoT.
I just want to know that how I can get the data from AWS IoT to AWS Lambda ??
Please Hel... | In IoT Code, Create a rule for invoking a Lambda to accept JSON data. Then you can do anything with that data. | 1.2 | true | 1 | 4,549 |
2016-10-19 23:10:00.280 | Add text to scatter point using python gmplot | I plotted some points on google maps using gmplot's scatter method (python). I want to add some text to the points so when someone clicks on those points they can see the text.
I am unable to find any documentation or example that shows how to do this.
Any pointers are appreciated. | Just looking for the answer to this myself. gmplot was updated to June 2016 to include a hovertext functionality for the marker method, but unfortunately this isn't available for the scatter method. The enthusiastic user will find that the scatter method simply calls the marker method over and over, and could modify t... | 0.999909 | false | 1 | 4,550 |
2016-10-20 07:39:41.337 | jupyter notebook select python | I have anaconda2 and anaconda3 installed on windows machine, have no access to internet and administrator rights. How can I switch between python 2 and 3 when starting jupyter? Basic "jupyter notebook" command starts python 2. With internet I would just add environment for python 3 and select it in jupyter notebook aft... | There's important points to consider:
you have to have jupyter notebook installed in each environment you want to run it from
if jupyter is only installed in one environment, your notebook will default to that environment no matter from which environment your start it, and you will have no option to change the noteboo... | 0.201295 | false | 2 | 4,551 |
2016-10-20 07:39:41.337 | jupyter notebook select python | I have anaconda2 and anaconda3 installed on windows machine, have no access to internet and administrator rights. How can I switch between python 2 and 3 when starting jupyter? Basic "jupyter notebook" command starts python 2. With internet I would just add environment for python 3 and select it in jupyter notebook aft... | Did you install python by Anaconda?
Try to install under Anaconda2/envs when choosing destination folder,
like this:
D:/Anaconda2/envs/py3
then"activate py3" by cmd, py3 must be then same name of installation folder | 0 | false | 2 | 4,551 |
2016-10-22 14:38:16.543 | How to check if a CSV has a header using Python? | I have a CSV file and I want to check if the first row has only strings in it (ie a header). I'm trying to avoid using any extras like pandas etc. I'm thinking I'll use an if statement like if row[0] is a string print this is a CSV but I don't really know how to do that :-S any suggestions? | I think the best way to check this is -> simply reading 1st line from file and then match your string instead of any library. | 0 | false | 1 | 4,552 |
2016-10-22 15:47:29.577 | Can't launch Spyder on windows 7 | After installing Winpython on windows 7 64 bits, when I launch Spyder I face this:
ImportError: No module named encodings
Python 2.7.12 Shell works well but Spyder don't.
Do you know how to solve this problem?
I really appreciate any help you can provide | You Could try to uninstall that version of spyder and download Anaconda, a free package manager that comes pre-installed with spyder and should work fine, as it did for me as I have windows 7 x64 | 0 | false | 1 | 4,553 |
2016-10-22 17:45:46.320 | Calling Raspberry Pi from ASP.NET to send a SMS remotely | Just discovered the amazing Raspberry Pi 3 and I am trying to learn how to use it in one of my projects.
Setup:
ASP.NET app on Azure.
RPi:
software: Raspbian, PHP, Apache 2, and MariaDB.
has internet access and a web server a configured.
3G dongle for SMS sending, connected to the RPi.
Desired scenario:
when a s... | What are the (logical) pitfalls of this scenario?
My opion would be to pass the data and the two fields (phoneNumber and SmsType) through a POST request rather then an GET request because you can send more data in an post request and encapsulate it with JSON making it easier to handle the data.
What would be a simpler ... | 1.2 | true | 1 | 4,554 |
2016-10-23 08:04:23.853 | how do i stop the invalid code message repeating while also occuring at the right time | I am writing a program to search a txt file for a certain line based only on part of the string. If the string isn't found, it should print not found once, but it is printing it multiple times. Even after indenting and using a correct code it still prints: | the else suite is executed after the for terminates normally (not by a break).
so it will definitely execute the else statement in your code, because you don't break in the for loop. | 0.135221 | false | 1 | 4,555 |
2016-10-24 09:19:13.347 | undefined symbol: Tk_Init | python2.7
when I import Tkinter, it prompt no module named _tkinter, I don't have the limits of administrator, so I install tcl and tk, then recompile python with --with-tcltk-includes and --with-tcltk-libs parameter, but when running 'make', the error """*** WARNING: renaming "_tkinter" since importing it failed: buil... | I had the same exact issue with Python-3.4.3. I followed Brice's solution and got halfway there. Not only did I require the -l flags after the -L flag as he suggested, but I discovered my LD_LIBRARY_PATH was inadequate when performing the 'make altinstall'. Be sure to include the same directory in LD_LIBRARY_PATH as us... | 0 | false | 1 | 4,556 |
2016-10-24 17:07:25.720 | Why can't I install cPickle | Pip needs upgrading? | When trying to install cPickle using pycharm I get this:
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Edwin\AppData\Local\Temp\pycharm-packaging\cpickle
You are using pip version 7.1.2, however version 8.1.2 is available.
You should consider upgrading via the 'python -m pip install --up... | As suggested in the comments, this is most likely because Python is not added to your environment variables. If you do not want to touch your environment variables, and assuming your Python is installed in C:\Python35\,
Navigate tp C:\Python35\ in Windows Explorer
Go to the address bar and type cmd to shoot up a comm... | 1.2 | true | 1 | 4,557 |
2016-10-25 09:29:25.600 | How to include PHP library in Python package (on not do it) | I've created tool, that runs as a server, and allow clients to connect to it through TCP, and run some commands. It's written on python 3
Now I'm going to build package and upload it to Pypi, and have conceptual problem.
This tool have python client library inside, so, after installation of the package, it'll be possib... | I've decided to create separate PHP package for my PHP library, and upload it to a packagist.org, so, user could get it using php composer, but not forced to, as it would be in case of including library.php into python package. | 1.2 | true | 1 | 4,558 |
2016-10-25 23:19:45.753 | How to get the contents of last line in tkinter text widget (Python 3) | I am working on a virtual console, which would use the systems builtin commands and then do the action and display output results on next line in console. This is all working, but how do I get the contents of the last line, and only the last line in the tkinter text widget? Thanks in advance. I am working in python 3.
... | Test widget has a see(index) method.
text.see(END) will scroll the text to the last line. | 0 | false | 2 | 4,559 |
2016-10-25 23:19:45.753 | How to get the contents of last line in tkinter text widget (Python 3) | I am working on a virtual console, which would use the systems builtin commands and then do the action and display output results on next line in console. This is all working, but how do I get the contents of the last line, and only the last line in the tkinter text widget? Thanks in advance. I am working in python 3.
... | You can apply modifiers to the text widget indicies, such as linestart and lineend as well as adding and subtracting characters. The index after the last character is "end".
Putting that all together, you can get the start of the last line with "end-1c linestart". | 1.2 | true | 2 | 4,559 |
2016-10-26 15:24:01.800 | Proxy Error 408 when running a script written in Scrapy Python | I am using a proxy (from proxymesh) to run a spider written in scrapy python, the script is running normally when I don't use the proxy, but when I use it, I am having the following error message:
Could not open CONNECT tunnel with proxy fr.proxymesh.com:31280 [{'status': 408, 'reason': 'request timeout'}]
Any clue abo... | Thanks.. I figure out here.. the problem is that some proxy location doesn't work with https.. so I just changed it and now it is working. | 1.2 | true | 1 | 4,560 |
2016-10-26 18:46:12.593 | opencv window in tkinter frame | I am making a hand controlled media player application in Python and through OpenCV.I want to embed gesture window of OpenCV in Tkinter frame so I can add further attributes to it.
Can someone tell how to embed OpenCV camera window into Tkinter frame? | OpenCV window in Tkinter window is not good idea. Both windows use own mainloop (event loop) which can't work at the same time (or you have to use threading) and don't have contact one with other.
Probably it is easier to get video frame and display in Tkinter window on Label or Canvas. You can use tk.after(milisecond... | 1.2 | true | 1 | 4,561 |
2016-10-27 06:01:37.120 | Flask return nothing, instead of having the re-render template | I have written a python function using flask framework to process some data submitted via a web form. However I don't want to re-render the template, I really just want to process the data and the leave the web form, it the state it was in, when the POST request was created. Not sure how to do this ... any suggestion... | If you want the user to stay in place, you should send the form using JavaScript asynchronously. That way, the browser won't try to fetch and render a new page.
You won't be able to get this behavior from the Flask end only. You can return effectively nothing but the browser will still try to get it and render that not... | 0 | false | 1 | 4,562 |
2016-10-27 12:12:23.010 | python: split matrix in hermitian and anti-hermitian part | Imagine I have a numpy array in python that has complex numbers as its elements.
I would like to know if it is possible to split any matrix of this kind into a hermitian and anti-hermitian part? My intuition says that this is possible, similar to the fact that any function can be split into an even and an uneven part.
... | The Hermitian part is (A + A.T.conj())/2, the anti-hermitian part is (A - A.T.conj())/2 (it is quite easy to prove).
If A = B + C with B Hermitian and C anti-Hermitian, you can take the conjugate (I'll denote it *) on both sides, uses its linearity and obtain A* = B - C, from which the values of B and C follow easily. | 1.2 | true | 1 | 4,563 |
2016-10-27 14:20:54.503 | Fastest way to calculate many regressions in python? | I think I have a pretty reasonable idea on how to do go about accomplishing this, but I'm not 100% sure on all of the steps. This question is mostly intended as a sanity check to ensure that I'm doing this in the most efficient way, and that my math is actually sound (since my statistics knowledge is not completely per... | some brief answers
1) Calling statsmodels repeatedly is not the fastest way. If we just need parameters, prediction and residual and we have identical explanatory variables, then I usually just use params = pinv(x).dot(y) where y is 2 dimensional and calculate the rest from there. The problem is that inference, confide... | 0.999329 | false | 1 | 4,564 |
2016-10-28 01:49:44.437 | How to extract words used for Doc2Vec | I am preparing a Doc2Vec model using tweets. Each tweet's word array is considered as a separate document and is labeled as "SENT_1", SENT_2" etc.
taggeddocs = []
for index,i in enumerate(cleaned_tweets):
if len(i) > 2: # Non empty tweets
sentence = TaggedDocument(words=gensim.utils.to_unicode(i).split(), ... | Gensim's Word2Vec/Doc2Vec models don't store the corpus data – they only examine it, in multiple passes, to train up the model. If you need to retrieve the original texts, you should populate your own lookup-by-key data structure, such as a Python dict (if all your examples fit in memory).
Separately, in recent versio... | 0.386912 | false | 1 | 4,565 |
2016-10-28 16:55:44.460 | cannot sum rows that match a regular expression in pandas / python | I can find the number of rows in a column in a pandas dataframe that do NOT follow a pattern but not the number of rows that follow the very same pattern!
This works:
df.report_date.apply(lambda x: (not re.match(r'[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}', x))).sum()
This does not: removing 'not' does not tell me how many rows m... | The problem is that the match function does not return True when it matches, it returns a match object. Pandas cannot add this match object because it is not an integer value. The reason you get a sum when you are using 'not' is because it returns a boolean value of True, which pandas can sum the True value and return ... | 0.386912 | false | 1 | 4,566 |
2016-10-29 16:16:56.217 | How do I format the contents of the following variable in Python? | So, I have been playing around with requests and bs4 for a project I'm working on and have managed to return the following in a variable:
"----------
Crossways Inn
Withy Road
West Huntspill
Somerset
TA93RA
01278783756
www.crosswaysinn.com
----------"
This was scraped from a site, using .text function within the bs4 mo... | Just use repr()
Like:
print(repr(<variable with string>)) | 0.386912 | false | 1 | 4,567 |
2016-10-29 17:23:20.700 | Python NamedTuple to C++ Struct | I have searched the internet for hours at this point. Does anyone know how to parse a namedtuple returned from a python function into a struct or just into separate variables. The part I am having trouble with is getting the data out of the returned pointer. I am calling a python function embedded in C++ using the PyOb... | namedtuple is implemented purely in Python. You can see its full source in collections.py. It's very short. The thing to keep in mind is that namedtuple itself is a function which creates a class in the frame in which it is called and then returns this class (not an instance of this class). And it is this returned ... | 0.201295 | false | 1 | 4,568 |
2016-10-29 20:54:23.140 | How to read Python function documentation | I have a problem understanding some description of functions in Python.
I understand simply functions like os.putenv(varname, value) but I have no idea how to use this: os.getenv(varname[, value]). How to pass arguments to that function, what does those square brackets mean? | Square brackets typically mean that the value is optional. Here, varname refers to the environment variable you want to get and value is an optional value that is return if the environment variable doesn't exist. | 0 | false | 1 | 4,569 |
2016-10-30 12:52:19.937 | Multiscale CNN - Keras Implementation | I want to implement a multiscale CNN in python. My aim is to use three different CNNs for three different scales and concatenate the final outputs of the final layers and feed them to a FC layer to take the output predictions.
But I don't understand how can I implement this. I know how to implement a single scale CNN. ... | I do not understand why to have 3 CNNs because you would mostly have the same results than on a single CNN. Maybe you could train faster.
Perhaps you could also do pooling and some resnet operation (I guess this could prove similar to what you want).
Nevertheless, for each CNN you need a cost function in order to optim... | 0 | false | 1 | 4,570 |
2016-10-31 10:09:46.513 | Python: how to mock a kafka topic for unit tests? | We have a message scheduler that generates a hash-key from the message attributes before placing it on a Kafka topic queue with the key.
This is done for de-duplication purposes. However, I am not sure how I could possibly test this deduplication without actually setting up a local cluster and checking that it is perfo... | If you need to verify a Kafka specific feature, or implementation with a Kafka-specific feature, then the only way to do it is by using Kafka!
Does Kafka have any tests around its deduplication logic? If so, the combination of the following may be enough to mitigate your organization's perceived risks of failure:
uni... | 1.2 | true | 1 | 4,571 |
2016-10-31 11:41:21.353 | Double an image using python | i have to double an image using python,
So i think i can replace each pixel of the image with a square formed by 4 pixels
how do i can do that and assign to each pixel of the little square different colors? | Is that a homework ? Working with a new target image, as suggested in the comments, is the easiest.
But theoretically, assuming your original image is represented as some 2 dimension table of pixels, you could do it without creating a new image:
First double both dimensions of the original image (with the original imag... | 1.2 | true | 1 | 4,572 |
2016-11-01 23:07:53.343 | Generate new tensorflow tensor according to the element index of original tensor | I have a question about tensorflow tensor.
If I have a NeuralNet like y=xw+b as an example.
then x is placeholder([7,7] dims), w is Variable([7,1]) and b is Variable([1,1])
So, y is tensorflow tensor with [7,1] dims.
then, in this case. can I make a new tensor like
new_y = [tf.reduce_sum(y[0:3]), tf.reduce_sum(y[3:5]),... | You should just make your label (y) in your reduced sum format (i.e. 3 bits), and train to that label. The neural net should be smart enough to adjust the weights to imitate your reduce_sum logic. | 0 | false | 1 | 4,573 |
2016-11-02 16:14:08.387 | pip3 stopped installing executables into /usr/local/bin | Suddenly, my pip install commands stopped installing binaries into /usr/local/bin. I tried to upgrade pip to see if that might be the problem, it was up to date and a forced re-install deleted my /usr/local/pip3 and didn't install it back, so now I have to use python3 -m pip to do any pip operations. I am running OS X ... | Resolved the problem. Turns out that this is Homebrew's behavior. I must have recently ran brew upgrade and it installed a newer version of python3. It seems that something got weird with re-linking the new python3, so all binaries for the new installs ended up somewhere deep in /usr/local/Cellar/python3.
I expect that... | 1.2 | true | 1 | 4,574 |
2016-11-02 20:39:42.047 | Clustering before regression - recommender system | I have a file called train.dat which has three fields - userID, movieID and rating.
I need to predict the rating in the test.dat file based on this.
I want to know how I can use scikit-learn's KMeans to group similar users given that I have only feature - rating.
Does this even make sense to do? After the clustering ... | Clustering users makes sense. But if your only feature is the rating, I don't think it could produce a useful model for prediction. Below are my assumptions to make this justification:
The quality of movie should be distributed with a gaussion distribution.
If we look at the rating distribution of a common user, it sh... | -0.201295 | false | 1 | 4,575 |
2016-11-04 15:03:00.030 | Transfer Data from Click Event Between Bokeh Apps | I have two Bokeh apps (on Ubuntu \ Supervisor \ Nginx), one that's a dashboard containing a Google map and another that's an account search tool. I'd like to be able to click a point in the Google map (representing a customer) and have the account search tool open with info from the the point.
My problem is that I don... | The cookies idea might work fine. There are a few other possibilities for sharing data:
a database (e.g. redis or something else, that can trigger async events that the app can respond to)
direct communication between the apps (e.g. with zeromq or similiar) The Dask dashboard uses this kind of communication between r... | 1.2 | true | 1 | 4,576 |
2016-11-04 20:07:30.817 | run graphlab from Spyder | I can run my python file with imported functionalities from GraphLab from the Terminal (first use the source activate gl-env and then run the file). So the file and installations are alright in that sense.
However, I can't figure out how to run the file directly in Spyder IDE. I only get ImportError: No module named '... | Following method will solve this:
Open Spyder --> tools --> preferences --> python interpreter --> change from default to custom and select the python executable under gl-env environment.
Restart spyder. It will work. | 1.2 | true | 1 | 4,577 |
2016-11-04 20:16:34.970 | Python hashlib and sparse files | I wanted to know how does python hashlib library treat sparse files. If the file has a lot of zero blocks then instead of wasting CPU and memory on reading zero blocks does it do any optimization like scanning the inode block map and reading only allocated blocks to compute the hash?
If it does not do it already, what ... | The hashlib module doesn't even work with files. You have to read the data in and pass blocks to the hashing object, so I have no idea why you think it would handle sparse files at all.
The I/O layer doesn't do anything special for sparse files, but that's the OS's job; if it knows the file is sparse, the "read" operat... | 0.386912 | false | 1 | 4,578 |
2016-11-05 13:10:28.650 | Using a server in android to run code | I have a second laptop running kali linux which is not used at all, meaning it can be running anytime as a server for my application. So what I actually want to do is connect from my application to my server and send some data, on the server run a python program that uses this code and return some data back. I never tr... | Your problem is not Android-related definitely.
You simply need to educated yourself about networking. Yes, it will cost you some money - you spend them buying few books and some hardware for building home network.
After about 3-6-12 months of playing with your home network you will find your question rather simple to ... | 0 | false | 1 | 4,579 |
2016-11-05 20:07:35.737 | C/C++ module vs python module. | In Python ( CPython) we can import module:
import module and module can be just *.py file ( with a python code) or module can be a module written in C/C++ ( be extending python). So, a such module is just compiled object file ( like *.so/*.o on the Unix).
I would like to know how is it executed by the interpreter exac... | When you import a C extension, python uses the platform's shared library loader to load the library and then, as you say, jumps to a function in the library. But you can't load just any library or jump to any function this way. It only works for libs specifically implemented to support python and to functions that are ... | 1.2 | true | 1 | 4,580 |
2016-11-06 17:50:55.907 | How to structure a very small Django Project? | It is a little oxymoron now that I am making a small Django project that it is hard to decide how to structure such project. Before I will at least will have 10 to 100 apps per project. Now my project is just a website that presents information about a company with no use database, meaning it's really static, with on... | Frankly I won't use Django in that case, I would use Flask for such small projects. it's easy to learn and setup a small website.
PS: I use Flask in small and large apps! | 0.135221 | false | 2 | 4,581 |
2016-11-06 17:50:55.907 | How to structure a very small Django Project? | It is a little oxymoron now that I am making a small Django project that it is hard to decide how to structure such project. Before I will at least will have 10 to 100 apps per project. Now my project is just a website that presents information about a company with no use database, meaning it's really static, with on... | meaning it's really static
Use nginx to serve static files. Do not use django. You will setup project structure when it will be required. | 0.386912 | false | 2 | 4,581 |
2016-11-06 21:47:15.293 | Simple algorithm to move from one tile to another using only a chess knight's moves | I have a problem shown below that wants to find the quickest way to get between any two points by using only the moves of a knight in chess. My first thought was to us the A* algorithm or Dijkstra's algorithm however, I don't know how to make sure only the moves of a knight are used. I would appreciate it if you could ... | While User_Targaryen's answer is the best because it directly answers your question, I would recommend an algebraic solution, if your goal is computing is the delivery of an answer in the shortest amount of time.
To shorten the algorithm, use reflections about the x, y, and xy axes, so as to consider only positive (x, ... | 0.101688 | false | 3 | 4,582 |
2016-11-06 21:47:15.293 | Simple algorithm to move from one tile to another using only a chess knight's moves | I have a problem shown below that wants to find the quickest way to get between any two points by using only the moves of a knight in chess. My first thought was to us the A* algorithm or Dijkstra's algorithm however, I don't know how to make sure only the moves of a knight are used. I would appreciate it if you could ... | Approach the problem in the following way:
Step 1: Construct a graph where each square of the chess board is a vertex.
Step 2: Place an edge between vertices exactly when there is a single knight-move from one square to another.
Step 3: Apply Dijkstra's algorithm. Dijkstra's algorithm is an algorithm to find the length... | 1.2 | true | 3 | 4,582 |
2016-11-06 21:47:15.293 | Simple algorithm to move from one tile to another using only a chess knight's moves | I have a problem shown below that wants to find the quickest way to get between any two points by using only the moves of a knight in chess. My first thought was to us the A* algorithm or Dijkstra's algorithm however, I don't know how to make sure only the moves of a knight are used. I would appreciate it if you could ... | For this problem, simply doing a breadth-first search is enough (Dijkstra and BFS work in same way for unweighted graphs). To ensure that only the chess knight's moves are used, you'll have to define the moves in a proper way.
Notice that a chess knight moves two squares to any direction, then one square perpendicular ... | 0.101688 | false | 3 | 4,582 |
2016-11-07 03:20:59.700 | information retrieval evaluation python precision, recall, f score, AP,MAP | i wrote one program to do the information retrieval and extraction. user enter the query in the search bar, the program can show the relevant txt result such as the relevant sentence and the article which consists the sentence.
I did some research for how to evaluate the result. I might need to calculate the precision,... | Evaluation has two essentials. First one is a test resource with the ranking of documents or their relevancy tag (relevant or not-relevant) for specific queries, which is made with an experiment (like user click, etc. and is mostly used when you have a running IR system), or made through crowd-sourcing. The second esse... | 0.201295 | false | 1 | 4,583 |
2016-11-07 17:33:25.797 | Django - beginner- what is the process for passing information to a view via a url? | I am working on my first django project which is also my first backend project. In the tutorials/reading I have completed, I haven't come across passing information back to django without a modelform.
My intention is to calculate a value on a page using javascript and pass it to django when a user hits a submit button ... | Yes, generally POST is a better way of submitting data than GET. There is a bit of a confusion about terminology in Django. While Django is, indeed MVC, models are models, but views are in fact controllers and views are templates. Since you are going to use AJAX to submit and retrieve the data, you don't care about tem... | 1.2 | true | 1 | 4,584 |
2016-11-08 08:31:41.803 | ways to avoid previous reload tornado | I have two forms, when I submit form#1 I get some corresponding file, but when I submit form#2 thenafter, the corresponding file gets shown but form#1 goes empty. So basically I want some thing like a SPA(e.g angular) but I am taking form#1 and form#2 as separate requests routes and each render my index.html every time... | This is not really a Tornado question, as this is simply how Web works.
One possible solution is to have only one form, but display its fields so that they look like two forms; in addition, have two separate submit buttons, each with its own name and value. Now, when you click on either button the whole form will be su... | 0 | false | 1 | 4,585 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.