I’m trying to subscribe to the Bitfinex.com websocket API public channel BTCUSD. Here’s the code: I believe ws.send(“BTCUSD”) is what subscribes to the public channel? I get a message back I think is confirming the subscription ({“event”:”info”,”version…
Tag: python
BeautifulSoup – find table with specified class on Wikipedia page
I am trying to find a table in a Wikipedia page using BeautifulSoup and for some reason I don’t get the table. Can anyone tell why I don’t get the table? my code: prints: None Answer You shouldn’t use jquery-tablesorter to select against in the response you get from requests because it is dy…
Upload file via SFTP with Python
I wrote a simple code to upload a file to a SFTP server in Python. I am using Python 2.7. The file did not appear on the server. However, no error message appeared. What is wrong with the code? I have enabled logging. I discovered that the file is uploaded to the root folder and not under public folder. Seems
How to join on multiple columns in Pyspark?
I am using Spark 1.3 and would like to join on multiple columns using python interface (SparkSQL) The following works: I first register them as temp tables. I would now like to join them based on multiple columns. I get SyntaxError: invalid syntax with this: Answer You should use & / | operators and be ca…
How do I find the keys in one dictionary that do not have a counterpart in another dictionary?
In Python, how do I find the keys in one dictionary that do not have a counterpart in another dictionary? The practical problem is that I have a dictionary of people that enrolled and a dictionary with their daily participation and I am trying to find the people that enrolled but did not participate, or are i…
Python – Using pyodbc to connect to remote server using info from Excel data connection
I have an excel (albeit, one that’s on our company server) that has a data connection to our SQL database so we can make nice pivot tables. I would like to get that data into python (on my local computer) so I can do some faster analysis. I have installed pyodbc. Here is the “connection stringR…
Using multiple Python engines (32Bit/64bit and 2.7/3.5)
I would like to use Python for scientific applications and after some research decided that I will use Anaconda as it comes bundled with loads of packages and add new modules using conda install through the cmd is easy. I prefer to use the 64 bit version for better RAM use and efficiency but 32bit version is …
How to sort by value efficiently in PySpark?
I want to sort my K,V tuples by V, i.e. by the value. I know that TakeOrdered is good for this if you know how many you need: Using TakeOrdered: Using Lambda I’ve checked out the question here, which suggests the latter. I find it hard to believe that takeOrdered is so succinct and yet it requires the s…
Python – Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-21ft0H/pandas
I’m using Centos 7 and Python 2.7.5. The problem is when I install Pandas, i got this error message I already tried a lot of solutions but no success even yum -y update. Can’t install via pip because of egg_info error Python pip install fails: invalid command egg_info https://www.digitalocean.com/…
Python functools lru_cache with instance methods: release object
How can I use functools.lru_cache inside classes without leaking memory? In the following minimal example the foo instance won’t be released although going out of scope and having no referrer (other than the lru_cache). But foo and hence foo.big (a BigClass) are still alive That means that Foo/BigClass …