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
2019-03-17 20:51:04.933
What is the preferred way to a add a citation suggestion to python packages?
How should developers indicate how users should cite the package, other than on the documentation? R packages return the preferred citation using citation("pkg"). I can think of pkg.CITATION, pkg.citation and pkg.__citation__. Are there others? If there is no preferred way (which seems to be the case to me as I did n...
Finally I opted for the dunder option. Only the dunder option (__citation__) makes clear, that this is not a normal variable needed for runtime. Yes, dunder strings should not be used inflationary because python might use them at a later time. But if python is going to use __citation__, then it will be for a similar ...
1.2
true
1
6,002
2019-03-18 14:05:53.610
How to see the full previous command in Pycharm Python console using a shortcut
I was wondering how I could see the history in the Pycharm Python console using a shortcut. I can see the history using the upper arrow key, but If I want to go further back in history I have to go to each individual line if more lines are ran at the time. Is it possible that each time I press a button the full previou...
Go to preferences -> Appereance & Behaviour -> Keymap. You can search for "Browse Console History" and add a keyboard shortcut with right click -> Add Keyboard shortcut.
0
false
1
6,003
2019-03-18 17:28:51.877
Python how to to make set of rules for each class in a game
in C# we have to get/set to make rules, but I don't know how to do this in Python. Example: Orcs can only equip Axes, other weapons are not eligible Humans can only equip swords, other weapons are eligible. How can I tell Python that an Orc cannot do something like in the example above? Thanks for answers in advance, h...
Python language doesn't have an effective mechanism for restricting access to an instance or method. There is a convention though, to prefix the name of a field/method with an underscore to simulate "protected" or "private" behavior. But, all members in a Python class are public by default.
0
false
1
6,004
2019-03-18 18:58:53.487
Regex to get key words, all digits and periods
My input text looks like this: Put in 3 extenders but by the 4th floor it is weak on signal these don't piggy back of each other. ST -99. 5G DL 624.26 UP 168.20 4g DL 2 Up .44 I am having difficulty writing a regex that will match any instances of 4G/5G/4g/5g and give me all the corresponding measurements after the...
I would separate it in different capture group like this: (?i)(?P<g1>5?4?G)\sDL\s(?P<g2>[^\s]*)\sUP\s(?P<g3>[^\s]*) (?i) makes the whole regex case insensitive (?P<g1>5?4?G) is the first group matching on either 4g, 5g, 4G or 5G. (?P<g2>[^\s]*) is the second and third group matching on everything that is not a space. T...
0.135221
false
1
6,005
2019-03-19 03:35:02.983
In Zapier, how do I get the inputs to my Python "Run Code" action to be passed in as lists and not joined strings?
In Zapier, I have a "Run Python" action triggered by a "Twitter" event. One of the fields passed to me by the Twitter event is called "Entities URLs Display URL". It's the list of anchor texts of all of the links in the tweet being processed. Zapier is passing this value into my Python code as a single comma-separated ...
David here, from the Zapier Platform team. At this time, all inputs to a code step are coerced into strings due to the way data is passed between zap steps. This is a great request though and I'll make a note of it internally.
0.673066
false
1
6,006
2019-03-19 07:09:31.563
Where is the tesseract executable file located on MacOS, and how to define it in Python?
I have made a code using pytesseract and whenever I run it, I get this error: TesseractNotFoundError: tesseract is not installed or it's not in your path I have installed tesseract using HomeBrew and also pip installed it.
If installed with Homebrew, it will be located in /usr/local/bin/tesseract by default. To verify this, run which tesseract in the terminal as Dmitrrii Z. mentioned. If it's there, you can set it up in your python environment by adding the following line to your python script, after importing the library: pytesseract.py...
0.673066
false
1
6,007
2019-03-19 09:10:22.167
Call function from file that has already imported the current file
If I have the files frame.py and bindings.py both with classes Frame and Bindings respectively inside of them, I import the bindings.py file into frame.py by using from bindings import Bindings but how do I go about importing the frame.py file into my bindings.py file. If I use import frame or from frame import Frame I...
Instead of using from bindings import Bindings try import bindings.
0
false
1
6,008
2019-03-20 10:03:02.943
How to only enter a date that is a weekday in Python
I'm creating a web applcation in Python and I only want the user to be able to enter a weekday that is older than today's date. I've had a look at isoweekday() for example but don't know how to integrate it into a flask form. The form currently looks like this: appointment_date = DateField('Appointment Date', format='%...
If you just want a weekday, you should put a select or a textbox, not a date picker. If you put a select, you can disable the days before today so you don't even need a validation
0
false
1
6,009
2019-03-20 23:43:33.130
Speed up access to python programs from Golang's exec packaqe
I need suggestions on how to speed up access to python programs when called from Golang. I really need fast access time (very low latency). Approach 1: func main() { ... ... cmd = exec.Command("python", "test.py") o, err = cmd.CombinedOutput() ... } If my test.py file is a basic print "HelloWorld" prog...
Approach 1: Simple HTTP server and client Approach 2: Local socket or pipe Approach 3: Shared memory Approach 4: GRPC server and client In fact, I prefer the GRPC method by stream way, it will hold the connection (because of HTTP/2), it's easy, fast and secure. And it's easy moving python node to another machine.
0
false
1
6,010
2019-03-21 20:01:04.153
Python: Iterate through every pixel in an image for image recognition
I'm a newbie in image processing and python in general. For an image recognition project, I want to compare every pixel with one another. For that, I need to create a program that iterates through every pixel, takes it's value (for example "[28, 78, 72]") and creates some kind of values through comparing it to every ot...
Comparing every pixel with a "pattern" can be done with convolution. You should take a look at Haar cascade algorithm.
0
false
1
6,011
2019-03-21 20:38:04.357
numpy.savetxt() rounding values
I'm using numpy.savetxt() to save an array, but its rounding my values to the first decimal point, which is a problem. anyone have any clue how to change this?
You can set the precision through changing fmt parameter. For example np.savetxt('tmp.txt',a, fmt='%1.3f') would leave you with an output with the precision of first three decimal points
0.386912
false
1
6,012
2019-03-22 03:06:43.583
Training SVM in Python with pictures
I have basic knowledge of SVM, but now I am working with images. I have images in 5 folders, each folder, for example, has images for letters a, b, c, d, e. The folder 'a' has images of handwriting letters for 'a, folder 'b' has images of handwriting letters for 'b' and so on. Now how can I use the images as my train...
as far i understood you want to train your svm to classify these images into the classes named a,b,c,d . For that you can use any of the good image processing techniques to extract features (such as HOG which is nicely implemented in opencv) from your image and then use these features , and the label as the input to yo...
0
false
1
6,013
2019-03-22 12:32:50.940
How to execute script from container within another container?
I have a contanarized flask app with external db, that logs users on other site using selenium. Everything work perfectly in localhost. I want to deploy this app using containers and found selenium container with google chrome within could make the job. And my question is: how to execute scripts/methods from flask cont...
As far as i understood, you are trying to take your local implementation, which runs on your pc and put it into two different docker containers. Then you want to make a call from the selenium container to your container containing the flask script which connects to your database. In this case, you can think of your con...
1.2
true
1
6,014
2019-03-22 21:15:34.407
Visual Studio doesn't work with Anaconda environment
I downloaded VS2019 preview to try how it works with Python. I use Anaconda, and VS2019 sees the Anaconda virtual environment, terminal opens and works but when I try to launch 'import numpy', for example, I receive this: An internal error has occurred in the Interactive window. Please restart Visual Studio. Intel ...
I had same issue, this worked for me: Try to add conda-env-root/Library/bin to the path in the run environment.
0
false
1
6,015
2019-03-24 17:23:41.657
Automatically filled field in model
I have some model where there are date field and CharField with choices New or Done, and I want to show some message for this model objects in my API views if 2 conditions are met, date is past and status is NEW, but I really don't know how I should resolve this. I was thinking that maybe there is option to make some ...
You need override the method save of your model. An overrided method must check the condition and show message You may set the signal receiver on the post_save signal that does the same like (1).
0
false
1
6,016
2019-03-25 03:15:40.920
how to drop multiple (~5000) columns in the pandas dataframe?
I have a dataframe with 5632 columns, and I only want to keep 500 of them. I have the columns names (that I wanna keep) in a dataframe as well, with the names as the row index. Is there any way to do this?
Let us assume your DataFrame is named as df and you have a list cols of column indices you want to retain. Then you should use: df1 = df.iloc[:, cols] This statement will drop all the columns other than the ones whose indices have been specified in cols. Use df1 as your new DataFrame.
0
false
1
6,017
2019-03-26 17:26:01.377
How to configure PuLP to call GLPK solver
I am using the PuLP library in Python to solve an MILP problem. I have run my problem successfully with the default solver (CBC). Now I would like to use PuLP with another solver (GLPK). How do I set up PuLP with GLPK? I have done some research online and found information on how to use GLPK (e.g. with lp_prob.solve(pu...
I had same problem, but is not related with glpk installation, is with solution file create, the message is confusim. My problem was I use numeric name for my variables, as '0238' ou '1342', I add a 'x' before it, then they looked like 'x0238'.
0.201295
false
2
6,018
2019-03-26 17:26:01.377
How to configure PuLP to call GLPK solver
I am using the PuLP library in Python to solve an MILP problem. I have run my problem successfully with the default solver (CBC). Now I would like to use PuLP with another solver (GLPK). How do I set up PuLP with GLPK? I have done some research online and found information on how to use GLPK (e.g. with lp_prob.solve(pu...
After reading in more detail the code and testing out some things, I finally found out how to use GLPK with PuLP, without changing anything in the PuLP package itself. Your need to pass the path as an argument to GLPK_CMD in solve as follows (replace with your glpsol path): lp_prob.solve(GLPK_CMD(path = 'C:\\Users\\use...
1.2
true
2
6,018
2019-03-26 23:03:52.333
Tower of colored cubes
Consider a set of n cubes with colored facets (each one with a specific color out of 4 possible ones - red, blue, green and yellow). Form the highest possible tower of k cubes ( k ≤ n ) properly rotated (12 positions of a cube), so the lateral faces of the tower will have the same color, using and evolutionary algorith...
First, I'm not sure how you get 12 rotations; I get 24: 4 orientations with each of the 6 faces on the bottom. Use a standard D6 (6-sided die) and see how many different layouts you get. Apparently, the first thing you need to build is a something (a class?) that accurately represents a cube in any of the available or...
0
false
1
6,019
2019-03-27 20:20:56.763
Airflow: How to download file from Linux to Windows via smbclient
I have a DAG that imports data from a source to a server. From there, I am looking to download that file from the server to the Windows network. I would like to keep this part in Airflow for automation purposes. Does anyone know how to do this in Airflow? I am not sure whether to use the os package, the shutil package,...
I think you're saying you're looking for a way to get files from a cloud server to a windows shared drive or onto a computer in the windows network, these are some options I've seen used: Use a service like google drive, dropbox, box, or s3 to simulate a synced folder on the cloud machine and a machine in the windows ...
0
false
1
6,020
2019-03-29 18:04:09.080
Python GTK+ 3: Is it possible to make background window invisible?
basically I have this window with a bunch of buttons but I want the background of the window to be invisible/transparent so the buttons are essentially floating. However, GTK seems to be pretty limited with CSS and I haven't found a way to do it yet. I've tried making the main window opacity 0 but that doesn't seem to ...
For transparency Xorg requires a composite manager running on the X11 server. The compmgr program from Xorg is a minimal composite manager.
0
false
1
6,021
2019-03-30 18:02:10.470
Matplotlib with Pydroid 3 on Android: how to see graph?
I'm currently using an Android device (of Samsung), Pydroid 3. I tried to see any graphs, but it doesn't works. When I run the code, it just shows me a black-blank screen temporarily and then goes back to the source code editing window. (means that i can't see even terminal screen, which always showed me [Program Finis...
I also had this problem a while back, and managed to fix it by using plt.show() at the end of your code. With matplotlib.pyplot as plt.
0.101688
false
3
6,022
2019-03-30 18:02:10.470
Matplotlib with Pydroid 3 on Android: how to see graph?
I'm currently using an Android device (of Samsung), Pydroid 3. I tried to see any graphs, but it doesn't works. When I run the code, it just shows me a black-blank screen temporarily and then goes back to the source code editing window. (means that i can't see even terminal screen, which always showed me [Program Finis...
After reinstalling it worked. The problem was that I forced Pydroid to update matplotlib via Terminal, not the official PIP tab. The version of matplotlib was too high for pydroid
1.2
true
3
6,022
2019-03-30 18:02:10.470
Matplotlib with Pydroid 3 on Android: how to see graph?
I'm currently using an Android device (of Samsung), Pydroid 3. I tried to see any graphs, but it doesn't works. When I run the code, it just shows me a black-blank screen temporarily and then goes back to the source code editing window. (means that i can't see even terminal screen, which always showed me [Program Finis...
You just need to add a line plt.show() Then it will work. You can also save the file before showing plt.savefig("*imageName*.png")
0
false
3
6,022
2019-03-31 02:36:13.693
Accidentally used homebrew to change my default python to 3.7, how do I change it back to 2.7?
I was trying to install python 3 because I wanted to work on a project using python 3. Instructions I'd found were not working, so I boldly ran brew install python. Wrong move. Now when I run python -V I get "Python 3.7.3", and when I try to enter a virtualenv I get -bash: /Users/elliot/Library/Python/2.7/bin/virtualen...
So, I got through it by completely uninstalling Python, which I'd been reluctant to do, and then reinstalled Python 2. I had to update my path and open a new shell to get it to see the new python 2 installation, and things fell into place. I'm now using pyenv for my Python 3 project, and it's a dream.
0
false
1
6,023
2019-03-31 06:41:35.623
How does one transfer python code written in a windows laptop to a samsung android phone?
I created numerous python scripts on my pc laptop, and I want to run those scripts on my android phone. How can I do that? How can I move python scripts from my windows pc laptop, and use those python scripts on my samsung adroid phone? I have downloaded qpython from the google playstore, but I still don't know how to...
Send them to yourself via email, then download the scripts onto your phone and run them through qpython. However you have to realize not all the modules on python work on qpython so your scripts may not work the same when you transfer them.
0
false
2
6,024
2019-03-31 06:41:35.623
How does one transfer python code written in a windows laptop to a samsung android phone?
I created numerous python scripts on my pc laptop, and I want to run those scripts on my android phone. How can I do that? How can I move python scripts from my windows pc laptop, and use those python scripts on my samsung adroid phone? I have downloaded qpython from the google playstore, but I still don't know how to...
you can use TeamViewer to control your android phone from your PC. And copy and paste the code easily. or You can transfer your scripts on your phone memory in the qpython folder and open it using qpython for android.
0
false
2
6,024
2019-04-01 16:47:12.417
how to find text before and after given words and output into different text files?
I have a text file like this: ... NAME : name-1 ... NAME : name-2 ... ... ... NAME : name-n ... I want output text files like this: name_1.txt : NAME : name-1 ... name_2.txt : NAME : name-2 ... ... name_n.txt : NAME : name-n ... I have the basic knowledge of grep, sed, awk, shell scripting, py...
With GNU sed: sed "s/\(.*\)\(name-.*\)/echo '\1 \2' > \2.txt/;s/-/_/2e" input-file Turn line NAME : name-2 into echo "NAME : name-2" > name-2.txt Then replace the second - with _ yielding echo "NAME : name-2" > name_2.txt e have the shell run the command constructed in the pattern buffer. This outputs blank lines to ...
0
false
1
6,025
2019-04-02 09:36:07.253
Unable to parse the rows in ResultSet returned by connection.execute(), Python and SQLAlchemy
I have a task to compare data of two tables in two different oracle databases. We have access of views in both of db. Using SQLAlchemy ,am able to fetch rows from views but unable to parse it. In one db the type of ID column is : Raw In db where column type is "Raw", below is the row am getting from resultset . (b'\...
bytes.hex() solved the problem
1.2
true
1
6,026
2019-04-02 12:30:37.360
How to install Python packages from python3-apt in PyCharm on Windows?
I'm on Windows and want to use the Python package apt_pkg in PyCharm. On Linux I get the package by doing sudo apt-get install python3-apt but how to install apt_pkg on Windows? There is no such package on PyPI.
There is no way to run apt-get in Windows; the package format and the supporting infrastructure is very explicitly Debian-specific.
0.201295
false
1
6,027
2019-04-03 14:59:12.000
“Close and Halt” feature does not functioning in jupyter notebook launched under Canopy on macOs High Sierra
When I done with my work, I try to close my jupyter notebook via 'Close and Halt' under the file menu. However it somehow do not functioning. I am running the notebook from Canopy, version: 2.1.9.3717, under macOs High Sierra.
If you are running Jupyter notebook from Canopy, then the Jupyter notebook interface is not controlling the kernel; rather, Canopy's built-in ipython Qtconsole is. You can restart the kernel from the Canopy run menu.
0.386912
false
1
6,028
2019-04-03 17:51:59.123
Running an external Python script on a Django site
I have a Python script which communicates with a Financial site through an API. I also have a Django site, i would like to create a basic form on my site where i input something and, according to that input, my Python script should perform some operations. How can i do this? I'm not asking for any code, i just would l...
Since you don't want code, and you didn't get detailed on everything required required, here's my suggestion: Make sure your admin.py file has editable fields for the model you're using. Make an admin action, Take the selected row with the values you entered, and run that action with the data you entered. I would be ...
0.386912
false
2
6,029
2019-04-03 17:51:59.123
Running an external Python script on a Django site
I have a Python script which communicates with a Financial site through an API. I also have a Django site, i would like to create a basic form on my site where i input something and, according to that input, my Python script should perform some operations. How can i do this? I'm not asking for any code, i just would l...
I agree with @Daniel Roseman If you are looking for your program to be faster, maybe multi-threading would be useful.
0
false
2
6,029
2019-04-04 02:39:46.887
Tracking any change in an table on SQL Server With Python
How are you today? I'm a newbie in Python. I'm working with SQL server 2014 and Python 3.7. So, my issue is: When any change occurs in a table on DB, I want to receive a message (or event, or something like that) on my server (Web API - if you like this name). I don't know how to do that with Python. I have an practi...
I do not know many things about SQL. But I guess there are tools for SQL to detect those changes. And then you could create an everlasting loop thread using multithreading package to capture that change. (Remember to use time.sleep() to block your thread so that It wouldn't occupy the CPU for too long.) Once you captur...
0
false
1
6,030
2019-04-04 07:59:55.183
virtual real time limit (178/120s) reached
I am using ubuntu 16 version and running Odoo erp system 12.0 version. On my application log file i see information says "virtual real time limit (178/120s) reached". What exactly it means & what damage it can cause to my application? Also how i can increase the virtual real time limit?
Open your config file and just add below parameter : --limit-time-real=100000
0.986614
false
1
6,031
2019-04-04 15:23:10.660
How to handle multiple major versions of dependency
I'm wondering how to handle multiple major versions of a dependency library. I have an open source library, Foo, at an early release stage. The library is a wrapper around another open source library, Bar. Bar has just launched a new major version. Foo currently only supports the previous version. As I'm guessing that ...
Have two different branches, updating both branches for all new features. Not sure how this works with PyPI. Wouldn't I have to release at different version numbers each time? Yes, you could have a 1.x release (that supports the old version) and a 2.x release (that supports the new version) and release both simultaneo...
0.201295
false
1
6,032
2019-04-05 16:28:56.133
How do apply Q-learning to an OpenAI-gym environment where multiple actions are taken at each time step?
I have successfully used Q-learning to solve some classic reinforcement learning environments from OpenAI Gym (i.e. Taxi, CartPole). These environments allow for a single action to be taken at each time step. However I cannot find a way to solve problems where multiple actions are taken simultaneously at each time step...
You can take one of two approaches - depend on the problem: Think of the set of actions you need to pass to the environment as independent and make the network output actions values for each one (make softmax separately) - so if you need to pass two actions, the network will have two heads, one for each axis. Think of...
0.673066
false
1
6,033
2019-04-06 19:50:46.103
How to install python3.6 in parallel with python 2.7 in Ubuntu 18
Setting up to start python for data analytics and want to install python 3.6 in Ubuntu 18.0 . Shall i run both version in parallel or overwrite 2.7 and how ? I am getting ambiguous methods when searched up.
Try pyenv and/or pipenv . Both are excellent tools to maintain local python installations.
0
false
1
6,034
2019-04-07 08:00:53.180
how to display the month in from view ? (Odoo11)
please, how do I display the month in the form? example: 07/04/2019 i want to change it in 07 april, 2019 Thank you in advance
Try with following steps: Go to Translations > Languages Open record with your current language. Edit date format with %d %A, %Y
0.386912
false
1
6,035
2019-04-07 14:08:01.350
How to fix print((double parentheses)) after 2to3 conversion?
When migrating my project to Python 3 (2to3-3.7 -w -f print *), I observed that a lot of (but not all) print statements became print((...)), so these statements now print tuples instead of performing the expected behavior. I gather that if I'd used -p, I'd be in a better place right now because from __future__ import p...
If your code already has print() functions you can use the -x print argument to 2to3 to skip the conversion.
0.613357
false
1
6,036
2019-04-08 06:39:59.923
Windowed writes in python, e.g. to NetCDF
In python how can I write subsets of an array to disk, without holding the entire array in memory? The xarray input/output docs note that xarray does not support incremental writes, only incremental reads except by streaming through dask.array. (Also that modifying a dataset only affects the in-memory copy, not the con...
This can be done using netCDF4 (the python library of low level NetCDF bindings). Simply assign to a slice of a dataset variable, and optionally call the dataset .sync() method afterward to ensure no delay before those changes are flushed to the file. Note this approach also provides the opportunity to progressively g...
0
false
1
6,037
2019-04-08 14:03:38.120
Is there any way to hide or encrypt your python code for edge devices? Any way to prevent reverse engineering of python code?
I am trying to make a smart IOT device (capable of performing smart Computer Vision operations, on the edge device itself). A Deep Learning algorithm (written in python) is implemented on Raspberry Pi. Now, while shipping this product (software + hardware) to my customer, I want that no one should log in to the raspber...
Keeping the code on your server and using internet access is the only way to keep the code private (maybe). Any type of distributed program can be taken apart eventually. You can't (possibly shouldn't) try to keep people from getting inside devices they own and are in their physical possession. If you have your propert...
-0.386912
false
1
6,038
2019-04-08 15:02:18.437
How to classify unlabelled data?
I am new to Machine Learning. I am trying to build a classifier that classifies the text as having a url or not having a url. The data is not labelled. I just have textual data. I don't know how to proceed with it. Any help or examples is appreciated.
Since it's text, you can use bag of words technique to create vectors. You can use cosine similarity to cluster the common type text. Then use classifier, which would depend on number of clusters. This way you have a labeled training set. If you have two cluster, binary classifier like logistic regression would work...
0.201295
false
1
6,039
2019-04-08 16:54:25.427
Django - how to visualize signals and save overrides?
As a project grows, so do dependencies and event chains, especially in overridden save() methods and post_save and pre_save signals. Example: An overridden A.save creates two related objects to A - B and C. When C is saved, the post_save signal is invoked that does something else, etc... How can these event chins be m...
(Too long to fit into a comment, lacking code to be a complete answer) I can't mock up a ton of code right now, but another interesting solution, inspired by Mario Orlandi's comment above, would be some sort of script that scans the whole project and searches for any overridden save methods and pre and post save signa...
0.454054
false
1
6,040
2019-04-09 07:36:02.467
Capturing time between HTML form submit action and printing response
I have a Python Flask application with a HTML form which accept few inputs from user, uses those in an python program which returns the processed values back to flask application return statement. I wanted to capture the time took for whole processing and rendering output data on browser but not sure how to do that. At...
Use ajax request to submit form. Fetch the time on clicking the button and after getting the response and then calculate the difference.
0
false
1
6,041
2019-04-09 09:15:48.837
How to extract images from PDF or Word, together with the text around images?
I found there are some library for extracting images from PDF or word, like docx2txt and pdfimages. But how can I get the content around the images (like there may be a title below the image)? Or get a page number of each image? Some other tools like PyPDF2 and minecart can extract image page by page. However, I cannot...
docx2python pulls the images into a folder and leaves -----image1.png---- markers in the extracted text. This might get you close to where you'd like to go.
0
false
1
6,042
2019-04-09 18:46:58.267
What is this audio datatype and how do I convert it to wav/l16?
I am recording audio in a web browser and sending it to a flask backend. From there, I want to transcribe the audio using Watson Speech to Text. I cannot figure out what data format I'm receiving the audio and how to convert it to a format that works for watson. I believe watson expects a bytestring like b'\x0c\xff\x0c...
Those values should be fine, but you have to define how you want them stored before getting the bytes representation of them. You'd simply want to convert those values to signed 2-byte/16-bit integers, then get the bytes representation of those.
1.2
true
1
6,043
2019-04-09 19:37:11.227
how do I implement ssim for loss function in keras?
I need SSIM as a loss function in my network, but my network has 2 outputs. I need to use SSIM for first output and cross-entropy for the next. The loss function is a combination of them. However, I need to have a higher SSIM and lower cross-entropy, so I think the combination of them isn't true. Another problem is th...
other choice would be ssim_loss = 1 - tf.reduce_mean(tf.image.ssim(target, output, max_val=self.max_val)) then combine_loss = mae (or mse) + ssim_loss In this way, you are minimizing both of them.
0
false
1
6,044
2019-04-11 11:57:15.603
KMeans: Extracting the parameters/rules that fill up the clusters
I have created a 4-cluster k-means customer segmentation in scikit learn (Python). The idea is that every month, the business gets an overview of the shifts in size of our customers in each cluster. My question is how to make these clusters 'durable'. If I rerun my script with updated data, the 'boundaries' of the clus...
Got the answer in a different topic: Just record the cluster means. Then when new data comes in, compare it to each mean and put it in the one with the closest mean.
0.386912
false
1
6,045
2019-04-11 13:25:10.313
how to count number of days via cron job in odoo 10?
I am setting up a script for counting number of days with passing each day in odoo. How i can count day passing each day till end of the month. For example : i have set two dates to find days between them.I need function which compare number of days with each passing day. When meet remaining day is 0 then will call a ...
Write a scheduled action that runs python code daily. The first thing that this code should do is to check the number of days you talk about and if it is 0, it should trigger whatever action it is needed.
0
false
1
6,046
2019-04-12 04:46:43.223
How to add reply(child comments) to comments on feed in getstream.io python
I am using getstream.io to create feeds. The user can follow feeds and add reaction like and comments. If a user adds a comment on feed and another wants to reply on the comment then how I can achieve this and also retrieve all reply on the comment.
you can add the child reaction by using reaction_id
0
false
1
6,047
2019-04-12 12:06:29.347
how to find the similarity between two documents
I have tried using the similarity function of spacy to get the best matching sentence in a document. However it fails for bullet points because it considers each bullet as the a sentence and the bullets are incomplete sentences (eg sentence 1 "password should be min 8 characters long , sentence 2 in form of a bullet " ...
Bullets are considered but the thing is it doesn't understand who 8 characters is referring to so I thought of finding the heading of the paragraph and replacing the bullets with it I found the headings using python docs but it doesn't read bullets while reading the document ,is there a way I can read it using py...
0
false
2
6,048
2019-04-12 12:06:29.347
how to find the similarity between two documents
I have tried using the similarity function of spacy to get the best matching sentence in a document. However it fails for bullet points because it considers each bullet as the a sentence and the bullets are incomplete sentences (eg sentence 1 "password should be min 8 characters long , sentence 2 in form of a bullet " ...
Sounds to me like you need to do more text processing before attempting to use similarity. If you want bullet points to be considered part of a sentence, you need to modify your spacy pipeline to understand to do so.
0
false
2
6,048
2019-04-12 13:48:58.717
Trying to Import Infoblox Module in Python
I am trying to write some code in python to retrieve some data from Infoblox. To do this i need to Import the Infoblox Module. Can anyone tell me how to do this ?
Before you can import infoblox you need to install it: open a command prompt (press windows button, then type cmd) if you are working in a virtual environment access it with activate yourenvname (otherwise skip this step) execute pip install infoblox to install infoblox, then you should be fine to test it from the com...
0
false
1
6,049
2019-04-12 21:52:02.810
Why do I keep getting this error when trying to create a virtual environment with Python 3 on MacOS?
So I'm following a book that's teaching me how to make a Learning Log using Python and the Django web framework. I was asked to go to a terminal and create a directory called "learning_log" and change the working directory to "learning_log" (did that with no problems). However, when I try to create the virtual environm...
For Ubuntu: The simple is if virtualenv --version returns something like virtualenv: command not found and which virtualenv prints nothing on the console, then virtualenv is not installed on your system. Please try to install using pip3 install virtualenv or sudo apt-get install virtualenv but this one might install a...
0
false
2
6,050
2019-04-12 21:52:02.810
Why do I keep getting this error when trying to create a virtual environment with Python 3 on MacOS?
So I'm following a book that's teaching me how to make a Learning Log using Python and the Django web framework. I was asked to go to a terminal and create a directory called "learning_log" and change the working directory to "learning_log" (did that with no problems). However, when I try to create the virtual environm...
I had the same error. I restarted my computer and tried it again, but the error was still there. Then I tried python3 -m venv ll_env and it moved forward.
0
false
2
6,050
2019-04-13 11:57:31.263
How do I calculate the similarity of a word or couple of words compared to a document using a doc2vec model?
In gensim I have a trained doc2vec model, if I have a document and either a single word or two-three words, what would be the best way to calculate the similarity of the words to the document? Do I just do the standard cosine similarity between them as if they were 2 documents? Or is there a better approach for compar...
There's a number of possible approaches, and what's best will likely depend on the kind/quality of your training data and ultimate goals. With any Doc2Vec model, you can infer a vector for a new text that contains known words – even a single-word text – via the infer_vector() method. However, like Doc2Vec in general, ...
1.2
true
1
6,051
2019-04-14 15:12:05.933
operations order in Python
I have just now started learning python from Learn Python 3 The Hard Way by Zed Shaw. In exercise 3 of the book, there was a problem to get the value of 100 - 25 * 3 % 4. The solution to this problem is already mentioned in the archives, in which the order preference is given to * and %(from left to right). I made a pr...
The % operator is used to find the remainder of a quotient. So 25 % 3 = 1 not 3/4.
0
false
2
6,052
2019-04-14 15:12:05.933
operations order in Python
I have just now started learning python from Learn Python 3 The Hard Way by Zed Shaw. In exercise 3 of the book, there was a problem to get the value of 100 - 25 * 3 % 4. The solution to this problem is already mentioned in the archives, in which the order preference is given to * and %(from left to right). I made a pr...
Actually, the % operator gives you the REMAINDER of the operation. Therefore, 25 % 3 returns 1, because 25 / 3 = 8 and the remainder of this operation is 1. This way, your operation 100 - 25 % 3 + 4 is the same as 100 - 1 + 4 = 103
1.2
true
2
6,052
2019-04-14 20:15:45.423
Comparing feature extractors (or comparing aligned images)
I'd like to compare ORB, SIFT, BRISK, AKAZE, etc. to find which works best for my specific image set. I'm interested in the final alignment of images. Is there a standard way to do it? I'm considering this solution: take each algorithm, extract the features, compute the homography and transform the image. Now I need to...
From your question, it seems like the task is not to compare the feature extractors themselves, but rather to find which type of feature extractor leads to the best alignment. For this, you need two things: a way to perform the alignment using the features from different extractors a way to check the accuracy of the a...
1.2
true
1
6,053
2019-04-15 15:05:35.363
How to get access to django database from other python program?
I have django project in which I can display records from raspberry pi device. I had mysql database and i have send records from raspberry there. I can display it via my api, but I want to work on this records.I want to change this to django database but I don't know how I can get access to django database which is on ...
ALERT: THIS CAN LEAD TO SECURITY ISSUES A Django database is no different from any other database. In this case a MySQL. The VPS server where the MySQL is must have a public IP, the MySQL must be listening on that IP (if the VPS has a public IP but MySQL is not listening/bind on that IP, it won't work) and the port of ...
1.2
true
1
6,054
2019-04-16 11:37:49.557
What happened after entered " flask run" on a terminal under the project directory?
What happened after entered "flask run" on a terminal under the project directory? How the python interpreter gets the file of flask.__main__.py and starts running project's code? I know how Flask locates app. What I want to figure out is how command line instruction "flask run" get the flask/__main__.py bootup
flask is a Python script. Since you stated you are not a beginner, you should simply open the file (/usr/bin/flask) in your favorite text editor and start from there. There is no magic under the hood.
1.2
true
1
6,055
2019-04-17 08:02:38.757
what's the difference between airflow's 'parallelism' and 'dag_concurrency'
I can't understand the difference between dag_concurrency and parallelism. documentation and some of the related posts here somehow contradicts my findings. The understanding I had before was that the parallelism parameter allows you to set the MAX number of global(across all DAGs) TaskRuns possible in airflow and dag_...
The other answer is only partially correct: dag_concurrency does not explicitly control tasks per worker. dag_concurrency is the number of tasks running simultaneously per dag_run. So if your DAG has a place where 10 tasks could be running simultaneously but you want to limit the traffic to the workers you would set da...
0.986614
false
1
6,056
2019-04-17 15:40:35.510
how do i fix "No module named 'win32api'" on python2.7
I am trying to import win32api in python 2.7.9. i did the "pip install pypiwin32" and made sure all the files were intalled correctly (i have the win32api.pyd under ${PYTHON_HOME}\Lib\site-packages\win32). i also tried coping the files from C:\Python27\Lib\site-packages\pywin32_system32 to C:\Python27\Lib\site-packages...
Well, turns out the answer is upgrading my python to 3.6. python 2.7 seems to old to work with outside imports (I'm just guessing here, because its not the first time I'm having an import problem) hope it helps :)
1.2
true
1
6,057
2019-04-17 15:55:52.440
paste code to Jupyter notebook without symbols
I tried to paste few lines code from online sources with the symbol like ">>>". My question is how to paste without these symbols? (Line by line works but it will be very annoying if pasting a big project.) Cheers
Go to Edit > Find and Replace, in which find for >>> and replace with empty. Enjoy :)
0
false
1
6,058
2019-04-17 19:02:36.187
How can python iterate over a set if no order is defined?
So I notice that we say in python that sets have no order or arrangement, although of course you can sort the list generated from a set. So I was wondering how the iteration over a set is defined in python. Does it just follow the sorted list ordering, or is there some other footgun that might crop up at some point? Th...
A temporary order is used to iterate over the set, but you can't reliably predict it (practically speaking, as it depends on the insertion and deletion history of the set). If you need a specific order, use a list.
1.2
true
1
6,059
2019-04-18 06:31:12.170
How to triangulate a point in 3D space, given coordinate points in 2 image and extrinsic values of the camera
I'm trying to write a function that when given two cameras, their rotation, translation matrices, focal point, and the coordinates of a point for each camera, will be able to triangulate the point into 3D space. Basically, given all the extrinsic/intrinsic values needed I'm familiar with the general idea: to somehow cr...
Assume you have two cameras -- camera 1 and camera 2. For each camera j = 1, 2 you are given: The distance hj between it's center Oj, (is "focal point" the right term? Basically the point Oj from which the camera is looking at its screen) and the camera's screen. The camera's coordinate system is centered at Oj, the...
0
false
1
6,060
2019-04-18 14:54:16.823
Understanding execution_date in Airflow
I am running an airflow DAG and wanted to understand how the execution date gets set. This is the code I am running: {{ execution_date.replace(day=1).strftime("%Y-%m-%d") }} This always returns the first day of the month. This is the functionality that I want, but I just want to find a way to understand what is happe...
execution_date returns a datatime object. You are using the replace method of that object to replace the “day” with the first. Then outputting that to a string with the format method.
0
false
2
6,061
2019-04-18 14:54:16.823
Understanding execution_date in Airflow
I am running an airflow DAG and wanted to understand how the execution date gets set. This is the code I am running: {{ execution_date.replace(day=1).strftime("%Y-%m-%d") }} This always returns the first day of the month. This is the functionality that I want, but I just want to find a way to understand what is happe...
The reason this always returns the first of the month is that you are using a Replace to ensure the day is forced to be the 1st of the month. Simply remove ".replace(day=1)".
1.2
true
2
6,061
2019-04-19 10:22:36.757
How to convert file .py to .exe, having Python from Anaconda Navigator? (in which command prompt should I write installation codes?)
I created a Python script (format .py) that works. I would like to convert this file to .exe, to use it in a computer without having Python installed. How can I do? I have Python from Anaconda3. What can I do? Thank you! I followed some instruction found here on Stackoverflow. .I modify the Path in the 'Environment var...
I personaly use pyinstaller, its available from pip. But it will not really compile, it will just bundle. The difference is compiling means translating to real machine code while bundling is creating a big exe file with all your libs and your python interpreter. Even if pyinstaller create bigger file and is slower than...
1.2
true
1
6,062
2019-04-19 16:25:54.117
How can i install opencv in python3.7 on ubuntu?
I have a Nvidia Jetson tx2 with the orbitty shield on it. I got it from a friend who worked on it last year. It came with ubuntu 16.04. I updated everything on it and i installed the latest python3.7 and pip. I tried checking the version of opencv to see what i have but when i do import cv2 it gives me : Traceback (mo...
Does python-3.7 -m pip install opencv-python work? You may have to change the python-3.7 to whatever path/alias you use to open your own python 3.7.
0
false
1
6,063
2019-04-20 21:40:23.537
Negative Feature Importance Value in CatBoost LossFunctionChange
I am using CatBoost for ranking task. I am using QueryRMSE as my loss function. I notice for some features, the feature importance values are negative and I don't know how to interpret them. It says in the documentation, the i-th feature importance is calculated as the difference between loss(model with i-th feature ex...
Negative feature importance value means that feature makes the loss go up. This means that your model is not getting good use of this feature. This might mean that your model is underfit (not enough iteration and it has not used the feature enough) or that the feature is not good and you can try removing it to improve ...
1.2
true
1
6,064
2019-04-23 04:00:09.300
cv2 - multi-user image display
Using python and OpenCV, is it possible to display the same image on multiple users? I am using cv2.imshow but it only displays the image for the user that runs the code. Thanks
I was able to display the images on another user/host by setting the DISPLAY environment variable of the X server to match the desired user's DISPLAY.
0
false
1
6,065
2019-04-23 06:19:55.700
Move turtle slightly closer to random coordinate on each update
I'm doing a homework and I want to know how can I move turtle to a random location a small step each time. Like can I use turtle.goto() in a slow motion? Someone said I should use turtle.setheading() and turtle.forward() but I'm confused on how to use setheading() when the destination is random. I'm hoping the turtle c...
Do you mean that you want to move a small step, stop, and repeat? If so, you can ‘import time’ and add ‘time.sleep(0.1)’ after each ‘forward’
0
false
1
6,066
2019-04-23 15:17:02.483
Python append single bit to bytearray
I have a bytearray containing some bytes, it currently look like this (Converted to ASCII): ['0b1100001', '0b1100010', '0b1100011', '0b10000000'] I need to add a number of 0 bits to this, is that possible or would I have to add full bytes? If so, how do I do that?
Where do you need the bits added to? Each element of your list or an additional element that contains all 0's? The former: myList[0] = myList[0] * 2 # ASL The later myList.append(0b000000)
0.135221
false
1
6,067
2019-04-23 19:50:59.320
How to access _pycache_ directory
I want to remove a folder, but I can’t get in pycache to delete the pyc and pyo$ files. I have done it before, but I don’t know how I did it.
If you want to remove your python file artifacts, such as the .pyc and .pyo cache files, maybe you could try the following: Move into your project's root directory cd <path_to_project_root> Remove python file artifacts find . -name '*.pyc' -exec rm -f {} + find . -name '*.pyo' -exec rm -f {} + Hopefully that helps!
0
false
1
6,068
2019-04-26 07:18:59.020
numerical entity extraction from unstructured texts using python
I want to extract numerical entities like temperature and duration mentioned in unstructured formats of texts using neural models like CRF using python. I would like to know how to proceed for numerical extraction as most of the examples available on the internet are for specific words or strings extraction. Input: 'F...
So far my research shows that you can treat numbers as words. This raises an issue : learning 5 will be ok, but 19684 will be to rare to be learned. One proposal is to convert into words. "nineteen thousands six hundred eighty four" and embedding each word. The inconvenient is that you are now learning a (minimum) 6 d...
0
false
1
6,069
2019-04-26 14:50:51.197
Python Azure webjob passing parameters
I have a Python WebJob living in Azure and I'm trying to pass parameters to it. I've found documentation saying that I should be able to post the URL and add:?arguments={'arg1', 'arg2'} after it. However, when I do that and then try to print(sys.argv) in my code, it's only printing the name of the Python file and non...
I figured it out: in the run.cmd file, you need to put "%*" after your script name and it will detect any arguments you passed in the URL.
1.2
true
1
6,070
2019-04-27 17:03:24.327
What happens after shutting down the PC via subprocess?
I try to turn my pc off and restart it on LAN. When getting one of the commands (turnoff or restart), I execute one of the followings: subprocess.call(["shutdown", "-f", "-s", "-y"]) # Turn off subprocess.call(["shutdown", "-f", "-r", "-t", "-c", "-y"]) # Restart I'd like to inform the other side if the process was s...
Programs like shutdown merely send a message to init (or whatever modern replacement) and exit immediately; it’s up to it what happens next. Typical Unix behavior is to first shut down things like SSH servers (which probably doesn’t kill your connection to the machine), then send SIGTERM to all processes, wait a few s...
1.2
true
1
6,071
2019-04-27 20:18:09.337
How can I create a vCard qrcode with pyqrcode?
I am trying to generate a vCard QR code with the pyqrcode library but I cannot figure out the way to do it. I have read their documentation 5 times and it doesn't say anything about vCard, only about URL and on the internet, I could found only about wifi. Does anybody know how can I do it? I want to make a vCard QR cod...
Let's say : We've two libraries: pyqrcode : QR reader / writer vobject : vCard serializer / deserializer Flow: a. Generate a QR img from "some" web site : web site send JSON info => get info from JSON and serialize using vobject to obtain a vcard string => pyqrcode.create(vcard string) b. Show human r...
1.2
true
1
6,072
2019-04-28 15:35:56.843
Cloud SQL/NiFi: Connect to cloud sql database with python and NiFi
So, I am doing a etl process in which I use Apache NiFi as an etl tool along with a postgresql database from google cloud sql to read csv file from GCS. As a part of the process, I need to write a query to transform data read from csv file and insert to the table in the cloud sql database. So, based on NIFi, I need to...
I don't understand why you need to write any code in Python? I've done a similar process where I used GetFile (locally) to read a CSV file, parse and transform it, and then used ExecuteSQLRecord to insert the rows into a SQL server (running on a cloud provider). The DBCPConnectionPool needs to reference your cloud prov...
0
false
1
6,073
2019-04-29 12:55:44.847
Keras / NN - Handling NaN, missing input
These days i'm trying to teach myself machine learning and i'm going though some issues with my dataset. Some of my rows (i work with csv files that i create with some js script, i feel more confident doing that in js) are empty wich is normal as i'm trying to build some guessing model but the issue is that it results ...
You need to have the same input size during training and inference. If you have a few missing values (a few %), you can always choose to replace the missing values by a 0 or by the average of the column. If you have more missing values (more than 50%) you are probably better off ignoring the column completely. Note tha...
1.2
true
1
6,074
2019-04-30 15:36:33.210
Doc2Vec - Finding document similarity in test data
I am trying to train a doc2vec model using training data, then finding the similarity of every document in the test data for a specific document in the test data using the trained doc2vec model. However, I am unable to determine how to do this. I currently using model.docvecs.most_similar(...). However, this function o...
The act of training-up a Doc2Vec model leaves it with a record of the doc-vectors learned from the training data, and yes, most_similar() just looks among those vectors. Generally, doing any operations on new documents that weren't part of training will require the use of infer_vector(). Note that such inference: ign...
1.2
true
2
6,075
2019-04-30 15:36:33.210
Doc2Vec - Finding document similarity in test data
I am trying to train a doc2vec model using training data, then finding the similarity of every document in the test data for a specific document in the test data using the trained doc2vec model. However, I am unable to determine how to do this. I currently using model.docvecs.most_similar(...). However, this function o...
It turns out there is a function called similarity_unseen_docs(...) which can be used to find the similarity of 2 documents in the test data. However, I will leave the question unsolved for now as it is not very optimal since I would need manually compare the specific document with every other document in the test dat...
0
false
2
6,075
2019-04-30 22:47:27.537
How to run a python program using sourcelair?
I'm trying to run a python program in the online IDE SourceLair. I've written a line of code that simply prints hello, but I am embarrassed to say I can't figure out how to RUN the program. I have the console, web server, and terminal available on the IDE already pulled up. I just don't know how to start the program. ...
Can I ask you why you are using SourceLair? Well I just figured it out in about 2 mins....its the same as using any other editor for python. All you have to do is to run it in the terminal. python (nameoffile).py
0.201295
false
1
6,076
2019-05-01 22:51:50.737
How to implement Proximal Policy Optimization (PPO) Algorithm for classical control problems?
I am trying to implement clipped PPO algorithm for classical control task like keeping room temperature, charge of battery, etc. within certain limits. So far I've seen the implementations in game environments only. My question is the game environments and classical control problems are different when it comes to the i...
I'm answering your question from a general RL point of view, I don't think the particular algorithm (PPO) makes any difference in this question. I think there is no fundamental differences, both can be seen as discrete control problems. In a game you observe the state, then choose an action and act according to it, and...
1.2
true
1
6,077
2019-05-03 22:13:05.803
Visualizing a frozen graph_def.pb
I am wondering how to go about visualization of my frozen graph def. I need it to figure out my tensorflow networks input and output nodes. I have already tried several methods to no avail, like the summarize graph tool. Does anyone have an answer for some things that I can try? I am open to clarifying questions, thank...
You can try to use TensorBoard. It is on the Tensorflow website...
0
false
1
6,078
2019-05-04 18:47:48.437
Python: how to create database and a GUI together?
I am new to Python and to train myself, I would like to use Python build a database that would store information about wine - bottle, date, rating etc. The idea is that: I could use to database to add a new wine entries I could use the database to browse wines I have previously entered I could run some small analyses ...
If it's just for you, sure there is no problem with that stack. If I were doing it, I would skip Tkinter, and build something using Flask (or Django.) Doing a web page as a GUI yields faster results, is less fiddly, and more applicable to the job market.
0
false
1
6,079
2019-05-05 00:30:24.233
Pandas read_csv method can't get 'œ' character properly while using encoding ISO 8859-15
I have some trubble reading with pandas a csv file which include the special character 'œ'. I've done some reseach and it appears that this character has been added to the ISO 8859-15 encoding standard. I've tried to specify this encoding standard to the pandas read_csv methods but it doesn't properly get this special ...
Anyone have a clue ? I've manage the problem by manually rewrite this special character before reading my csv with pandas but that doesn't answer my question :(
0
false
1
6,080
2019-05-06 11:57:11.053
Using OpenCV with PyPy
I am trying to run a python script using OpenCV with PyPy, but all the documentation that I found didn't work. The installation of PyPy went well, but when I try to run the script it says that it can't find OpenCV modules like 'cv2' for example, despite having cloned opencv for pypy directly from a github repository. I...
pip install opencv-python worked well for me on python 2.7, I can import and use cv2.
0.201295
false
1
6,081
2019-05-07 06:21:51.733
Getting ARERR 149 A user name must be supplied in the control record
I have a SOAP url , while running the url through browser I am getting a wsdl response.But when I am trying to call a method in the response using the required parameter list, and it is showing "ARERR [149] A user name must be supplied in the control record".I tried using PHP as well as python but I am getting the same...
I got the solution for this problem.Following are the steps I followed to solve the issue (I have used "zeep" a 3rd party module to solve this): Run the following command to understand WSDL: python -mzeep wsdl_url Search for string "Service:". Below that we can see our operation name For my operation I found followi...
0
false
1
6,082
2019-05-07 20:45:21.080
How to implement Breadth-First-Search non-recursively for a directed graph on python
I'm trying to implement a BFS function that will print a list of nodes of a directed graph as visited using Breadth-First-Search traversal. The function has to be implemented non-recursively and it has to traverse through all the nodes in a graph, so if there are multiple trees it will print in the following way: Tree ...
BFS is usually done with a queue. When you process a node, you push its children onto the queue. After processing the node, you process the next one in the queue. This is by nature non-recursive.
0
false
1
6,083
2019-05-08 08:51:35.840
How to kill tensorboard with Tensorflow2 (jupyter, Win)
sorry for the noob question, but how do I kill the Tensorflow PID? It says: Reusing TensorBoard on port 6006 (pid 5128), started 4 days, 18:03:12 ago. (Use '!kill 5128' to kill it.) But I can not find any PID 5128 in the windows taks manager. Using '!kill 5128' within jupyter the error returns that comand kill cannot b...
If you clear the contents of AppData/Local/Temp/.tensorboard-info, and delete your logs, you should be able to have a fresh start
0.999967
false
1
6,084
2019-05-08 11:29:27.797
how to extract line from a word2vec file?
I have created a word2vec file and I want to extract only the line at position [0] this is the word2vec file `36 16 Activity 0.013954502 0.009596351 -0.0002082094 -0.029975398 -0.0244055 -0.001624907 0.01995442 0.0050479663 -0.011549354 -0.020344704 -0.0113901375 -0.010574887 0.02007604 -0.008582828 0.030914625 -0.0091...
glove_model["Activity"] should get you its vector representation from the loaded model. This is because glove_model is an object of type KeyedVectors and you can use key value to index into it.
1.2
true
1
6,085
2019-05-08 17:12:26.120
Handling many-to-many relationship from existing database using Django ORM
I'm starting to work with Django, already done some models, but always done that with 'code-first' approach, so Django handled the table creations etc. Right now I'm integrating an already existing database with ORM and I encountered some problems. Database has a lot of many-to-many relationships so there are quite a ...
In many cases it doesn't matter. If you would like to keep the code minimal then m2m fields are a good way to go. If you don't control the database structure it might be worth keeping the inspectdb schema in case you have to do it again after schema changes that you don't control. If the m2m link tables can grow proper...
0
false
1
6,086
2019-05-08 20:10:18.047
Is there a way to use the "read_csv" method to read the csv files in order they are listed in a directory?
I am plotting plots on one figure using matplotlib from csv files however, I want the plots in order. I want to somehow use the read_csv method to read the csv files from a directory in the order they are listed in so that they are outputted in the same fashion. I want the plots listed under each other the same way the...
you could use os.listdir() to get all the files in the folder and then sort them out in a certain way, for example by name(it would be enough using the python built in sorted() ). Instead if you want more fancy ordering you could retrieve both the name and last modified date and store them in a dictionary, order the ke...
1.2
true
1
6,087
2019-05-09 09:52:44.457
How to make a python script run forever online?
I Have a python script that monitors a website, and I want it to send me a notification when some particular change happens to the website. My question is how can I make that Python script runs for ever in some place else (Not my machine, because I want it to send me a notification even when my machine is off)? I have ...
I would suggest you to setup AWS EC2 instance with whatever OS you want. For beginner, you can get 750 hours of usage for free where you can run your script on.
0.386912
false
1
6,088
2019-05-12 11:06:47.317
How to write binary file with bit length not a multiple of 8 in Python?
I'm working on a tool generates dummy binary files for a project. We have a spec that describes the real binary files, which are created from a stream of values with various bit lengths. I use input and spec files to create a list of values, and the bitstring library's BitArray class to convert the values and join them...
You need to give padding to the, say 7-bit value so it matches a whole number of bytes: 1010101 (7 bits) --> 01010101 1111 (4 bits) --> 00001111 The padding of the most significant digits does not affect the data taken from the file.
0
false
1
6,089
2019-05-14 11:09:07.967
Send variable between PCs over the internet using python
I have two computers with internet connection. They both have public IPs and they are NATed. What I want is to send a variable from PC A to PC B and close the connection. I have thought of two approaches for this: 1) Using sockets. PC B will have listen to a connection from PC A. Then, when the variable will be sent, ...
Figured a solution out. I make a dummy server using flask and I hosted it at pythonanywhere.com for free. The variables are posted to the server from PC A and then, PC B uses the GET method to get them locally.
1.2
true
1
6,090
2019-05-15 19:48:44.263
Pulling duration stats API in Airflow
In airflow, the "Gantt" chart offers quite a good view on performance of the ran tasks. It offers stats like start/end time, duration and etc. Do you guys know a way to programmatically pull these stats via the Airflow API? I would like to use these stats and generate periodic reports on the performance of my tasks and...
One easy approach could be to set up a SQL alchemy connection, airflow stores/sends all the data in there once the configuration is completed(dag info/stat/fail, task info/stats/ etc.). Edit airflow.cfg and add: sql_alchemy_conn = mysql://------/table_name
1.2
true
1
6,091