2,204,521 questions
Score of 0
3 answers
52 views
How to compute a gradient column-wise in a pandas DataFrame using the index as an input?
I'd like to compute the gradient of a DataFrame, for which I can gather that the best method is to use .apply(), e.g:
df = pd.DataFrame([[1,2,3],[4,5,6],[7,8,9]])
df = df.apply(np.gradient)
print(df)
...
Score of 0
1 answer
93 views
Preserving whitespace during lxml serialization
is there a way to retain whitespaces when serializing an etree.Element with lxml?
E.g.:
<ph id="af7b8b15-8c62-4be5-a9dc-3c6e7a11b2ed" ctype="x-innovasys-property" innovasys:...
Score of 0
1 answer
76 views
Error when trying to loop through and display SQLite table within HTML page
I'm currently trying to loop through a table from my SQLite database and display it on my Flask web app however none of the data is showing on the HTML page and when trying to query the table I'm ...
Score of 0
2 answers
63 views
How to realize which version of Selenium to use for each Chrome version? [duplicate]
In a web scraping process with Selenium Python, I have written a code including opening a Chrome browser. The code has worked fine for 2 years but suddenly since two days ago stopped working. How I ...
Score of -1
1 answer
87 views
Are imports to the __future__ module cached? [duplicate]
When you import foo in python, foo is added to the sys.modules cache and reused for further imports of foo. I'm curious whether __future__ imports behave the same? If bar imports a __future__ feature ...
Score of -9
0 answers
129 views
Why doesn't Python use a simpler, implied enum syntax? [closed]
Looking at Python enums, a simpler syntax seems to be possible.
Firstly, consider this example using enum from the stdlib:
class Status(IntEnum):
PENDING = 0
COMPLETED = 1
It feels rather ...
Score of -1
0 answers
39 views
Stadia.AlidadeSatellite Not working in folium interactive map [closed]
I have been coding and interactive map in python and folium. For some reason when I try to load Stadia.AlidadeSatellite it doesn't work. I am fairly new to coding so I'm not sure entirely what to do. ...
Score of 5
0 answers
220 views
What does this ",/:" operator mean in Python? [duplicate]
I came across a statement similar to this:
f = lambda x,/: x
What does this ,/: or /: operator mean? Is the above identical to the following?
f = lambda x: x
Score of 3
1 answer
102 views
sklearn.learning_curve(n_jobs=-1) crashes with TerminatedWorkerError in Quarto but not Jupyter
When rendering a Quarto document with jupyter: python3, calling sklearn's learning_curve() with n_jobs=-1 crashes with a TerminatedWorkerError. The same code runs fine in a plain Jupyter notebook.
...
Score of 2
1 answer
133 views
curve_fit() with multiple independent variables in integral function
I am trying to fit a curve with curve_fit() in SciPy using a function with multiple independent variables and multiple fitting parameters.
However, the function is the integral of a single-variable ...
Score of 11
2 answers
256 views
What does annotating a variable do in the Python REPL?
In Python 3.13 I can do this:
>>> x: int
>>>
Which passes. But this raises NameError:
>>> x
Traceback (most recent call last):
File "<stdin>", line 1, in &...
Score of -4
0 answers
93 views
What is this square bracket notation in Python class? [duplicate]
What is the function of '[T]' in this code?
class Box[T]:
def __init__(self, content: T):
self.content = content
And here, why is Box subscripted?
str_box = Box[str]('Python')
Score of -3
1 answer
242 views
When and how should __all__ be defined?
When should a module define __all__ vs using the underscore invention? Should this be done manually or dynamically?
Ideally, we could answer this once and for all with 'write it all out manually' and '...
Score of 0
0 answers
42 views
How to use pydicom auto_format config option
I am trying to use pydicom to store a float as a field DS. It appears that it should be working automagically since issue 1264 has been closed:
https://github.com/pydicom/pydicom/issues/1264
However I ...
Score of 2
1 answer
48 views
NiceGui Upload CSV Error 'UploadEventArguments' object has no attribute 'content'
I am brand-new to NiceGUI and I am trying to learn it for Python by following some tutorials to learn basic features. I have been trying to replicate the CSV file upload and show content by ...