I’m trying to read a txt file from S3 with Spark, but I’m getting thhis error: This is my code: This is the full traceback: How can I fix this? Answer If you are using a local machine you can use boto3: (do not forget to setup your AWS S3 credentials). Another clean solution if you are using an AW…
Position the legend outside the plot area with Bokeh
I am making a plot following the example found here Unfortunately, I have 17 curves I need to display, and the legend overlaps them. I know I can create a legend object that can be displayed outside the plot area like here, but I have 17 curves so using a loop is much more convenient. Do you know how to
OSError 105 : No buffer Space – Zeroconf
I’m using a NanoPi M1 (Allwinner H3 board) & running a Yocto-based OS. On my first encounter with ZeroConf-python, I’m getting the error: This error doesn’t arise when I run it in Raspbian(on RPI). I’ve tried to search for fixes to such errors in homeassistant, but none provide a g…
How to get current user when implementing Python Flask-Security?
I am using Flask-Security to set up user authentication for my app but I am struggling with getting the email address or ID of the currently logged in user so I can query a table with that particular users details. I’ve just using the standard code. Another question here suggested the following but it d…
How can I increase the maximum query time?
I ran a query which will eventually return roughly 17M rows in chunks of 500,000. Everything seemed to be going just fine, but I ran into the following error: Obviously such a query can be expected to take some time; I’m fine with this (and chunking means I know I won’t be breaking any RAM limitat…
Color the shaded area under the curve distribution plot different colors
I’m using seaborn’s kdeplot to draw the distribution of my data. I want to divide the shaded area under the line into three parts, showing the “high” percentile and the “low” percentile. It would be ideal if I can color the shaded area with three different colors. Any idea …
Why does PyQt crashes without information? (exit code 0xC0000409)
I’m trying to develop a software with PyQt, but I often get stuck on software crashes without debug information (only the exit code 0xC0000409). I’m using QThread, and I wrote a system like this: I have crashes when I read/write serialEnabled in run() or in ConnDisconn(). I know that PyQt is not t…
Subclassing Sequence with proper type hints in Python
I’m trying to implement a kind of custom sequence class in Python: Now I want to check that mypy is aware that elements of MySequence are items of type T: So it fails: mypy knows nothing about items of foo. The same example for ordinary Sequence works: If I’m trying to add type annotations to __ge…
In pandas, how to create a new column with a rank according to the mean values of another column
I have the following pandas dataframe I want to create a new column that ranks each of the countries according to the mean of their values from largest to smallest The output would look like the following Note that I don’t need the average column, its just there to help with the explanation. Many thanks…
Display an image in a label without saving it
The following lines are in my script: from PyQt5 import QtGui, QtWidgets, QtCore from PyQt5.QtGui import QIcon, QPixmap from PyQt5.Widgets import * import cv2 def positioningCross(Dy, Dx, center, imgCross): if(center[1,0]>=center[0,0]): Dy2 = center[0,0] + np.absolute(Dy) else: Dy2 = center[1,0] + np.absol…