QuestionId int64 74.8M 79.8M | UserId int64 56 29.4M | QuestionTitle stringlengths 15 150 | QuestionBody stringlengths 40 40.3k | Tags stringlengths 8 101 | CreationDate stringdate 2022-12-10 09:42:47 2025-11-01 19:08:18 | AnswerCount int64 0 44 | UserExpertiseLevel int64 301 888k | UserDisplayName stringlengths 3 30 ⌀ |
|---|---|---|---|---|---|---|---|---|
75,052,865 | 4,740,661 | How to use a variable as value of replace function in python pandas | <p>I have such dataframe where the column <code>body</code> has image path that I want to replace with the corresponding baseUrl + <code>id</code> + .webp</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
df = pd.DataFrame({ 'id': ["982951473","000590051"],
... | <python><pandas> | 2023-01-09 03:13:19 | 1 | 1,027 | Ax_ |
75,052,604 | 18,059,131 | RefreshError ('invalid_grant: Token has been expired or revoked.') Google API | <p>About a week ago I set up an application on google. Now when I tri and run:</p>
<pre><code>SCOPES = ['https://www.googleapis.com/auth/gmail.readonly']
creds = None
if os.path.exists('token.pickle'):
with open(self.CREDENTIALS_PATH+self.conjoiner+'token.pickle', 'rb') as token:
creds = pickle.load(token)... | <python><google-api><google-oauth><gmail-api><google-api-python-client> | 2023-01-09 02:07:34 | 2 | 318 | prodohsamuel |
75,052,440 | 9,357,484 | WEKA's performance on nominal dataset | <p>I used <em>WEKA</em> for classification. I used the <em>breast cancer</em> dataset which is available in <em>WEKA</em> data folder. The data set is a nominal dataset. The .arff file can be found <a href="https://github.com/tertiarycourses/Weka/blob/master/Weka%20datasets/breast-cancer.arff" rel="nofollow noreferrer"... | <python><machine-learning><scikit-learn><weka><naivebayes> | 2023-01-09 01:24:14 | 1 | 3,446 | Encipher |
75,052,425 | 6,346,514 | Python, Loop to reading in Excel file sheets, change header row number | <p>I have a loop that counts the rows in each sheet of an xls. When I open the xls itself the count is not aligning with what python is returning me.</p>
<p>It is due to the first sheet header being in row 3. How can I alter my code to read the first sheet ONLY in at row 3 and ignore the first two lines? The rest of my... | <python> | 2023-01-09 01:18:39 | 1 | 577 | Jonnyboi |
75,052,366 | 851,699 | How do I to save a stateful TFLite model where shape of state depends on input? | <p>I'm trying to do something fairly simple in tensorflow-lite, but I'm not sure it's possible.</p>
<p>I want to define a stateful graph where the shape of the state variable is defined when model is LOADED, not when it's saved.</p>
<p>As a simple example - lets say I just want to compute a temporal difference - ie. a ... | <python><tensorflow><tensorflow-lite><tflite> | 2023-01-09 01:00:19 | 1 | 13,753 | Peter |
75,052,226 | 7,317,408 | ValueError: time data '2018-02-22' does not match format '%m-%d-%Y' when using https://stocknewsapi.com/ | <p>I have a bunch of daily data in ohlc format:</p>
<pre><code> index date symbol open high low close volume vwap previous_close change_1_day
0 7896 2018-02-22 CHK 2.870 3.330 2.86 3.20 130538189 3.109534 2.6300 21.673004
1 8108 2018-12-26 CHK... | <python><pandas><numpy> | 2023-01-09 00:19:08 | 1 | 3,436 | a7dc |
75,052,206 | 1,330,719 | Specifying Huggingface model as project dependency | <p>Is it possible to install huggingface models as a project dependency?</p>
<p>Currently it is downloaded automatically by the <code>SentenceTransformer</code> library, but this means in a docker container it downloads every time it starts.</p>
<p>This is the model I am trying to use: <a href="https://huggingface.co/s... | <python><docker><python-poetry><huggingface> | 2023-01-09 00:13:17 | 1 | 1,269 | rbhalla |
75,052,167 | 10,098,394 | VLC-python don't read my mp4 video online | <p>I'm just looking for a way to read video from internet with Vlc-python.
i have just a very simple script but it does not work with my video and i don't understand why it's working for some link and why not others...</p>
<pre><code># importing vlc module
import vlc
# creating vlc media player object
media_player ... | <python><stream><streaming><vlc> | 2023-01-09 00:02:23 | 0 | 421 | Ronaldonizuka |
75,051,936 | 1,777,331 | Is there an advantage to Lambda Powertools’s Parser over straight Pydantic? | <p>I’ve got models which inherit Pydantic’s BaseModel and I use this to define my model attributes and do some validation.</p>
<p>But I see that <a href="https://awslabs.github.io/aws-lambda-powertools-python/2.5.0/utilities/parser/#install" rel="nofollow noreferrer">Lambda Powertools comes with a Parser</a> module whi... | <python><amazon-web-services><pydantic> | 2023-01-08 23:08:44 | 1 | 4,420 | Tom Harvey |
75,051,894 | 1,330,719 | Pytest slow in docker container taking 75s+ for about 15 tests | <p>I have a simple dockerfile that does the following:</p>
<pre><code>FROM python:3.10.3
RUN pip install -U pip setuptools
RUN pip install poetry==1.1.11
WORKDIR /srv
</code></pre>
<p>I am using docker compose to mount the relevant directory, but will ignore that here. I am then running this command to run tests in 1... | <python><docker><pytest> | 2023-01-08 22:59:07 | 0 | 1,269 | rbhalla |
75,051,852 | 13,509,355 | How do I enable Python command history editing in bash under virtual environments | <p>I want to use history recall and command line editing in the python shell.</p>
<p>However, for virtual environments this does not work by default. For example using</p>
<pre><code>python3 -v venv env
source env/bin/activate
</code></pre>
<p>and then invoking the python interpreter</p>
<pre><code>python
</code></pre>... | <python><virtual-environment> | 2023-01-08 22:50:34 | 1 | 743 | Neil Bartlett |
75,051,776 | 726,730 | pywinauto save (permant) control identifiers to variable | <p>I am trying to save control identifiers to a variable.
The reason is that: i use <code>main_dlg.print_control_identifiers(filename="control_ids.text")</code> but i am getting this error:</p>
<pre><code>Traceback (most recent call last):
File "run_tests.py", line 7, in <module>
main_dl... | <python><automation><pywinauto> | 2023-01-08 22:38:19 | 0 | 2,427 | Chris P |
75,051,724 | 3,976,494 | Pandas: return first row where column value satisfies condition against a list of values | <p>I have a dataframe <code>df</code> and a list of floats <code>T</code>. <code>df.B</code> is a time series of values sorted in chronological order, where the 0th index is the most recent timestamp and the last index is the oldest timestamp.</p>
<pre class="lang-py prettyprint-override"><code>df = pd.DataFrame({'A': ... | <python><pandas><dataframe> | 2023-01-08 22:31:24 | 1 | 702 | Hunter |
75,051,590 | 11,505,813 | Remove first 5 from numbers in a list? | <p>I have a list with numbers like this :-</p>
<pre><code>s = [5542, 5654, 7545]
</code></pre>
<p>The goal is to remove the first 5 from the number such that the resultant list is like this</p>
<pre><code>s = [542, 654, 745]
</code></pre>
<p>What's the best way to achieve the following without using any external librar... | <python> | 2023-01-08 22:02:31 | 2 | 1,388 | Somethingwhatever |
75,051,422 | 20,443,528 | How to 'check' a value in a radio button by default in Django? | <p>I wrote a model form. I used widgets to make radio buttons and I want a particular radio button to be checked by default while rendering the form in my html file.</p>
<p>Model:</p>
<pre><code>class Room(models.Model):
class Meta:
number = models.PositiveSmallIntegerField()
CATEGORIES = (
('Regul... | <python><django><django-models><django-forms><django-widget> | 2023-01-08 21:24:55 | 1 | 331 | Anshul Gupta |
75,051,370 | 6,346,514 | Python, Len not counting rows correctly | <p>I have a loop that counts the rows in each sheet of an xls. When i open the xls itself the count is not exactly aligning with what python is returning me.</p>
<pre><code>row_counts = []
for sheet in list(data_mapping.keys()):
row_counts.append(len(data_mapping.get(sheet)))
print(len(data_mapping.get(sheet)))... | <python> | 2023-01-08 21:17:20 | 1 | 577 | Jonnyboi |
75,051,327 | 1,128,695 | Change month labels in matplotlib without changing the locale | <p>With this plot as an example:
<a href="https://i.sstatic.net/2bawL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2bawL.png" alt="enter image description here" /></a></p>
<p>With the code:</p>
<pre><code>import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.cbook as cboo... | <python><matplotlib> | 2023-01-08 21:11:39 | 2 | 1,197 | PerseP |
75,051,207 | 4,348,534 | pyautogui.write() not automatically using shift to type characters on non-english keyboard | <p>I'm trying to automate the uploading of a file to a website. Using <code>selenium</code> to navigate the website, I got to the point where I get the prompt box to input the filename:</p>
<p><a href="https://i.sstatic.net/p6ELl.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/p6ELl.jpg" alt="Upload prom... | <python><pyautogui> | 2023-01-08 20:53:24 | 1 | 4,297 | François M. |
75,050,886 | 1,698,678 | Signing a string with an RSA key in Python - how can I translate this JavaScript code that uses SubtleCrypto to Python? | <p>I am trying to sign a string with an RSA key in Python. I have working JavaScript code that does it, but now I need to replicate it in Python using Python-RSA.</p>
<p>In particular, these are the two JavaScript calls that I need to deal with:</p>
<pre><code>const key = await crypto.subtle.importKey(
'raw',
bytesOfSe... | <javascript><python><rsa><subtlecrypto> | 2023-01-08 20:03:18 | 1 | 1,504 | PlinyTheElder |
75,050,590 | 18,758,062 | Error using Pytorch nn.Sequential: RuntimeError: mat1 and mat2 shapes cannot be multiplied | <p>After I try to clean up my working code to use <code>nn.Sequential</code>, I start to get the error when doing a forward pass</p>
<blockquote>
<p>RuntimeError: mat1 and mat2 shapes cannot be multiplied (64x49 and 3136x512)</p>
</blockquote>
<p>This is likely because during my original forward pass, I did this in the... | <python><pytorch><neural-network> | 2023-01-08 19:13:05 | 1 | 1,623 | gameveloster |
75,050,436 | 5,736,438 | Why is Scipy.linalg.eigh much slower when using np.complex64? | <p>I have a large Hermitian matrix of which I need to calculate the eigenvalues and eigenvectors. For this I use <code>scipy.linalg.eigh</code>. Above a certain size of the matrix, scipy is much faster if <code>np.complex128</code> is used as data type instead of <code>np.complex64</code>.</p>
<p>If I use <code>np.comp... | <python><numpy><scipy><blas><eigenvector> | 2023-01-08 18:48:28 | 0 | 1,062 | Peter234 |
75,050,435 | 11,693,768 | Python pandas drop columns if their partial name is in a list or column in pandas | <p>I have the following dataframe called <code>dropthese</code>.</p>
<pre><code> | partname | x1 | x2 | x3....
0 text1_mid1
1 another1_mid2
2 yet_another
</code></pre>
<p>And another dataframe called <code>df</code> that looks like this.</p>
<pre><code> text1_mid1_suffix1 | text1_mid1_suf... | <python><pandas><filter> | 2023-01-08 18:48:18 | 1 | 5,234 | anarchy |
75,050,419 | 41,174 | python - mock - class method mocked but not reported as being called | <p>learning python mocks here. I need some helps to understand how the <em>patch</em> work when mocking a class.</p>
<p>In the code below, I mocked a class. the function under tests receives the mock and calls a function on it. In my assertions, the class is successfully called, but the function is reported as not bein... | <python><unit-testing><mocking><python-unittest><python-unittest.mock> | 2023-01-08 18:45:56 | 1 | 1,362 | Jean-Francois |
75,050,371 | 9,784,909 | Difficulty Importing Fonts in Python FPDF package | <p>I'm having a tough time trying to get something working which I think should be straightforward.</p>
<p>I'm new to python and learning via projects which in this case is a simple PDF generator. I want to add custom fonts to my program (Poppins) and I can get it to work if I include the fonts in the exact location as... | <python><fpdf> | 2023-01-08 18:35:16 | 1 | 403 | Tom E |
75,050,364 | 6,372,226 | More pythonic way to filter objects from a list of dicts based on a dict value that must not contain a string from a list of strings | <p>As I'm coming from Java, I wonder if there is a more pythonic approach to achieve the following logic:</p>
<pre><code>movies = [{'original_title': 'Star Wars'}, {'original_title': 'Avengers'}, {'original_title': 'After Love'}]
blacklist = ['Star', 'Love']
filtered_movies = []
for movie in movies:
blacklisted = ... | <python><list><dictionary><filter> | 2023-01-08 18:34:19 | 3 | 384 | XDAF |
75,050,310 | 558,619 | Python: Dynamically add properties to class instance, properties return function value with inputs | <p>I've been going through all the Stackoverflow answers on dynamic property setting, but for whatever reason I can't seem to get this to work.</p>
<p>I have a class, <code>Evolution_Base</code>, that in its <code>init</code> creates an instance of <code>Value_Differences</code>. <code>Value_Differences</code> should b... | <python> | 2023-01-08 18:24:12 | 10 | 3,541 | keynesiancross |
75,049,933 | 3,132,844 | How to interpolate values in non-rectangular coordinates using Python? | <p>I need to make compensation of values in my optical system using Python. I've measured the dependency of my compensation params in the corners of my table and I want to interpolate such value there linearly, but a map is not a rectangle.
Example:</p>
<pre><code># Corners coordinates:
a_real = (45, 45)
a_coeff = (33... | <python><numpy><scipy><coordinate-transformation> | 2023-01-08 17:28:03 | 1 | 1,494 | artsin |
75,049,862 | 338,479 | Minimal implementation of a "file-like" object? | <p>I want to create a file-like object to be passed to another module. I don't know if that other module will be calling read() or readline() or both. If I were to subclass say <code>io.IOBase</code> and just implement <code>read()</code> would that be sufficient, even if the client is calling <code>readline()</code>?<... | <python><file> | 2023-01-08 17:18:41 | 1 | 10,195 | Edward Falk |
75,049,828 | 997,832 | Tensorflow - Text Classification - Shapes (None,) and (None, 250, 100) are incompatible error | <p>I want to classify text with multiple labels. I use TextVectorization layer and CategoricalCrossEntropy function. Here is my model code:</p>
<p>Text Vectorizer:</p>
<pre><code>def custom_standardization(input_data):
print(input_data[:5])
lowercase = tf.strings.lower(input_data)
stripped_html = tf.strings.regex... | <python><tensorflow><deep-learning> | 2023-01-08 17:14:23 | 1 | 1,395 | cuneyttyler |
75,049,808 | 3,507,584 | Django postgres "No migrations to apply" troubleshoot | <p>I had to modify the table of my app so I dropped it from postgres database (using <code>objectname.objects.all().delete()</code> in django python shell and with postgres at PGAdmin).</p>
<p>I deleted the appname <code>migrations</code> folder. When I run python <code>manage.py makemigrations appname</code>, the fold... | <python><django><postgresql><django-migrations> | 2023-01-08 17:11:31 | 2 | 3,689 | User981636 |
75,049,684 | 1,172,439 | boxplot scatterplot from r to python | <p>I am trying to port some code from R to python, but I am encountering some difficulties with plotting.</p>
<p>The simplest example I can give is the following:</p>
<pre><code>library(ggplot2)
df1=data.frame(a_class=letters[1:10], vals=sample(10, replace=TRUE))
ggplot(df1, aes(x=0, y=vals))+
geom_boxplot()+
the... | <python><r><matplotlib><ggplot2><seaborn> | 2023-01-08 16:56:18 | 0 | 947 | Fabrizio |
75,049,548 | 552,563 | Why can't you intern bytes in Python? | <p>As mentioned in Python documentation, <a href="https://docs.python.org/3/library/sys.html?highlight=intern#sys.intern" rel="nofollow noreferrer"><code>sys.intern()</code></a> only accepts string objects. I understand why mutable types are not supported by <code>sys.intern</code>. But there's at least one more immuta... | <python> | 2023-01-08 16:38:29 | 1 | 3,011 | Alex Bochkarev |
75,049,502 | 15,825,321 | XGBoost prediction input dimensionality error | <p>I have the following model:</p>
<pre><code>X_train_xgb, X_test_xgb, y_train_xgb, y_test_xgb = X_train.values, X_test.values, y_train.values, y_test.values
xgb_model = xgboost.XGBRegressor()
xgb_model.fit(X_train_xgb, y_train_xgb)
</code></pre>
<p>X_train and X_test have the same count of columns. However, running</... | <python><numpy><multidimensional-array><xgboost> | 2023-01-08 16:33:16 | 0 | 303 | Paul1911 |
75,049,265 | 9,855,588 | unable to mock global variable assigned to function call python pytest | <p>When I run my pytest and mock patch a global variable in the python file that has a function call assigned to capture the output, I'm unable to mock it (I dont want to actually execute the function during tests). I find that the function is still getting called. How can I prevent it from being called?</p>
<pre><code... | <python><python-3.x><pytest><pytest-mock> | 2023-01-08 16:03:00 | 1 | 3,221 | dataviews |
75,049,127 | 3,451,339 | Resize any image to 512 x 512 | <p>I am trying to train a stable diffusion model, which receives <code>512 x 512</code> images as inputs.</p>
<p>I am downloading the bulk of images from the web, and they have multiple sizes and shapes, and so I need to preprocess them and convert to <code>512 x 512</code>.</p>
<p>If I take this <code>2000 × 1434</cod... | <python><python-imaging-library><stable-diffusion> | 2023-01-08 15:44:29 | 1 | 10,121 | 8-Bit Borges |
75,049,077 | 1,436,800 | How to create a single API which takes data of all Employees | <p>I am new to django. I have a model like this:</p>
<pre><code>class Standup(models.Model):
team = models.ForeignKey("Team", on_delete=models.CASCADE)
standup_time = models.DateTimeField(auto_now_add=True)
class StandupUpdate(models.Model):
standup = models.ForeignKey("Standup", on_de... | <python><django><django-models><django-rest-framework><django-views> | 2023-01-08 15:37:27 | 1 | 315 | Waleed Farrukh |
75,048,983 | 4,845,935 | Can I mock sqlite3 CURRENT_TIMESTAMP in Python tests? | <p>I want to return custom value for SQLite3 CURRENT_TIMESTAMP in my Python tests by mocking the return value (without interfering system clock).</p>
<p>I discovered <a href="https://stackoverflow.com/questions/27499411/sqlite-can-i-mock-the-current-time-now-for-testing">this answer</a> but it doesn't work for CURRENT_... | <python><sqlite><unit-testing> | 2023-01-08 15:26:32 | 2 | 874 | dimnnv |
75,048,909 | 5,359,846 | How to make sure text inside a column is fully visible using Playwright? | <p>I have a table in my web page. Let us assume that one of the columns has a very long text, and the column is at its default width.</p>
<pre><code>expect(self.page.locator('text=ABCDEFGHIJKLMNOPQRSTUVWXYZ')).\
to_be_visible(timeout=20 *1000)
</code></pre>
<p>The code passes, as <code>Playwright</code> can find the te... | <python><playwright><playwright-python> | 2023-01-08 15:15:49 | 0 | 1,838 | Tal Angel |
75,048,860 | 7,155,895 | Resize images while preserving aspect ratio | <p>I have a small problem that could have a simple solution, but unfortunately I'm not very good at math.</p>
<p>I have three images that need to be stacked on top of each other and their heights add up to more than the screen height.</p>
<p>So to fix, I did a simple proportion and changed the height of the three image... | <python><python-3.x><math><pygame><python-3.9> | 2023-01-08 15:09:25 | 1 | 579 | Rebagliati Loris |
75,048,782 | 18,753,528 | How to sequence numbers in text while looping | <p>I'm trying to reach a way to print numbers in a specific way but I can't, my code here</p>
<pre><code>for i in range(7): # 7 it could be a string length for an example
print("letter"+str(i)+",letter"+str(i+1)+"|letter"+str(i+1)+",letter"+str(i+2)+";")
</code></pr... | <python> | 2023-01-08 14:59:07 | 4 | 875 | IVs |
75,048,688 | 17,267,064 | PicklingError: Could not serialize object: IndexError: tuple index out of range | <p>I initiated pyspark in cmd and performed below to sharpen my skills.</p>
<pre><code>C:\Users\Administrator>SUCCESS: The process with PID 5328 (child process of PID 4476) has been terminated.
SUCCESS: The process with PID 4476 (child process of PID 1092) has been terminated.
SUCCESS: The process with PID 1092 (chi... | <python><apache-spark><pyspark><rdd> | 2023-01-08 14:47:42 | 3 | 346 | Mohit Aswani |
75,048,619 | 18,749,472 | Django - stop logout with javascript pop-up confirm box | <p>In my django site I have a logout button that redirects to the view <code>logout</code>. When the button is clicked it instantly logs the user out, but I would like a JS pop-up confirm box to appear then the logout button is clicked.</p>
<p>When the user clicks 'Ok' OR 'Cancel' it logs the user out. How can i preven... | <javascript><python><django><django-views><popup> | 2023-01-08 14:38:15 | 1 | 639 | logan_9997 |
75,048,611 | 10,480,181 | How to prevent subprocess.run() output? | <p>I am using the subprocess module to create some directories. However in some cases the same command might be creating directories in restricted directories. In such cases I get an output to the console: <code>mkdir: cannot create directory 'location/to/directory': Permission denied</code></p>
<p>How to avoid this ou... | <python><python-3.x><subprocess><stdout> | 2023-01-08 14:37:03 | 1 | 883 | Vandit Goel |
75,048,481 | 3,247,006 | How to use local, non-local and global variables in the same inner function without errors in Python? | <p>When trying to use <strong>the local and non-local variables <code>x</code></strong> in <code>inner()</code> as shown below:</p>
<pre class="lang-py prettyprint-override"><code>x = 0
def outer():
x = 5
def inner():
x = 10 # Local variable
x += 1
print(x)
nonlocal x # ... | <python><global-variables><local-variables><python-nonlocal><inner-function> | 2023-01-08 14:22:11 | 1 | 42,516 | Super Kai - Kazuya Ito |
75,048,422 | 11,133,602 | cibuildwheel - CIBW_BEFORE_ALL not working as expected and cannot find installed module | <p>Here's the GitHub Actions job that uses to build wheel for a Python module with C++ code, (bound using the <code>pybind11</code> module):</p>
<pre class="lang-yaml prettyprint-override"><code>
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
# if: ${{ github.event.workflow_run.conclusion == 'succ... | <python><github-actions><python-module> | 2023-01-08 14:11:48 | 1 | 1,096 | Teddy C |
75,048,344 | 7,959,614 | Get ranking within Pandas.DataFrame with ties as possibility | <p>I have the following example</p>
<pre><code>import pandas as pd
names = ['a', 'b', 'c', 'd', 'e']
points = [10, 15, 15, 12, 20]
scores = pd.DataFrame({'name': names,
'points': points})
</code></pre>
<p>I want to create a new column called <code>position</code> that specifies the relative pos... | <python><pandas> | 2023-01-08 14:01:01 | 1 | 406 | HJA24 |
75,048,233 | 7,665,821 | MSVC/VS is not detecting any Windows SDK related things - includes, libraries etc | <p>I installed Visual Studio Build Tools 2022 from the official website, checking the "C++ desktop development" box. It installed successfully. However, when I try to use it to compile some Python library, various errors thrown by the compiler shows that MSVC is not aware of any Windows SDK related files on m... | <python><windows><visual-c++> | 2023-01-08 13:45:13 | 0 | 381 | Billy Cao |
75,047,803 | 12,871,587 | Polars read_excel set option to include filtered rows | <p>I've noticed that the Polars read_excel/Xlsx2csv doesn't include rows that are filtered in excel file(s). However, there is an option in Polars read_csv to set xlsx2csv options (xlsx2csv_options: dict[str, Any]).</p>
<p>I've tried to check from Xlsx2csv documentation whether there would be such an option, but couldn... | <python><python-polars> | 2023-01-08 12:37:22 | 0 | 713 | miroslaavi |
75,047,681 | 5,362,515 | Socket programming: How does client get access to its IP adress and port? | <p>Just started learning about socket programming using Python. To create server, we do something like this:</p>
<pre><code>sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('localhost', 10000)
sock.bind(server_address)
sock.listen(1)
while True:
connection, client_address = sock.accept()
... | <python><sockets><network-programming> | 2023-01-08 12:18:42 | 0 | 327 | mayankkaizen |
75,047,527 | 9,328,846 | How to add a new column to dataframe based on conditions on another column | <p>I have the following example dataframe:</p>
<pre><code>d = {'col1': [4, 2, 8, 4, 3, 7, 6, 9, 3, 5]}
df = pd.DataFrame(data=d)
df
col1
0 4
1 2
2 8
3 4
4 3
5 7
6 6
7 9
8 3
9 5
</code></pre>
<p>I need to add <code>col2</code> to this dataframe, and values of this new column will be set by comp... | <python><python-3.x><pandas><dataframe><rolling-computation> | 2023-01-08 11:54:06 | 1 | 2,201 | edn |
75,047,412 | 7,093,241 | Is there a way to use filter() to return a modified value with a lambda? | <p>I was trying to check for palindromes and wanted to eliminate non alphanumeric characters. I can use filter for this like so:</p>
<pre><code>filteredChars = filter(lambda ch: ch.isalnum(), s)
</code></pre>
<p>However, I also need to compare with the same case so I would really like to get is <code>ch.lower</code> so... | <python> | 2023-01-08 11:34:18 | 3 | 1,794 | heretoinfinity |
75,047,366 | 3,179,765 | How to deal with non-English characters and spaces in filename in python? | <p>I want to download some files from gdrive with a python script. Files contain spaces and nonEnglish characters and I want to save them exactly with the same names. I try to create a similar file with spaces and special characters, but python gives me always
<code>OSError: [Errno 22] Invalid argument:</code>:</p>
<pr... | <python> | 2023-01-08 11:26:26 | 0 | 705 | Mubin Icyer |
75,047,291 | 3,247,006 | How can the most inner function access the non-local variable in the most outer function in Python? | <p><code>inner()</code> can access <strong>the non-local variable <code>x</code></strong> in <code>middle()</code> with <code>nonlocal x</code>:</p>
<pre class="lang-py prettyprint-override"><code>def outer():
x = 0
def middle():
x = 5 # <- Here
def inner():
nonlocal x # Here
... | <python><variables><nested-function><python-nonlocal><inner-function> | 2023-01-08 11:11:08 | 1 | 42,516 | Super Kai - Kazuya Ito |
75,047,238 | 18,972,785 | Why backslash ( \ ) causes ValuesError when using CDLIB? | <p>I am working on community detection algorithms on graphs. I have an edge list that its nodes are strings such as: names, addresses,IDs and ,...
There was something interesting with edge list. When there is backslash ( \ ) in edgelist such as <code>\template1\ </code> the program raises this Error: <code>ValueError: ... | <python><graph> | 2023-01-08 11:02:16 | 0 | 505 | Orca |
75,046,988 | 3,131,604 | Building tensorflow-text=2.11.0 from source fails with "rev: command not found" on Windows | <p>As you may know, after version 2.10, tensorflow-text is not be provided as a pip package on windows.</p>
<p>I tried to follow the Build from source procedure at <a href="https://github.com/tensorflow/text#build-from-source-steps" rel="nofollow noreferrer">https://github.com/tensorflow/text#build-from-source-steps</a... | <python><tensorflow2.0> | 2023-01-08 10:21:12 | 1 | 7,433 | u2gilles |
75,046,899 | 19,838,445 | Does function know about the class before binding | <p>Is there a way to access a class (where function is defined as a method) before there is an instance of that class?</p>
<pre class="lang-py prettyprint-override"><code>class MyClass:
def method(self):
print("Calling me")
m1 = MyClass.method
instance = MyClass()
m2 = instance.method
print(m2._... | <python><methods><metaprogramming><python-descriptors> | 2023-01-08 10:02:15 | 2 | 720 | GopherM |
75,046,837 | 3,482,266 | How can I preserve search efficiency, and reduce RAM usage of a dictionary container? | <p>I'm keeping a record of what I'm calling <code>profile</code>s.</p>
<p>Each <code>profile</code> is a tuple of dictionaries: <code>(Dict,Dict)</code>, and we can associate to it a unique <code>id</code>(may include characters like <code>_</code> or <code>-</code>).</p>
<p>I need to keep them in RAM memory for a cert... | <python> | 2023-01-08 09:51:04 | 0 | 1,608 | An old man in the sea. |
75,046,764 | 12,167,384 | max() with key argument python | <p>I know a bit about how <code>key</code> argument is used in python <code>max()</code>. <code>max(("pyth", "lua", "ruby"), key=len)</code> will return <code>pyth</code> and <code>ruby</code>. However, <code>max((31, 13, 11), key=lambda x: sum(int(i) for i in str(x)))</code> will only giv... | <python><max> | 2023-01-08 09:40:35 | 3 | 336 | uoay |
75,046,746 | 1,181,482 | python: how to find name of currently evaluating argument during function call | <p>given the code example below: how can I get the name of argument corresponding to particular evaluation of function get_arg_val.</p>
<pre><code>def do_sum(a, b, c):
return a + b + c
def get_arg_val():
print("call f") # what argument this call corresponds to: a, b or c ???
return 1
x = do_sum... | <python><python-3.x><parameter-passing><introspection><function-call> | 2023-01-08 09:37:29 | 0 | 2,612 | lowtech |
75,046,723 | 5,869,076 | Execute statement only once in Python | <p>I'm running a periodic task on Celery that executes the same code once every 3 minutes. If a condition is True, an action is performed (a message is sent), but I need that message to be sent only once.</p>
<p>The ideal would be that that message, if sent, it could not be sent in the next 24 hours (even though the fu... | <python><python-3.x><celery> | 2023-01-08 09:33:31 | 2 | 611 | Jim |
75,046,635 | 8,844,732 | Subplot multiple combination of categories in python | <p>I have the following example dataset where 'Type1 has 2 categories 'A' and 'B' and 'Type2' has 3 categories 'Red', 'Blue', and ' Green'. I would like to plot 3 subplots where subplot 1 has 'Type1', subplot 2 has 'Type2' and subplot3 has the combination of 'Type1' and 'Type2'. The x axis is the 'Time' and the y axis ... | <python><pandas><matplotlib> | 2023-01-08 09:16:52 | 1 | 423 | non_linear |
75,046,568 | 20,800,676 | Why does pylint raises this error: Parsing failed: 'cannot assign to expression here. Maybe you meant '==' instead of '='? | <p>While solving some exercises from the "Impractical Python Projects" book I've encountered this error:</p>
<pre><code>myconfig.pylintrc:6:1: E0001: Parsing failed: 'cannot assign to expression here. Maybe you meant '==' instead of '='? (<unknown>, line 6)' (syntax-error)
</code></pre>
<p>The error occ... | <python><python-3.x><pylint><pylintrc> | 2023-01-08 09:03:20 | 1 | 541 | Sigmatest |
75,046,502 | 5,130,783 | Python floating-point equations | <p>I want to know how to make floating-point equations correctly in Python3.</p>
<p>I am trying to solve a linear equation problem and have variables and statements below.</p>
<pre class="lang-py prettyprint-override"><code>slope = float(70 / 23)
c = 9
(slope * -161) + c == -481 # False
print((slope * -161) + c) # -481... | <python><floating-point> | 2023-01-08 08:49:53 | 0 | 1,679 | Changnam Hong |
75,046,444 | 4,053,840 | Run python tests from different files in parrallel? | <p>I am working on integration tests, written in python and run with pytest.
They are defined/written in different python files, but all these tests are executed sequentially.
Part of the tests include testing of starting and stopping of machines, and this takes a while.
That is why i want to run the start/stopping tes... | <python><parallel-processing><pytest> | 2023-01-08 08:36:59 | 1 | 483 | Ivajlo Iliev |
75,046,434 | 11,995,121 | wxpython RuntimeError: super-class __init__() of type MainMenuBar was never called when instantiating class | <p>I am trying to import MainMenuBar class from filemenu.py to my main class and instantiate it in my main class init method in wxPython but I am getting error</p>
<pre><code>RuntimeError: super-class __init__() of type MainMenuBar was never called
</code></pre>
<p>Here is my main class</p>
<pre><code>import os
import ... | <python><class><wxpython><instantiation><init> | 2023-01-08 08:35:05 | 2 | 454 | HotWheels |
75,046,293 | 13,789,467 | Cannot run selenium test | <p>I am new to automation testing. Currently downloaded selenium 4 and trying to automate login into a sample site.Please help me with this. Been struggling all day in this. And I can't even understand my error messages in the console<a href="https://i.sstatic.net/lBD2S.png" rel="nofollow noreferrer"><img src="https://... | <python><selenium><selenium-webdriver><selenium-chromedriver><webdriverwait> | 2023-01-08 08:04:21 | 2 | 319 | Prashant Mishra |
75,046,236 | 194,888 | Why is this map_elements() custom function slower in Polars than apply() in Pandas | <p>I ran the following in a Jupyter Notebook and was disappointed that similar Pandas code is faster. Hoping someone can show a smarter approach in Polars.</p>
<p>POLARS VERSION</p>
<pre class="lang-py prettyprint-override"><code>def cleanse_text(sentence):
RIGHT_QUOTE = r"(\u2019)"
sentence = re.sub(... | <python><dataframe><python-polars> | 2023-01-08 07:51:07 | 1 | 616 | Biosopher |
75,046,225 | 6,357,916 | Why python code with list comprehension take less time than the one without? | <p>I wrote following code:</p>
<pre><code>def meth3(history_list, fromDate, toDate):
active = {}
chart_data = [0] * (daysDiff + 1)
activityData = [(_activityData.user_id, timezone.localtime(_activityData.last_save_time).date())
for item in history_list for _activityData in item.use... | <python><python-3.x><list-comprehension> | 2023-01-08 07:48:58 | 0 | 3,029 | MsA |
75,046,073 | 17,275,588 | Python + Open AI/GPT3 question: Why is part of my prompt spilling into the responses I receive? | <p>This happens to probably 10% of responses I get. For whatever reason, the last bits of my prompt somehow spill into it, at the start of it. Like there will be a period, or a question mark, or sometimes a few of the last letters from the prompt, that get removed from the prompt, and somehow find their way into BOTH t... | <python><machine-learning><artificial-intelligence><gpt-3> | 2023-01-08 07:16:08 | 1 | 389 | king_anton |
75,045,732 | 14,358,677 | html to pdf on Azure using pdfkit with wkhtmltopdf | <p>I'm attempting to write an Azure function which converts an html input to pdf and either writes this to a blob and/or returns the pdf to the client. I'm using the <a href="https://pypi.org/project/pdfkit/" rel="nofollow noreferrer">pdfkit</a> python library. This requires the wkhtmltopdf executable to be available.<... | <python><azure><azure-functions><wkhtmltopdf><html-to-pdf> | 2023-01-08 05:39:09 | 1 | 2,769 | Anupam Chand |
75,045,588 | 19,238,204 | Python3 Matplotlib to Show Solid of Revolution from Method of Disks, Method of Shells, and Method of Washers around x-axis and y-axis | <p>I have created this topic before: <a href="https://stackoverflow.com/questions/74970235/how-to-add-another-subplot-to-show-solid-of-revolution-toward-x-axis/74972856#74972856">How to Add another subplot to show Solid of Revolution toward x-axis?</a></p>
<p>I want to plot the solid from a curve 3 + 2x - x^2 that is r... | <python><python-3.x><numpy><matplotlib> | 2023-01-08 04:58:11 | 0 | 435 | Freya the Goddess |
75,045,285 | 17,696,880 | Put "0" in front of numeric quantities within a string that are missing a numeric figure following the context of a regex pattern | <pre class="lang-py prettyprint-override"><code>import re
input_text = '2000_-_9_-_01 8:1 am' #example 1
input_text = '(2000_-_1_-_01) 18:1 pm' #example 2
input_text = '(20000_-_12_-_1) (1:1 am)' #example 3
identificate_hours = r"(?:a\s*las|a\s*la|)\s*(\d{1,2}):(\d{1,2})\s*(?:(am)|(pm)|)"
date_format_0... | <python><regex><datetime> | 2023-01-08 03:18:02 | 1 | 875 | Matt095 |
75,045,199 | 344,669 | pytest patch generate exception for Class method call | <p>I am testing the generating mock exception using <code>side_effect</code>. based on this page <a href="https://changhsinlee.com/pytest-mock/" rel="nofollow noreferrer">https://changhsinlee.com/pytest-mock/</a> I am trying to generate the exception when calling <code>load_data</code> method, but its not working for m... | <python><python-3.x><pytest><pytest-mock> | 2023-01-08 02:47:33 | 2 | 19,251 | sfgroups |
75,045,161 | 1,014,385 | How can we make pandas default handling of missing values warn of their presence rather than silently ignore them? | <p>As discussed <a href="https://stackoverflow.com/questions/73615856/does-pandas-current-treatment-of-missing-values-have-potential-to-cause-serious">here</a>, pandas silently replaces <code>NaN</code> values with 0 when calculating sums, in contrast to explicit calculations as shown here:</p>
<pre class="lang-py pret... | <python><pandas><missing-data> | 2023-01-08 02:34:04 | 1 | 912 | David Lovell |
75,045,158 | 5,212,614 | Trying to scrape a specific table but getting no results | <p>I tried three different techniques to scrape a table named 'table-light', but nothing is actually working for me. The code below shows my attempts to extract the data.</p>
<pre><code>import pandas as pd
tables = pd.read_html('https://finviz.com/groups.ashx?g=industry&v=120&o=marketcap')
tables
############... | <python><python-3.x><beautifulsoup> | 2023-01-08 02:32:52 | 1 | 20,492 | ASH |
75,045,016 | 11,462,274 | If the value of a specific column from a previous date is greater than zero then True, less than or equal to zero is False | <pre class="lang-none prettyprint-override"><code>,clock_now,competition,market_name,lay,per_day
0,2022-12-30,A,B,-1.0,-1.0
1,2022-12-31,A,B,1.28,0.28
2,2023-01-01,A,B,-1.0,-0.72
3,2023-01-02,A,B,1.0,0.28
4,2023-01-03,A,B,1.0,1.28
5,2023-01-04,A,B,-1.0,-1.72
6,2023-01-04,A,B,-1.0,-1.72
7,2023-01-04,A,B,-1.0,-1.72
</co... | <python><pandas> | 2023-01-08 01:46:20 | 1 | 2,222 | Digital Farmer |
75,044,779 | 6,626,632 | Scraping data from KendoUI interface using selenium and python | <p>I am trying to scrape data from <a href="https://laerm-monitoring.de/mittelung?mp=14" rel="nofollow noreferrer">this website</a> using selenium and python (note the website is in German but can be translated using Chrome's translate function). Specifically, I would like to automate the process of (1) selecting "... | <python><selenium><web-scraping> | 2023-01-08 00:42:05 | 1 | 462 | sdg |
75,044,685 | 10,380,766 | Pyenv unable to install older versions of Python 3 due to `configure: error: C compiler cannot create executables` | <p>I've been trying to use <code>pyenv</code> to install older versions of python3. I've tried <code>3.0.1</code>, <code>3.1.0</code>, <code>3.1.1</code>, and <code>3.1.2</code>. I kept getting the error</p>
<pre><code>ImportError: No module named _ssl
ERROR: The Python ssl extension was not compiled. Missing the OpenS... | <python><python-3.x><ubuntu><openssl><pyenv> | 2023-01-08 00:15:41 | 2 | 1,020 | Hofbr |
75,044,683 | 11,154,361 | NetCDF variable extraction at specific coordinates using arrays does not work - python | <p>I am trying to extract two variables values of a netCDF file at specific coordinates. From what I have seen from various posts on StackOverflow, the best way to achieve that is to work with <code>arrays</code>.</p>
<p>I have tried to use <a href="https://stackoverflow.com/questions/69330668/efficient-way-to-extract-... | <python><arrays><netcdf><python-xarray> | 2023-01-08 00:14:40 | 0 | 344 | I.M. |
75,044,240 | 1,473,517 | Correlation coefficient confidence intervals | <p>Using scipy.stats we can compute the correlation coefficient along with a p-value. For example using:</p>
<pre><code>x = [1.76405235, 0.40015721, 0.97873798,
2.2408932, 1.86755799, -0.97727788]
y = [2.71414076, 0.2488, 0.87551913,
2.6514917, 2.01160156, 0.47699563]
def statistic(x): # permute only `x`
return... | <python><scipy><statistics> | 2023-01-07 22:32:18 | 1 | 21,513 | Simd |
75,044,224 | 1,580,659 | How do I "flatten" a nested serializer in DRF? | <p>We have a nested serializer that we would like to "flatten". But I'm not having much luck finding how to achieve this in the docs.</p>
<p>Here is the current output.</p>
<pre><code>{
"user_inventory": "UOHvaxFa11R5Z0bPYuihP0RKocn2",
"quantity": 1,
"player"... | <python><django><django-rest-framework> | 2023-01-07 22:30:44 | 1 | 1,428 | JeremyE |
75,043,540 | 14,368,435 | how can i tell the python interpreter running inside the flatpak sandbox to use libraries from the main system | <p>I'm creating a Gtk4 application with python bindings on Linux. I'm using flatpak as well.
So I'm creating like an extensions/plugins systems where user can define his main module to call in a specific file and later on ill load it. Every thing works but when the user uses imports for external libraries like NumPy or... | <python><gtk4><flatpak> | 2023-01-07 20:24:12 | 1 | 304 | Ali BEN AMOR |
75,043,535 | 2,495,203 | Python: more efficient data structure than a nested dictionary of dictionaries of arrays? | <p>I'm writing a python-3.10 program that predicts time series of various properties for a large number of objects. My current choice of data structure for collecting results internally in the code and then for writing to files is a nested dictionary of dictionaries of arrays. For example, for two objects with time ser... | <python><numpy><dictionary><nested><pickle> | 2023-01-07 20:22:39 | 1 | 721 | quantumflash |
75,043,497 | 1,486,486 | Nested locks of the same Thread causing a dead lock | <p>I have a small class (<code>Counters</code>) which wraps a dictionary of objects (<code>Counter</code>).</p>
<p>Here is a simplified example (with my debugging prints...)</p>
<pre><code>import threading
import time
import logging
import random
logging.basicConfig(level=logging.DEBUG, format='(%(threadName)-9s) %(me... | <python><python-3.x><multithreading><deadlock><thread-lock> | 2023-01-07 20:16:45 | 1 | 6,606 | Shlomi Hassid |
75,043,415 | 7,437,221 | How can I add a new column to a dataframe (df1) that is the sum of multiple lookup values from df1 in another dataframe (df2) | <p>Say I have 2 dataframes:</p>
<p>df1</p>
<pre><code> id guid name item1 item2 item3 item4 item5 item6 item7 item8 item9
0 3031958124 85558-261955282 Alonso 85558-57439 85558-54608 85558-91361 85558-40647 85558-41305 85558-799... | <python><pandas><numpy><data-science><data-analysis> | 2023-01-07 20:03:24 | 3 | 353 | Sean Sailer |
75,043,231 | 10,664,489 | Upgrade to opencv-python 4.7 causes import error | <p>While working on a project that uses the opencv-python module, I ended up updating it to version 4.7.0.68 from 4.6.0.66. The next time I ran my program it failed with an import error:
<code>ImportError: dlopen(path/to/my/virtualenv/lib/python3.9/site-packages/cv2/cv2.abi3.so, 2): Symbol not found: _VTRegisterSupplem... | <python><macos><opencv> | 2023-01-07 19:34:51 | 1 | 574 | Adam Richard |
75,043,137 | 814,354 | Set arrow size based on figure units instead of axis data units? | <p>In matplotlib, is there a way to specify arrow head sizes in figure units rather than in data units?</p>
<p>The use case is: I am making a multi-panel figure in which each panel has a different axis size (e.g., one goes from 0 to 1 on the X-axis, and the next goes from 0 to 10). I'd like the arrows to appear the sa... | <python><matplotlib><plot> | 2023-01-07 19:18:11 | 2 | 19,445 | keflavich |
75,043,134 | 2,326,896 | How would I implement my own IntEnum in Python if one wasn't provided oob? | <p>I always struggle with Enum, IntEnum, etc and have to revisit the documentation several times each time I use this Python feature. I think it would be useful to have a more clear understanding of the internals.</p>
<p>For instance, why can't I use named arguments in this example?</p>
<pre><code>class MD_Fields(IntEn... | <python><enums> | 2023-01-07 19:17:44 | 2 | 891 | Fernando César |
75,043,118 | 2,453,606 | Sagemaker Batch Transform Job "upstream prematurely closed connection" when surpassing 30 minutes | <p>I am serving a sagemaker model through a custom docker container using <a href="https://sagemaker-examples.readthedocs.io/en/latest/advanced_functionality/scikit_bring_your_own/scikit_bring_your_own.html#When-should-I-build-my-own-algorithm-container%3F" rel="nofollow noreferrer">the guide that AWS provides</a>. Thi... | <python><amazon-web-services><nginx><gunicorn><amazon-sagemaker> | 2023-01-07 19:14:55 | 1 | 1,885 | GrantD71 |
75,043,093 | 2,326,896 | Python compiler says I'm adding an extra argument to int in an Enum | <p>I'm trying to create a custom enumerator that can replace an int, but has additional fields.</p>
<pre><code>from enum import IntEnum
class MD_Fields(IntEnum):
ACCOUNT = (0, "Account", True)
M_DESCRIPT = (4, "Description", False)
def __new__(cls, value: int, description: str, identif... | <python><enums> | 2023-01-07 19:11:56 | 1 | 891 | Fernando César |
75,043,070 | 1,845,408 | groupby produces a different mean when done at two levels | <p>I have a dataset (<code>df</code>) about the <code>Time</code> spent by different users (<code>UserId</code>). Users can belong to different <code>Group</code>s (1, 2, 3).</p>
<pre><code> UserId Time Group
0 181915 52 3
1 128004 52 2
2 178974 40 1
3 182887 30 1
4 238434 50 2
</code></pre>
<... | <python><pandas><dataframe><group-by> | 2023-01-07 19:06:40 | 0 | 8,321 | renakre |
75,043,032 | 19,989,634 | How to redirect to same place on page when redirecting to previous page | <p>I was wondering if there is a way in django for when you click back to go to the previous page via a link or in my case an anchored link with in an img, for it to also end up in the same place as you click originally, in my case the image that is clicked in the first place.</p>
<p><strong>Page I click image to redir... | <python><django> | 2023-01-07 19:01:18 | 1 | 407 | David Henson |
75,043,015 | 13,609,047 | Jupyter Kernel Dies when Running TensorFlow Model | <p>While training a TensorFlow Model in Jupyter, the kernel dies before the first epoch.</p>
<p>The model I am using is a DeepLab with input size 256 on a ResNet50 encoder. I cannot show the model summary because it is too long to fit in the question.
This issue only happens with this specific model and does not occur ... | <python><tensorflow><jupyter-notebook> | 2023-01-07 18:58:41 | 1 | 352 | neuops |
75,042,645 | 1,826,066 | Specify return type of a wrapper function that calls an abstract method in Python | <p>For this example, consider the simplified scenario where a <code>Solver</code> will return a <code>Solution</code>.</p>
<p>We have <code>Solution</code>s:</p>
<pre class="lang-py prettyprint-override"><code>class Solution(ABC):
pass
class AnalyticalSolution(Solution):
pass
class NumericalSolution(Solutio... | <python><object><abstract-class><type-hinting> | 2023-01-07 18:05:10 | 1 | 1,351 | Thomas |
75,042,556 | 5,994,555 | TypeError when autoincrementing column in sqlalchemy | <p>I have the following table definition</p>
<pre><code>class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True, autoincrement=True)
email = Column(String(256), unique=True)
is_admin = Column(Boolean, nullable=False)
def __init__(self, id, email, is_admin):
self.id ... | <python><sqlalchemy> | 2023-01-07 17:51:37 | 1 | 497 | Sabina Orazem |
75,042,333 | 13,345,744 | How to convert Pandas Series to Timestamp when not every value is convertible? | <p><strong>Context</strong></p>
<p>I have a <code>Pandas</code> <code>Series</code> containing <code>Dates</code> in a <code>String</code> format <em>(e.g. 2017-12-19 09:35:00)</em>. My goal is to convert this <code>Series</code> into <code>Timestamps</code> <em>(Time in Seconds since 1970)</em>.</p>
<p>The difficulty ... | <python><pandas><datetime><machine-learning><timestamp> | 2023-01-07 17:22:13 | 2 | 1,721 | christophriepe |
75,042,171 | 14,094,460 | Block setting of class attributes (__setattr__) | <ol>
<li>is there a simple way to prevent setting new class attrs?</li>
<li>while trying with the following snippet, shouldn't <code>setattr(Derived, "test1", 1)</code> call the <code>__setattr__</code> from <code>Base</code>?</li>
</ol>
<pre><code>class Base:
def __setattr__(self, key, value):
ra... | <python><setattr> | 2023-01-07 16:58:58 | 2 | 1,442 | deponovo |
75,042,021 | 20,247,248 | Import "pybit" could not be resolved | <p>When I run <code>pip3 install pybit</code> in the terminal I get:</p>
<pre><code>Requirement already satisfied: pybit in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (2.4.1)
</code></pre>
<p>But in my project:</p>
<pre><code>#API imports
from pybit import HTTP
</code></pre>
<p>I ge... | <python> | 2023-01-07 16:39:03 | 0 | 402 | tdimoff |
75,042,013 | 7,104,332 | Python sort a string in CSV | <p>I want to sort the every row of the CSV string with the following code</p>
<pre><code>import csv
def sort_csv_columns(csv_string: str) -> str:
# Split the CSV string into lines
lines = csv_string.strip().split("\n")
# Split the first line (column names) and sort it case-insensitively
h... | <python><csv> | 2023-01-07 16:37:28 | 1 | 474 | Rohit Sthapit |
75,041,692 | 4,451,521 | Ordering a dataframe with a key function and multiple columns | <p>I have the following</p>
<pre><code>import pandas as pd
import numpy as np
df = pd.DataFrame({
'col1': ['A', 'A', 'B', np.nan, 'D', 'C'],
'col2': [2, -1, 9, -8, 7, 4],
'col3': [0, 1, 9, 4, 2, 3],
'col4': ['a', 'B', 'c', 'D', 'e', 'F'],
'col5': [2, 1, 9, 8, 7, 4],
'col6': [1.00005,1.00001,-2.... | <python><pandas> | 2023-01-07 15:53:42 | 2 | 10,576 | KansaiRobot |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.