itemId stringlengths 1 34 | itemType stringclasses 4
values | site stringclasses 4
values | scrapedAt timestamp[s]date 2026-08-03 00:21:25 2026-08-03 04:01:45 | tagName stringlengths 1 34 ⌀ | questionCount int64 2 2.53M ⌀ | hasSynonyms bool 2
classes | isModeratorOnly bool 1
class | isRequired bool 1
class | link stringlengths 32 258 | _run_id stringclasses 57
values | _dataset_id stringclasses 57
values | questionId int64 1 80M ⌀ | title stringlengths 15 150 ⌀ | score int64 -10 35.3k ⌀ | viewCount int64 6 16.7M ⌀ | answerCount int64 0 296 ⌀ | isAnswered bool 2
classes | hasAcceptedAnswer bool 2
classes | tags listlengths 1 6 ⌀ | createdAt timestamp[s]date 2008-08-01 04:18:04 2026-08-03 03:37:34 ⌀ | lastActivityAt timestamp[s]date 2008-10-30 09:20:18 2026-08-03 01:36:51 ⌀ | ownerDisplayName stringlengths 3 30 ⌀ | isClosed bool 2
classes | contentLicense stringclasses 3
values | acceptedAnswerId int64 4 80M ⌀ | ownerUserId int64 1 33M ⌀ | ownerReputation int64 1 1.53M ⌀ | userId int64 13 33M ⌀ | displayName stringclasses 897
values | reputation int64 1 1.53M ⌀ | userType stringclasses 3
values | lastAccessAt timestamp[s]date 2011-01-10 08:55:57 2026-08-03 03:38:13 ⌀ | goldBadges int64 0 895 ⌀ | silverBadges int64 0 9.32k ⌀ | bronzeBadges int64 0 9.36k ⌀ | reputationChangeMonth int64 -40 1.43k ⌀ | reputationChangeYear int64 -1,146 11.7k ⌀ | websiteUrl stringclasses 302
values | location stringclasses 279
values | acceptRate int64 17 100 ⌀ | answerId int64 1.13k 80M ⌀ | isAccepted bool 2
classes | bodyText stringlengths 31 24.4k ⌀ | bodyHtml stringlengths 39 34.9k ⌀ | answers listlengths 1 3 ⌀ | answersFetched int64 0 3 ⌀ |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7585435 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/7585435/how-to-convert-string-to-bytes-in-python-3 | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 7,585,435 | How to convert string to bytes in Python 3 | 1,541 | 3,006,884 | 5 | true | true | [
"python",
"string",
"character-encoding",
"python-3.x"
] | 2011-09-28T15:14:07 | 2025-08-22T23:21:40 | Mark Ransom | false | CC BY-SA 4.0 | 7,585,619 | 5,987 | 310,547 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | TypeError: 'str' does not support the buffer interface suggests two possible methods to convert a string to bytes: b = bytes(mystring, 'utf-8') b = mystring.encode('utf-8') What are the differences between them? Which one should I opt for and why? See Convert bytes to a string in Python 3 for the other way around. | <p><a href="https://stackoverflow.com/questions/5471158/typeerror-str-does-not-support-the-buffer-interface">TypeError: 'str' does not support the buffer interface</a> suggests two possible methods to convert a string to bytes:</p>
<pre><code>b = bytes(mystring, 'utf-8')
b = mystring.encode('utf-8')
</code></p... | null | 0 |
8858008 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/8858008/how-do-i-move-a-file-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 8,858,008 | How do I move a file in Python? | 1,539 | 2,141,240 | 12 | true | true | [
"python",
"file",
"file-handling",
"python-os"
] | 2012-01-13T22:17:58 | 2024-04-28T06:05:52 | David542 | false | CC BY-SA 4.0 | 8,858,026 | 651,174 | 112,952 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How can I do the equivalent of mv in Python? mv "path/to/current/file.foo" "path/to/new/destination/for/file.foo" | <p>How can I do the equivalent of <a href="https://ss64.com/bash/mv.html" rel="noreferrer"><code>mv</code></a> in Python?</p>
<pre class="lang-bash prettyprint-override"><code>mv "path/to/current/file.foo" "path/to/new/destination/for/file.foo"
</code></pre>
| [
{
"answerId": 8858026,
"score": 2295,
"isAccepted": true,
"createdAt": "2012-01-13T22:19:58",
"ownerDisplayName": "ig0774",
"ownerUserId": 274466,
"bodyText": "os.rename() , os.replace() , or shutil.move() All employ the same syntax: import os import shutil os.rename(\"path/to/current/fi... | 1 |
192109 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/192109/is-there-a-built-in-function-to-print-all-the-current-properties-and-values-of-a | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 192,109 | Is there a built-in function to print all the current properties and values of an object? | 1,539 | 1,464,202 | 32 | true | true | [
"python",
"debugging",
"introspection",
"pretty-print",
"python-datamodel"
] | 2008-10-10T16:19:27 | 2026-03-22T04:29:42 | fuentesjr | false | CC BY-SA 4.0 | 192,365 | 10,708 | 52,634 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | So what I'm looking for here is something like PHP's print_r function. This is so I can debug my scripts by seeing what's the state of the object in question. | <p>So what I'm looking for here is something like PHP's <a href="https://www.php.net/print_r" rel="noreferrer">print_r</a> function.</p>
<p>This is so I can debug my scripts by seeing what's the state of the object in question.</p>
| [
{
"answerId": 193539,
"score": 1425,
"isAccepted": false,
"createdAt": "2008-10-11T01:16:32",
"ownerDisplayName": "Jeremy Cantrell",
"ownerUserId": 18866,
"bodyText": "You want vars() mixed with pprint() : from pprint import pprint pprint(vars(your_object))"
}
] | 1 |
5142418 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/5142418/what-is-the-use-of-assert-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 5,142,418 | What is the use of "assert" in Python? | 1,530 | 1,507,484 | 23 | true | true | [
"python",
"exception",
"assert",
"assertion"
] | 2011-02-28T13:11:45 | 2022-12-06T02:47:13 | Hossein | false | CC BY-SA 4.0 | 5,142,453 | 313,245 | 42,599 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | What does assert mean? How is it used? | <p>What does <code>assert</code> mean? How is it used?</p>
| [
{
"answerId": 5142453,
"score": 1772,
"isAccepted": true,
"createdAt": "2011-02-28T13:15:33",
"ownerDisplayName": "salezica",
"ownerUserId": 469300,
"bodyText": "The assert statement exists in almost every programming language. It has two main uses: It helps detect problems early in your... | 1 |
7961363 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/7961363/removing-duplicates-in-lists | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 7,961,363 | Removing duplicates in lists | 1,526 | 2,339,709 | 58 | true | true | [
"python",
"algorithm",
"list",
"duplicates",
"intersection"
] | 2011-11-01T00:45:24 | 2026-03-04T20:16:19 | Neemaximo | false | CC BY-SA 4.0 | 7,961,390 | 1,022,857 | 21,169 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How can I check if a list has any duplicates and return a new list without duplicates? | <p>How can I check if a list has any duplicates and return a new list without duplicates?</p>
| [
{
"answerId": 7961390,
"score": 2341,
"isAccepted": true,
"createdAt": "2011-11-01T00:49:04",
"ownerDisplayName": "poke",
"ownerUserId": 216074,
"bodyText": "The common approach to get a unique collection of items is to use a set . Sets are unordered collections of distinct objects. To c... | 1 |
31684375 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/31684375/automatically-create-file-requirements-txt | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 31,684,375 | Automatically create file 'requirements.txt' | 1,524 | 2,741,573 | 29 | true | true | [
"python",
"dependencies",
"python-import",
"requirements.txt"
] | 2015-07-28T18:29:03 | 2026-01-04T22:32:56 | Igor Barinov | false | CC BY-SA 4.0 | 33,468,993 | 1,268,964 | 26,330 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Sometimes I download the Python source code from GitHub and don't know how to install all the dependencies. If there isn't any requirements.txt file I have to create it by hand. Given the Python source code directory, is it possible to create requirements.txt automatically from the import section? | <p>Sometimes I download the Python source code from <a href="https://en.wikipedia.org/wiki/GitHub" rel="noreferrer">GitHub</a> and don't know how to install all the dependencies. If there isn't any <em>requirements.txt</em> file I have to create it by hand.</p>
<p>Given the Python source code directory, is it possible ... | [
{
"answerId": 31684470,
"score": 1677,
"isAccepted": false,
"createdAt": "2015-07-28T18:34:04",
"ownerDisplayName": "DJanssens",
"ownerUserId": 2526441,
"bodyText": "You can use the following code to generate a requirements.txt file: pip install pipreqs pipreqs /path/to/project The benef... | 2 |
3430372 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/3430372/how-do-i-get-the-full-path-of-the-current-files-directory | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 3,430,372 | How do I get the full path of the current file's directory? | 1,523 | 2,839,926 | 12 | true | true | [
"python",
"directory"
] | 2010-08-07T12:17:52 | 2023-09-07T15:57:19 | Shubham | true | null | 3,430,395 | 388,350 | 22,584 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I get the current file's directory path? I tried: >>> os.path.abspath(__file__) 'C:\\python27\\test.py' But I want: 'C:\\python27\\' | <p>How do I get the current file's directory path?
I tried:</p>
<pre><code>>>> os.path.abspath(__file__)
'C:\\python27\\test.py'
</code></pre>
<p>But I want:</p>
<pre><code>'C:\\python27\\'
</code></pre>
| [
{
"answerId": 3430395,
"score": 2823,
"isAccepted": true,
"createdAt": "2010-08-07T12:24:25",
"ownerDisplayName": "Bryan Oakley",
"ownerUserId": 7432,
"bodyText": "The special variable __file__ contains the path to the current file. From that we can get the directory using either pathlib... | 1 |
1483429 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/1483429/how-do-i-print-an-exception-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 1,483,429 | How do I print an exception in Python? | 1,520 | 2,324,767 | 11 | true | true | [
"python",
"exception",
"error-handling"
] | 2009-09-27T11:48:19 | 2024-04-27T19:25:22 | TIMEX | true | null | 1,483,488 | 179,736 | 275,536 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I print the error/exception in the except: block? try: ... except: print(exception) | <p>How do I print the error/exception in the <code>except:</code> block?</p>
<pre><code>try:
...
except:
print(exception)
</code></pre>
| [
{
"answerId": 1483488,
"score": 2041,
"isAccepted": true,
"createdAt": "2009-09-27T12:19:27",
"ownerDisplayName": "jldupont",
"ownerUserId": 171461,
"bodyText": "For Python 2.6 and later and Python 3.x: except Exception as e: print(e) For Python 2.5 and earlier, use: except Exception,e: ... | 1 |
9942594 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/9942594/unicodeencodeerror-ascii-codec-cant-encode-character-u-xa0-in-position-20 | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 9,942,594 | UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in range(128) | 1,519 | 2,320,523 | 35 | true | true | [
"python",
"unicode",
"beautifulsoup",
"python-2.x",
"python-unicode"
] | 2012-03-30T12:06:41 | 2024-08-08T07:49:44 | Homunculus Reticulli | false | CC BY-SA 3.0 | 9,942,822 | 962,891 | 69,274 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I'm having problems dealing with unicode characters from text fetched from different web pages (on different sites). I am using BeautifulSoup. The problem is that the error is not always reproducible; it sometimes works with some pages, and sometimes, it barfs by throwing a UnicodeEncodeError . I have tried just about ... | <p>I'm having problems dealing with unicode characters from text fetched from different web pages (on different sites). I am using BeautifulSoup. </p>
<p>The problem is that the error is not always reproducible; it sometimes works with some pages, and sometimes, it barfs by throwing a <code>UnicodeEncodeError</code>. ... | [
{
"answerId": 9942822,
"score": 1532,
"isAccepted": true,
"createdAt": "2012-03-30T12:21:31",
"ownerDisplayName": "agf",
"ownerUserId": 500584,
"bodyText": "Read the Python Unicode HOWTO . This error is the very first example . Do not use str() to convert from unicode to encoded text / b... | 1 |
3768895 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/3768895/how-to-make-a-class-json-serializable | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 3,768,895 | How to make a class JSON serializable | 1,516 | 1,706,934 | 46 | true | true | [
"python",
"json",
"serialization"
] | 2010-09-22T11:52:19 | 2025-08-21T07:10:36 | Sergey | false | CC BY-SA 4.0 | 3,768,975 | 388,427 | 21,579 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How to make a Python class serializable? class FileItem: def __init__(self, fname): self.fname = fname Attempt to serialize to JSON: >>> import json >>> x = FileItem('/foo/bar') >>> json.dumps(x) TypeError: Object of type 'FileItem' is not JSON serializable | <p>How to make a Python class serializable?</p>
<pre><code>class FileItem:
def __init__(self, fname):
self.fname = fname
</code></pre>
<p>Attempt to serialize to JSON:</p>
<pre><code>>>> import json
>>> x = FileItem('/foo/bar')
>>> json.dumps(x)
TypeError: Object of type 'FileItem... | null | 0 |
3289601 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/3289601/null-object-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 3,289,601 | Null object in Python | 1,513 | 2,566,719 | 11 | true | true | [
"python",
"object",
"null"
] | 2010-07-20T11:53:41 | 2025-02-21T16:32:37 | Lizard | false | CC BY-SA 4.0 | 3,289,606 | 123,140 | 45,377 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I refer to the null object in Python? | <p>How do I refer to the <a href="https://en.wikipedia.org/wiki/Null_pointer" rel="noreferrer">null object</a> in Python?</p>
| [
{
"answerId": 3289606,
"score": 1994,
"isAccepted": true,
"createdAt": "2010-07-20T11:54:27",
"ownerDisplayName": "Ben James",
"ownerUserId": 189179,
"bodyText": "In Python, the 'null' object is the singleton None . To check if something is None , use the is identity operator: if foo is ... | 1 |
1093322 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/1093322/how-do-i-check-which-version-of-python-is-running-my-script | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 1,093,322 | How do I check which version of Python is running my script? | 1,506 | 1,883,968 | 26 | true | true | [
"python",
"version"
] | 2009-07-07T16:17:49 | 2024-10-14T14:20:49 | carrier | false | CC BY-SA 4.0 | 1,093,331 | 20,498 | 33,306 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I check which version of the Python interpreter is running my script? See Find full path of the Python interpreter (Python executable)? if you are looking to find exactly which interpreter is being used - for example, to debug a Pip installation problem, or to check which virtual environment (if any) is active. | <p>How do I check which version of the Python interpreter is running my script?</p>
<hr />
<p><sub> See <a href="https://stackoverflow.com/questions/2589711">Find full path of the Python interpreter (Python executable)?</a> if you are looking to find exactly <em>which interpreter</em> is being used - for example, to de... | [
{
"answerId": 1093331,
"score": 1722,
"isAccepted": true,
"createdAt": "2009-07-07T16:20:12",
"ownerDisplayName": "krawyoti",
"ownerUserId": 130961,
"bodyText": "This information is available in the sys.version string in the sys module: >>> import sys Human readable: >>> print(sys.versio... | 1 |
2835559 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/2835559/why-cant-python-parse-this-json-data | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 2,835,559 | Why can't Python parse this JSON data? | 1,503 | 2,701,827 | 3 | true | true | [
"python",
"json",
"parsing"
] | 2010-05-14T15:54:20 | 2022-07-02T05:29:08 | michele | true | null | 2,835,672 | 453,712 | 26,678 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I have this JSON in a file: { "maps": [ { "id": "blabla", "iscategorical": "0" }, { "id": "blabla", "iscategorical": "0" } ], "masks": [ "id": "valore" ], "om_points": "value", "parameters": [ "id": "valore" ] } I wrote this script to print all of the JSON data: import json from pprint import pprint with open('data.jso... | <p>I have this JSON in a file:</p>
<pre class="lang-json prettyprint-override"><code>{
"maps": [
{
"id": "blabla",
"iscategorical": "0"
},
{
"id": "blabla",
"iscategoric... | [
{
"answerId": 2835672,
"score": 2193,
"isAccepted": true,
"createdAt": "2010-05-14T16:10:15",
"ownerDisplayName": "Justin Peel",
"ownerUserId": 254617,
"bodyText": "Your data is not valid JSON format. You have [] when you should have {} for the \"masks\" and \"parameters\" elements: [] a... | 1 |
4760215 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/4760215/running-shell-command-and-capturing-the-output | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 4,760,215 | Running shell command and capturing the output | 1,498 | 2,050,315 | 25 | true | true | [
"python",
"shell",
"subprocess"
] | 2011-01-21T14:55:44 | 2025-05-30T19:46:28 | Silver Light | false | CC BY-SA 4.0 | 4,760,517 | 303,513 | 46,480 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I want to write a function that will execute a shell command and return its output as a string , no matter, is it an error or success message. I just want to get the same result that I would have gotten with the command line. What would be a code example that would do such a thing? For example: def run_command(cmd): # ... | <p>I want to write a function that will execute a shell command and return its output <strong>as a string</strong>, no matter, is it an error or success message. I just want to get the same result that I would have gotten with the command line.</p>
<p>What would be a code example that would do such a thing?</p>
<p>Fo... | [
{
"answerId": 4760517,
"score": 1976,
"isAccepted": true,
"createdAt": "2011-01-21T15:27:52",
"ownerDisplayName": "senderle",
"ownerUserId": 577088,
"bodyText": "In all officially maintained versions of Python, the simplest approach is to use the subprocess.check_output function: >>> sub... | 1 |
20625582 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 20,625,582 | How to deal with SettingWithCopyWarning in Pandas | 1,495 | 2,586,439 | 27 | true | true | [
"python",
"pandas",
"dataframe",
"chained-assignment",
"pandas-settingwithcopy-warning"
] | 2013-12-17T03:48:02 | 2025-06-15T02:38:25 | bigbug | false | CC BY-SA 4.0 | 20,627,316 | 1,072,888 | 60,014 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I just upgraded my Pandas from 0.11 to 0.13.0rc1. Now, the application is popping out many new warnings. One of them like this: E:\FinReporter\FM_EXT.py:449: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_index,col_indexer] = value instead quote_df['TVol'] ... | <p>I just upgraded my Pandas from 0.11 to 0.13.0rc1. Now, the application is popping out many new warnings. One of them like this:</p>
<pre class="lang-none prettyprint-override"><code>E:\FinReporter\FM_EXT.py:449: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc... | [
{
"answerId": 20627316,
"score": 1735,
"isAccepted": true,
"createdAt": "2013-12-17T06:20:23",
"ownerDisplayName": "Garrett",
"ownerUserId": 243434,
"bodyText": "The SettingWithCopyWarning was created to flag potentially confusing \"chained\" assignments, such as the following, which doe... | 1 |
11875770 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/11875770/how-can-i-overcome-datetime-datetime-not-json-serializable | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 11,875,770 | How can I overcome "datetime.datetime not JSON serializable"? | 1,495 | 1,394,772 | 36 | true | true | [
"python",
"json"
] | 2012-08-09T02:02:51 | 2025-09-07T13:38:55 | Rolando | false | CC BY-SA 4.0 | 11,875,813 | 971,888 | 63,440 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | sample = {} sample['title'] = "String" sample['somedate'] = somedatetimehere jsonify(sample) on that dict gets: TypeError: datetime.datetime(2012, 8, 8, 21, 46, 24, 862000) is not JSON serializable What can I do to overcome that error? Note: the dictionaries are generated from the retrieval of records out of mongodb wh... | <pre class="lang-py prettyprint-override"><code>sample = {}
sample['title'] = "String"
sample['somedate'] = somedatetimehere
</code></pre>
<p><code>jsonify(sample)</code> on that dict gets:</p>
<blockquote>
<p>TypeError: datetime.datetime(2012, 8, 8, 21, 46, 24, 862000) is not JSON serializable</p>
</blockquo... | [
{
"answerId": 36142844,
"score": 1844,
"isAccepted": false,
"createdAt": "2016-03-21T22:29:26",
"ownerDisplayName": "jjmontes",
"ownerUserId": 401656,
"bodyText": "My quick & dirty JSON dump that eats dates and everything: json.dumps(my_dictionary, indent=4, sort_keys=True, default=str) ... | 1 |
7696924 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/7696924/how-do-i-create-multiline-comments-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 7,696,924 | How do I create multiline comments in Python? | 1,486 | 2,343,155 | 27 | true | true | [
"python",
"comments",
"documentation"
] | 2011-10-08T12:51:13 | 2026-02-13T14:03:20 | Pavan Kumar | false | CC BY-SA 4.0 | 7,696,966 | 639,891 | 20,853 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I make multi-line comments? Most languages have block comment symbols like: /* */ | <p>How do I make multi-line comments? Most languages have block comment symbols like:</p>
<pre><code>/*
*/
</code></pre>
| [
{
"answerId": 7696966,
"score": 2237,
"isAccepted": true,
"createdAt": "2011-10-08T12:58:47",
"ownerDisplayName": "Petr Viktorin",
"ownerUserId": 99057,
"bodyText": "You can use triple-quoted strings. When they're not a docstring (the first thing in a class/function/module), they are ign... | 1 |
122327 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 122,327 | How do I find the location of my Python site-packages directory? | 1,484 | 1,820,715 | 23 | true | true | [
"python"
] | 2008-09-23T17:04:43 | 2026-02-22T14:11:18 | Daryl Spitzer | false | CC BY-SA 4.0 | 46,071,447 | 4,766 | 151,222 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I find the location of my site-packages directory? | <p>How do I find the location of my <code>site-packages</code> directory?</p>
| [
{
"answerId": 46071447,
"score": 1182,
"isAccepted": true,
"createdAt": "2017-09-06T09:24:00",
"ownerDisplayName": "Peterino",
"ownerUserId": 202834,
"bodyText": "There are two types of site-packages directories, global and per user . Global site-packages (\" dist-packages \") directorie... | 1 |
13413590 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/13413590/how-to-drop-rows-of-pandas-dataframe-whose-value-in-a-certain-column-is-nan | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 13,413,590 | How to drop rows of Pandas DataFrame whose value in a certain column is NaN | 1,479 | 2,320,080 | 17 | true | true | [
"python",
"pandas",
"dataframe",
"indexing",
"nan"
] | 2012-11-16T09:17:22 | 2024-03-08T15:47:42 | bigbug | false | CC BY-SA 4.0 | 13,413,845 | 1,072,888 | 60,014 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I have this DataFrame and want only the records whose EPS column is not NaN: STK_ID EPS cash STK_ID RPT_Date 601166 20111231 601166 NaN NaN 600036 20111231 600036 NaN 12 600016 20111231 600016 4.3 NaN 601009 20111231 601009 NaN NaN 601939 20111231 601939 2.5 NaN 000001 20111231 000001 NaN NaN ...i.e. something like df.... | <p>I have this DataFrame and want only the records whose EPS column is not NaN:</p>
<pre class="lang-none prettyprint-override"><code> STK_ID EPS cash
STK_ID RPT_Date
601166 20111231 601166 NaN NaN
600036 20111231 600036 NaN 12
600016 20111231 600016 4.3 NaN
601009 2011... | [
{
"answerId": 13413845,
"score": 1651,
"isAccepted": true,
"createdAt": "2012-11-16T09:34:38",
"ownerDisplayName": "eumiro",
"ownerUserId": 449449,
"bodyText": "Don't drop, just take the rows where EPS is not NA: df = df[df['EPS'].notna()]"
},
{
"answerId": 13434501,
"score":... | 2 |
134934 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/134934/display-number-with-leading-zeros | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 134,934 | Display number with leading zeros | 1,479 | 1,727,769 | 19 | true | true | [
"python",
"integer",
"string-formatting"
] | 2008-09-25T18:06:06 | 2022-11-09T15:44:56 | ashchristopher | true | null | 134,951 | 22,306 | 26,501 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I display a leading zero for all numbers with less than two digits? 1 → 01 10 → 10 100 → 100 | <p>How do I display a leading zero for all numbers with less than two digits?</p>
<pre class="lang-none prettyprint-override"><code>1 → 01
10 → 10
100 → 100
</code></pre>
| [
{
"answerId": 134951,
"score": 2004,
"isAccepted": true,
"createdAt": "2008-09-25T18:08:21",
"ownerDisplayName": "Jack M.",
"ownerUserId": 3421,
"bodyText": "In Python 2 (and Python 3) you can do: number = 1 print(\"%02d\" % (number,)) Basically % is like printf or sprintf (see docs ). F... | 2 |
268272 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/268272/getting-key-with-maximum-value-in-dictionary | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 268,272 | Getting key with maximum value in dictionary? | 1,473 | 1,813,660 | 29 | true | true | [
"python",
"dictionary",
"max"
] | 2008-11-06T10:49:58 | 2024-03-08T03:53:33 | ricafeal | false | CC BY-SA 4.0 | 268,285 | 34,598 | 15,159 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I have a dictionary where keys are strings, and values are integers. stats = {'a': 1, 'b': 3000, 'c': 0} How do I get the key with the maximum value? In this case, it is 'b' . Is there a nicer approach than using an intermediate list with reversed key-value tuples? inverse = [(value, key) for key, value in stats.items(... | <p>I have a dictionary where keys are strings, and values are integers.</p>
<pre><code>stats = {'a': 1, 'b': 3000, 'c': 0}
</code></pre>
<p>How do I get the key with the maximum value? In this case, it is <code>'b'</code>.</p>
<hr />
<p>Is there a nicer approach than using an intermediate list with reversed key-value t... | [
{
"answerId": 280156,
"score": 2121,
"isAccepted": false,
"createdAt": "2008-11-11T06:24:30",
"ownerDisplayName": "A. Coady",
"ownerUserId": 36433,
"bodyText": "max(stats, key=stats.get)"
}
] | 1 |
5082452 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/5082452/string-formatting-vs-format-vs-f-string-literal | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 5,082,452 | String formatting: % vs. .format vs. f-string literal | 1,471 | 1,079,848 | 16 | true | true | [
"python",
"performance",
"string-formatting",
"f-string"
] | 2011-02-22T18:46:42 | 2024-07-10T10:34:49 | NorthIsUp | false | CC BY-SA 4.0 | 5,082,482 | 231,463 | 17,925 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | There are various string formatting methods: Python <2.6: "Hello %s" % name Python 2.6+: "Hello {}".format(name) (uses str.format ) Python 3.6+: f"{name}" (uses f-strings) Which is better, and for what situations? The following methods have the same outcome, so what is the difference? name = "Alice" "Hello %s" % name "... | <p>There are various string formatting methods:</p>
<ul>
<li>Python <2.6: <code>"Hello %s" % name</code></li>
<li>Python 2.6+: <code>"Hello {}".format(name)</code> (uses <a href="https://docs.python.org/2/library/stdtypes.html#str.format" rel="noreferrer"><code>str.format</code></a>)</li>
<li>P... | null | 0 |
1952464 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/1952464/python-how-to-determine-if-an-object-is-iterable | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 1,952,464 | Python: how to determine if an object is iterable? | 1,470 | 850,584 | 25 | true | true | [
"python",
"iterable"
] | 2009-12-23T12:13:55 | 2024-07-31T18:59:36 | willem | false | CC BY-SA 4.0 | 1,952,481 | 22,702 | 27,257 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Is there a method like isiterable ? The only solution I have found so far is to call: hasattr(myObj, '__iter__') but I am not sure how foolproof this is. | <p>Is there a method like <code>isiterable</code>? The only solution I have found so far is to call:</p>
<pre class="lang-py prettyprint-override"><code>hasattr(myObj, '__iter__')
</code></pre>
<p>but I am not sure how foolproof this is.</p>
| [
{
"answerId": 1952481,
"score": 1086,
"isAccepted": true,
"createdAt": "2009-12-23T12:16:43",
"ownerDisplayName": "miku",
"ownerUserId": 89391,
"bodyText": "Checking for __iter__ works on sequence types, but it would fail on e.g. strings in Python 2 . I would like to know the right answe... | 1 |
6269765 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/6269765/what-does-the-b-character-do-in-front-of-a-string-literal | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 6,269,765 | What does the 'b' character do in front of a string literal? | 1,468 | 1,352,862 | 12 | true | true | [
"python",
"string",
"unicode",
"binary"
] | 2011-06-07T18:14:52 | 2026-02-22T19:19:24 | Jesse Webb | false | CC BY-SA 4.0 | 6,269,785 | 346,561 | 45,671 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Apparently, the following is the valid syntax: b'The string' I would like to know: What does this b character in front of the string mean? What are the effects of using it? What are appropriate situations to use it? I found a related question right here on SO, but that question is about PHP though, and it states the b ... | <p>Apparently, the following is the valid syntax:</p>
<pre><code>b'The string'
</code></pre>
<p>I would like to know:</p>
<ol>
<li>What does this <code>b</code> character in front of the string mean?</li>
<li>What are the effects of using it?</li>
<li>What are appropriate situations to use it?</li>
</ol>
<p>I found a <... | [
{
"answerId": 6273618,
"score": 1271,
"isAccepted": false,
"createdAt": "2011-06-08T02:34:37",
"ownerDisplayName": "dan04",
"ownerUserId": 287586,
"bodyText": "Python 3.x makes a clear distinction between the types: str = '...' literals = a sequence of characters . A “character” is a bas... | 1 |
2682745 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/2682745/how-do-i-create-a-constant-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 2,682,745 | How do I create a constant in Python? | 1,456 | 1,616,550 | 45 | true | true | [
"python",
"constants"
] | 2010-04-21T12:20:18 | 2026-07-24T15:23:06 | zfranciscus | false | CC BY-SA 4.0 | 2,682,752 | 166,264 | 17,285 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I declare a constant in Python? In Java, we do: public static final String CONST_NAME = "Name"; | <p>How do I declare a constant in Python?</p>
<p>In Java, we do:</p>
<pre class="lang-java prettyprint-override"><code>public static final String CONST_NAME = "Name";
</code></pre>
| [
{
"answerId": 2682752,
"score": 1446,
"isAccepted": true,
"createdAt": "2010-04-21T12:21:54",
"ownerDisplayName": "Felix Kling",
"ownerUserId": 218196,
"bodyText": "You cannot declare a variable or value as constant in Python. To indicate to programmers that a variable is a constant, one... | 1 |
73663 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/73663/how-do-i-terminate-a-script | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 73,663 | How do I terminate a script? | 1,446 | 2,244,553 | 12 | true | true | [
"python",
"termination"
] | 2008-09-16T15:35:55 | 2026-03-15T19:56:06 | Teifion | false | CC BY-SA 4.0 | 73,673 | 1,384,652 | 111,901 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I exit a script early, like the die() command in PHP? | <p>How do I exit a script early, like the <code>die()</code> command in PHP?</p>
| [
{
"answerId": 73673,
"score": 1860,
"isAccepted": true,
"createdAt": "2008-09-16T15:36:36",
"ownerDisplayName": "pjz",
"ownerUserId": 8002,
"bodyText": "import sys sys.exit() This will exit with status code 0; if you don't want that, you can pass a different one or a message: sys.exit(1)... | 1 |
17330160 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/17330160/how-does-the-property-decorator-work-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 17,330,160 | How does the @property decorator work in Python? | 1,430 | 911,993 | 15 | true | true | [
"python",
"properties",
"decorator",
"python-decorators",
"python-internals"
] | 2013-06-26T20:47:15 | 2025-07-19T12:36:58 | ashim | false | CC BY-SA 4.0 | 17,330,273 | 1,082,727 | 25,930 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I would like to understand how the built-in function property works. What confuses me is that property can also be used as a decorator, but it only takes arguments when used as a built-in function and not when used as a decorator. This example is from the documentation : class C: def __init__(self): self._x = None def ... | <p>I would like to understand how the built-in function <code>property</code> works. What confuses me is that <code>property</code> can also be used as a decorator, but it only takes arguments when used as a built-in function and not when used as a decorator.</p>
<p>This example is from the <a href="http://docs.python.... | [
{
"answerId": 17330273,
"score": 1350,
"isAccepted": true,
"createdAt": "2013-06-26T20:54:27",
"ownerDisplayName": "Martijn Pieters",
"ownerUserId": 100297,
"bodyText": "The property() function returns a special descriptor object : >>> property() <property object at 0x10ff07940> It is th... | 1 |
10715965 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/10715965/create-a-pandas-dataframe-by-appending-one-row-at-a-time | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 10,715,965 | Create a Pandas Dataframe by appending one row at a time | 1,430 | 2,504,050 | 32 | true | true | [
"python",
"pandas",
"dataframe",
"append"
] | 2012-05-23T08:12:31 | 2024-06-09T02:30:19 | PhE | true | null | 24,888,331 | 31,335 | 16,764 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I create an empty DataFrame , then add rows, one by one? I created an empty DataFrame : df = pd.DataFrame(columns=('lib', 'qty1', 'qty2')) Then I can add a new row at the end and fill a single field with: df = df._set_value(index=len(df), col='qty1', value=10.0) It works for only one field at a time. What is a b... | <p>How do I create an empty <code>DataFrame</code>, then add rows, one by one?</p>
<p>I created an empty <code>DataFrame</code>:</p>
<pre><code>df = pd.DataFrame(columns=('lib', 'qty1', 'qty2'))
</code></pre>
<p>Then I can add a new row at the end and fill a single field with:</p>
<pre><code>df = df._set_value(index=le... | null | 0 |
8609192 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/8609192/what-is-the-difference-between-null-true-and-blank-true-in-django | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 8,609,192 | What is the difference between null=True and blank=True in Django? | 1,430 | 594,878 | 30 | true | true | [
"python",
"django",
"django-models",
"django-admin"
] | 2011-12-22T20:11:03 | 2024-02-08T18:25:45 | user993563 | false | CC BY-SA 4.0 | 8,609,425 | 993,563 | 19,561 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | When we add a model field in Django we generally write: models.CharField(max_length=100, null=True, blank=True) The same is done with ForeignKey , DecimalField etc. What is the basic difference between: null=True only blank=True only null=True and blank=True in respect to different ( CharField , ForeignKey , ManyToMany... | <p>When we add a model field in Django we generally write:</p>
<pre><code>models.CharField(max_length=100, null=True, blank=True)
</code></pre>
<p>The same is done with <code>ForeignKey</code>, <code>DecimalField</code> etc. What is the basic difference between:</p>
<ol>
<li><code>null=True</code> only</li>
<li><code>b... | [
{
"answerId": 8609425,
"score": 1659,
"isAccepted": true,
"createdAt": "2011-12-22T20:35:26",
"ownerDisplayName": "Chris Pratt",
"ownerUserId": 654031,
"bodyText": "null=True sets NULL (versus NOT NULL ) on the column in your DB. Blank values for Django field types such as DateTimeField ... | 1 |
843277 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/843277/how-do-i-check-if-a-variable-exists | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 843,277 | How do I check if a variable exists? | 1,427 | 1,936,817 | 16 | true | true | [
"python",
"exception",
"variables"
] | 2009-05-09T13:10:31 | 2025-06-03T06:53:11 | Max Frai | false | CC BY-SA 4.0 | 843,293 | 87,152 | 64,832 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I want to check if a variable exists. Now I'm doing something like this: try: myVar except NameError: # Do something. Are there other ways without exceptions? | <p>I want to check if a variable exists. Now I'm doing something like this:</p>
<pre><code>try:
myVar
except NameError:
# Do something.
</code></pre>
<p>Are there other ways without exceptions?</p>
| [
{
"answerId": 843293,
"score": 2377,
"isAccepted": true,
"createdAt": "2009-05-09T13:16:05",
"ownerDisplayName": "Ayman Hourieh",
"ownerUserId": 40005,
"bodyText": "To check the existence of a local variable: if 'myVar' in locals(): # myVar exists. To check the existence of a global vari... | 1 |
11248073 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/11248073/how-do-i-remove-all-packages-installed-by-pip | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 11,248,073 | How do I remove all packages installed by pip? | 1,419 | 1,857,510 | 34 | true | true | [
"python",
"pip",
"virtualenv",
"python-packaging"
] | 2012-06-28T15:36:44 | 2024-03-31T18:02:12 | blueberryfields | false | CC BY-SA 4.0 | 11,250,821 | 173,773 | 51,716 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I uninstall all packages installed by pip from my currently activated virtual environment? | <p>How do I uninstall all packages installed by pip from my currently activated virtual environment?</p>
| [
{
"answerId": 11250821,
"score": 1992,
"isAccepted": true,
"createdAt": "2012-06-28T18:32:29",
"ownerDisplayName": "blueberryfields",
"ownerUserId": 173773,
"bodyText": "I've found this snippet as an alternative solution. It's a more graceful removal of libraries than remaking the virtua... | 2 |
53162 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/53162/how-can-i-do-a-line-break-line-continuation-in-python-split-up-a-long-line-of | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 53,162 | How can I do a line break (line continuation) in Python (split up a long line of source code)? | 1,417 | 2,757,506 | 11 | true | true | [
"python",
"syntax",
"line-breaks",
"long-lines"
] | 2008-09-09T23:45:30 | 2025-03-28T15:26:04 | Ray | false | CC BY-SA 4.0 | 53,180 | 4,872 | 194,066 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Given: e = 'a' + 'b' + 'c' + 'd' How do I write the above in two lines? e = 'a' + 'b' + 'c' + 'd' See also: How do I split the definition of a long string over multiple lines? if there is a long string literal in the code that needs to be broken up to wrap the line nicely. | <p>Given:</p>
<pre><code>e = 'a' + 'b' + 'c' + 'd'
</code></pre>
<p>How do I write the above in two lines?</p>
<pre><code>e = 'a' + 'b' +
'c' + 'd'
</code></pre>
<hr />
<p><sub>See also: <a href="https://stackoverflow.com/questions/10660435">How do I split the definition of a long string over multiple lines?</a> if... | [
{
"answerId": 53180,
"score": 1591,
"isAccepted": true,
"createdAt": "2008-09-09T23:52:05",
"ownerDisplayName": "Harley Holcombe",
"ownerUserId": 1057,
"bodyText": "What is the line? You can just have arguments on the next line without any problems: a = dostuff(blahblah1, blahblah2, blah... | 1 |
533631 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/533631/what-is-a-mixin-and-why-is-it-useful | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 533,631 | What is a mixin and why is it useful? | 1,413 | 585,236 | 17 | true | true | [
"python",
"oop",
"multiple-inheritance",
"mixins",
"python-class"
] | 2009-02-10T18:50:42 | 2025-09-08T15:40:47 | TarkaDaal | false | CC BY-SA 4.0 | 547,714 | 55,155 | 19,836 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | In Programming Python , Mark Lutz mentions the term mixin . I am from a C/C++/C# background and I have not heard the term before. What is a mixin? Reading between the lines of this example (which I have linked to because it is quite long), I am presuming it is a case of using multiple inheritance to extend a class as o... | <p>In <a href="https://rads.stackoverflow.com/amzn/click/com/0596009259" rel="noreferrer" rel="nofollow noreferrer"><em>Programming Python</em></a>, Mark Lutz mentions the term <em>mixin</em>. I am from a C/C++/C# background and I have not heard the term before. What is a mixin?</p>
<p>Reading between the lines of <a h... | null | 0 |
8369219 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/8369219/how-can-i-read-a-text-file-into-a-string-variable-and-strip-newlines | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 8,369,219 | How can I read a text file into a string variable and strip newlines? | 1,411 | 2,467,975 | 27 | true | true | [
"python",
"string"
] | 2011-12-03T16:47:54 | 2026-04-19T05:09:10 | klijo | false | CC BY-SA 4.0 | 8,369,345 | 963,489 | 16,601 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I have a text file that looks like: ABC DEF How can I read the file into a single-line string without newlines, in this case creating a string 'ABCDEF' ? For reading the file into a list of lines, but removing the trailing newline character from each line, see How to read a file without newlines? . | <p>I have a text file that looks like:</p>
<pre><code>ABC
DEF
</code></pre>
<p>How can I read the file into a single-line string without newlines, in this case creating a string <code>'ABCDEF'</code>?</p>
<hr />
<p><sub>For reading the file into a <em>list</em> of lines, but removing the trailing newline character from... | [
{
"answerId": 8369345,
"score": 1978,
"isAccepted": true,
"createdAt": "2011-12-03T17:06:34",
"ownerDisplayName": "sleeplessnerd",
"ownerUserId": 616486,
"bodyText": "You could use: with open('data.txt', 'r') as file: data = file.read().replace('\\n', '') Or if the file content is guaran... | 1 |
3940128 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/3940128/how-do-i-reverse-a-list-or-loop-over-it-backwards | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 3,940,128 | How do I reverse a list or loop over it backwards? | 1,411 | 2,144,774 | 18 | true | true | [
"python",
"list",
"reverse"
] | 2010-10-15T06:59:39 | 2025-03-01T03:12:52 | Leo.peis | false | CC BY-SA 4.0 | 3,940,144 | 476,595 | 14,521 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I iterate over a list in reverse in Python? See also: How can I get a reversed copy of a list (avoid a separate statement when chaining a method after .reverse)? | <p>How do I iterate over a list in reverse in Python?</p>
<hr />
<p><sub>See also: <a href="https://stackoverflow.com/questions/4280691/">How can I get a reversed copy of a list (avoid a separate statement when chaining a method after .reverse)?</a></sub></p>
| [
{
"answerId": 3940144,
"score": 1737,
"isAccepted": true,
"createdAt": "2010-10-15T07:02:20",
"ownerDisplayName": "codaddict",
"ownerUserId": 227665,
"bodyText": "To get a new reversed list, apply the reversed function and collect the items into a list : >>> xs = [0, 10, 20, 40] >>> list... | 2 |
2802726 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/2802726/putting-a-simple-if-then-else-statement-on-one-line | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 2,802,726 | Putting a simple if-then-else statement on one line | 1,404 | 2,782,691 | 5 | true | true | [
"python",
"if-statement",
"syntax",
"conditional-operator"
] | 2010-05-10T12:58:04 | 2023-07-25T14:50:07 | Abizern | true | null | 2,802,748 | 41,116 | 152,007 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I write an if - then - else statement in Python so that it fits on one line? For example, I want a one line version of: if count == N: count = 0 else: count = N + 1 In Objective-C, I would write this as: count = count == N ? 0 : count + 1; | <p>How do I write an <code>if</code>-<code>then</code>-<code>else</code> statement in Python so that it fits on one line?</p>
<p>For example, I want a one line version of:</p>
<pre><code>if count == N:
count = 0
else:
count = N + 1
</code></pre>
<p>In Objective-C, I would write this as:</p>
<pre><code>count = c... | [
{
"answerId": 2802748,
"score": 2626,
"isAccepted": true,
"createdAt": "2010-05-10T13:00:17",
"ownerDisplayName": "cmsjr",
"ownerUserId": 23114,
"bodyText": "That's more specifically a ternary operator expression than an if-then, here's the python syntax value_when_true if condition else... | 1 |
19482970 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/19482970/get-a-list-from-pandas-dataframe-column-headers | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 19,482,970 | Get a list from Pandas DataFrame column headers | 1,396 | 2,452,844 | 25 | true | true | [
"python",
"pandas",
"dataframe",
"list",
"header"
] | 2013-10-20T21:18:37 | 2023-09-16T19:35:57 | natsuki_2002 | false | CC BY-SA 4.0 | 19,483,025 | 2,428,549 | 25,649 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I want to get a list of the column headers from a Pandas DataFrame. The DataFrame will come from user input, so I won't know how many columns there will be or what they will be called. For example, if I'm given a DataFrame like this: y gdp cap 0 1 2 5 1 2 3 9 2 8 7 2 3 3 4 7 4 6 7 7 5 4 8 3 6 8 2 8 7 9 9 10 8 6 6 4 9 1... | <p>I want to get a list of the column headers from a Pandas DataFrame. The DataFrame will come from user input, so I won't know how many columns there will be or what they will be called.</p>
<p>For example, if I'm given a DataFrame like this:</p>
<pre class="lang-none prettyprint-override"><code> y gdp cap
0 1... | [
{
"answerId": 19483025,
"score": 2072,
"isAccepted": true,
"createdAt": "2013-10-20T21:23:07",
"ownerDisplayName": "Simeon Visser",
"ownerUserId": 1267329,
"bodyText": "You can get the values as a list by doing: list(my_dataframe.columns.values) Also you can simply use (as shown in Ed Ch... | 1 |
8384737 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/8384737/extract-file-name-from-path-no-matter-what-the-os-path-format | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 8,384,737 | Extract file name from path, no matter what the os/path format | 1,395 | 2,538,936 | 23 | true | true | [
"python",
"path"
] | 2011-12-05T11:39:49 | 2024-12-12T20:36:43 | BuZz | false | CC BY-SA 4.0 | 8,384,788 | 1,029,944 | 17,695 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Which Python library can I use to extract filenames from paths, no matter what the operating system or path format could be? For example, I'd like all of these paths to return me c : a/b/c/ a/b/c \a\b\c \a\b\c\ a\b\c a/b/../../a/b/c/ a/b/../../a/b/c | <p>Which Python library can I use to extract filenames from paths, no matter what the operating system or path format could be?</p>
<p>For example, I'd like all of these paths to return me <code>c</code>:</p>
<pre><code>a/b/c/
a/b/c
\a\b\c
\a\b\c\
a\b\c
a/b/../../a/b/c/
a/b/../../a/b/c
</code></pre>
| [
{
"answerId": 8384838,
"score": 1982,
"isAccepted": false,
"createdAt": "2011-12-05T11:49:16",
"ownerDisplayName": "stranac",
"ownerUserId": 975755,
"bodyText": "There's a function that returns exactly what you want import os print(os.path.basename(your_path)) WARNING: When os.path.basen... | 2 |
12096252 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/12096252/use-a-list-of-values-to-select-rows-from-a-pandas-dataframe | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 12,096,252 | Use a list of values to select rows from a Pandas dataframe | 1,394 | 1,828,927 | 9 | true | true | [
"python",
"pandas",
"dataframe",
"indexing",
"filter"
] | 2012-08-23T16:31:12 | 2025-03-19T13:29:16 | zach | false | CC BY-SA 4.0 | 12,098,586 | 983,191 | 31,473 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Let’s say I have the following Pandas dataframe: df = DataFrame({'A': [5,6,3,4], 'B': [1,2,3,5]}) df A B 0 5 1 1 6 2 2 3 3 3 4 5 I can subset based on a specific value: x = df[df['A'] == 3] x A B 2 3 3 But how can I subset based on a list of values? - something like this: list_of_values = [3, 6] y = df[df['A'] in list_... | <p>Let’s say I have the following Pandas dataframe:</p>
<pre><code>df = DataFrame({'A': [5,6,3,4], 'B': [1,2,3,5]})
df
A B
0 5 1
1 6 2
2 3 3
3 4 5
</code></pre>
<p>I can subset based on a specific value:</p>
<pre><code>x = df[df['A'] == 3]
x
A B
2 3 3
</code></pre>
<p>But how ca... | [
{
"answerId": 12098586,
"score": 2291,
"isAccepted": true,
"createdAt": "2012-08-23T19:20:12",
"ownerDisplayName": "Wouter Overmeire",
"ownerUserId": 1548051,
"bodyText": "You can use the isin method: In [1]: df = pd.DataFrame({'A': [5,6,3,4], 'B': [1,2,3,5]}) In [2]: df Out[2]: A B 0 5 ... | 1 |
6159900 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/6159900/correct-way-to-write-line-to-file | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 6,159,900 | Correct way to write line to file? | 1,392 | 2,911,857 | 17 | true | true | [
"python",
"file-io"
] | 2011-05-28T05:44:53 | 2023-08-31T15:22:15 | Yaroslav Bulatov | false | CC BY-SA 4.0 | 6,160,082 | 419,116 | 58,139 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I write a line to a file in modern Python? I heard that this is deprecated: print >>f, "hi there" Also, does "\n" work on all platforms, or should I use "\r\n" on Windows? | <p>How do I write a line to a file in modern Python? I heard that this is deprecated:</p>
<pre><code>print >>f, "hi there"
</code></pre>
<p>Also, does <code>"\n"</code> work on all platforms, or should I use <code>"\r\n"</code> on Windows?</p>
| [
{
"answerId": 6160082,
"score": 1597,
"isAccepted": true,
"createdAt": "2011-05-28T06:36:52",
"ownerDisplayName": "johnsyweb",
"ownerUserId": 78845,
"bodyText": "This should be as simple as: with open('somefile.txt', 'a') as the_file: the_file.write('Hello\\n') From The Documentation: Do... | 1 |
3277367 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/3277367/how-does-pythons-super-work-with-multiple-inheritance | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 3,277,367 | How does Python's super() work with multiple inheritance? | 1,389 | 705,804 | 18 | true | true | [
"python",
"multiple-inheritance"
] | 2010-07-18T21:40:25 | 2023-06-23T16:16:08 | Callisto | false | CC BY-SA 4.0 | 3,277,407 | 395,354 | 13,911 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How does super() work with multiple inheritance? For example, given: class First(object): def __init__(self): print "first" class Second(object): def __init__(self): print "second" class Third(First, Second): def __init__(self): super(Third, self).__init__() print "that's it" Which parent method of Third does super()._... | <p>How does <code>super()</code> work with multiple inheritance? For example, given:</p>
<pre><code>class First(object):
def __init__(self):
print "first"
class Second(object):
def __init__(self):
print "second"
class Third(First, Second):
def __init__(self):
su... | null | 0 |
761804 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/761804/how-do-i-trim-whitespace-from-a-string | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 761,804 | How do I trim whitespace from a string? | 1,389 | 1,463,239 | 14 | true | true | [
"python",
"string",
"trim"
] | 2009-04-17T19:16:06 | 2023-12-10T03:40:46 | robert | false | CC BY-SA 4.0 | 761,825 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I remove leading and trailing whitespace from a string in Python? " Hello world " --> "Hello world" " Hello world" --> "Hello world" "Hello world " --> "Hello world" "Hello world" --> "Hello world" | <p>How do I remove leading and trailing whitespace from a string in Python?</p>
<pre><code>" Hello world " --> "Hello world"
" Hello world" --> "Hello world"
"Hello world " --> "Hello world"
"Hello world" --> "Hello world"
<... | [
{
"answerId": 761825,
"score": 2018,
"isAccepted": true,
"createdAt": "2009-04-17T19:21:29",
"ownerDisplayName": "Brian",
"ownerUserId": 9493,
"bodyText": "To remove all whitespace surrounding a string, use .strip() . Examples: >>> ' Hello '.strip() 'Hello' >>> ' Hello'.strip() 'Hello' >... | 1 |
33533148 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/33533148/how-do-i-type-hint-a-method-with-the-type-of-the-enclosing-class | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 33,533,148 | How do I type hint a method with the type of the enclosing class? | 1,387 | 413,996 | 9 | true | true | [
"python",
"pycharm",
"python-typing"
] | 2015-11-04T22:17:54 | 2025-04-07T03:53:54 | Michael van Gerwen | false | CC BY-SA 4.0 | 33,533,514 | 4,665,133 | 13,981 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I have the following code in Python 3: class Position: def __init__(self, x: int, y: int): self.x = x self.y = y def __add__(self, other: Position) -> Position: return Position(self.x + other.x, self.y + other.y) But my editor (PyCharm) says that the reference Position can not be resolved (in the __add__ method). How s... | <p>I have the following code in Python 3:</p>
<pre><code>class Position:
def __init__(self, x: int, y: int):
self.x = x
self.y = y
def __add__(self, other: Position) -> Position:
return Position(self.x + other.x, self.y + other.y)
</code></pre>
<p>But my editor (PyCharm) says that t... | [
{
"answerId": 33533514,
"score": 1801,
"isAccepted": true,
"createdAt": "2015-11-04T22:44:33",
"ownerDisplayName": "Paulo Scardine",
"ownerUserId": 444036,
"bodyText": "I guess you got this exception: NameError: name 'Position' is not defined This is because in the original implementatio... | 1 |
16819222 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/16819222/how-do-i-return-dictionary-keys-as-a-list-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 16,819,222 | How do I return dictionary keys as a list in Python? | 1,383 | 2,245,051 | 13 | true | true | [
"python",
"python-3.x",
"list",
"dictionary"
] | 2013-05-29T16:24:16 | 2023-02-27T21:29:21 | user2015601 | false | CC BY-SA 4.0 | 16,819,250 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | With Python 2.7, I can get dictionary keys , values , or items as a list : >>> newdict = {1:0, 2:0, 3:0} >>> newdict.keys() [1, 2, 3] With Python >= 3.3, I get: >>> newdict.keys() dict_keys([1, 2, 3]) How do I get a plain list of keys with Python 3? | <p>With Python 2.7, I can get dictionary <em>keys</em>, <em>values</em>, or <em>items</em> as a <code>list</code>:</p>
<pre><code>>>> newdict = {1:0, 2:0, 3:0}
>>> newdict.keys()
[1, 2, 3]
</code></pre>
<p>With Python >= 3.3, I get:</p>
<pre><code>>>> newdict.keys()
dict_keys([1, 2, 3])
</... | [
{
"answerId": 16819250,
"score": 1722,
"isAccepted": true,
"createdAt": "2013-05-29T16:25:40",
"ownerDisplayName": "Chris ",
"ownerUserId": 935692,
"bodyText": "This will convert the dict_keys object to a list : list(newdict.keys()) On the other hand, you should ask yourself whether or n... | 1 |
237079 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/237079/how-do-i-get-file-creation-and-modification-date-times | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 237,079 | How do I get file creation and modification date/times? | 1,382 | 1,357,570 | 13 | true | true | [
"python",
"file"
] | 2008-10-25T21:54:56 | 2026-02-05T10:02:58 | Mark Biek | false | CC BY-SA 4.0 | 52,858,040 | 305 | 152,309 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | What's the best cross-platform way to get file creation and modification dates/times, that works on both Linux and Windows? | <p>What's the best cross-platform way to get file creation and modification dates/times, that works on both Linux and Windows?</p>
| null | 0 |
227459 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/227459/how-to-get-the-ascii-value-of-a-character | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 227,459 | How to get the ASCII value of a character | 1,366 | 1,934,016 | 7 | true | true | [
"python",
"ascii"
] | 2008-10-22T20:39:57 | 2024-06-01T15:45:12 | Matt | false | CC BY-SA 4.0 | 227,472 | 17,693 | 89,027 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I get the ASCII value of a character as an int in Python? | <p>How do I get the <a href="https://en.wikipedia.org/wiki/ASCII" rel="noreferrer">ASCII</a> value of a character as an <code>int</code> in Python?</p>
| [
{
"answerId": 227472,
"score": 1822,
"isAccepted": true,
"createdAt": "2008-10-22T20:43:04",
"ownerDisplayName": "Matt J",
"ownerUserId": 18528,
"bodyText": "From here : The function ord() gets the int value of the char. And in case you want to convert back after playing with the number,... | 1 |
2998215 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/2998215/if-python-is-interpreted-what-are-pyc-files | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 2,998,215 | If Python is interpreted, what are .pyc files? | 1,365 | 721,104 | 13 | true | true | [
"python",
"compiled",
"interpreted-language",
"pyc"
] | 2010-06-08T14:27:13 | 2025-01-03T23:01:54 | froadie | false | CC BY-SA 4.0 | 2,998,228 | 259,541 | 83,880 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Python is an interpreted language. But why does my source directory contain .pyc files, which are identified by Windows as "Compiled Python Files"? | <p>Python is an interpreted language. But why does my source directory contain <code>.pyc</code> files, which are identified by Windows as "Compiled Python Files"?</p>
| [
{
"answerId": 2998544,
"score": 1226,
"isAccepted": false,
"createdAt": "2010-06-08T15:00:58",
"ownerDisplayName": "Alex Martelli",
"ownerUserId": 95810,
"bodyText": "I've been given to understand that Python is an interpreted language... This popular meme is incorrect, or, rather, const... | 1 |
2709821 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/2709821/what-is-the-purpose-of-the-self-parameter-why-is-it-needed | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 2,709,821 | What is the purpose of the `self` parameter? Why is it needed? | 1,362 | 1,115,878 | 27 | true | true | [
"python",
"class",
"oop",
"self"
] | 2010-04-25T20:22:28 | 2025-09-30T06:30:09 | richzilla | false | CC BY-SA 4.0 | 2,709,832 | 301,032 | 42,368 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Consider this example: class MyClass: def func(self, name): self.name = name I know that self refers to the specific instance of MyClass . But why must func explicitly include self as a parameter? Why do we need to use self in the method's code? Some other languages make this implicit, or use special syntax instead. Fo... | <p>Consider this example:</p>
<pre class="lang-py prettyprint-override"><code>class MyClass:
def func(self, name):
self.name = name
</code></pre>
<p>I know that <code>self</code> refers to the specific instance of <code>MyClass</code>. But why must <code>func</code> explicitly include <code>self</code> as a... | null | 0 |
715417 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/715417/converting-from-a-string-to-boolean-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 715,417 | Converting from a string to boolean in Python | 1,362 | 1,535,376 | 43 | true | true | [
"python",
"string",
"boolean"
] | 2009-04-03T19:44:20 | 2025-10-15T07:17:49 | Joan Venge | false | CC BY-SA 4.0 | 715,455 | 51,816 | 334,709 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I convert a string into a boolean in Python? This attempt returns True : >>> bool("False") True | <p>How do I convert a string into a boolean in Python? This attempt returns <code>True</code>:</p>
<pre><code>>>> bool("False")
True
</code></pre>
| [
{
"answerId": 715455,
"score": 1420,
"isAccepted": true,
"createdAt": "2009-04-03T19:52:56",
"ownerDisplayName": "Keith Gaughan",
"ownerUserId": 8342,
"bodyText": "Really, you just compare the string to whatever you expect to accept as representing true, so you can do this: s == 'True' O... | 1 |
1155617 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/1155617/count-the-number-of-occurrences-of-a-character-in-a-string | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 1,155,617 | Count the number of occurrences of a character in a string | 1,358 | 1,966,914 | 26 | true | true | [
"python",
"string",
"count"
] | 2009-07-20T20:00:36 | 2023-07-08T23:11:58 | Mat | false | CC BY-SA 4.0 | 1,155,647 | 42,974 | 87,620 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I count the number of occurrences of a character in a string? e.g. 'a' appears in 'Mary had a little lamb' 4 times. | <p>How do I count the number of occurrences of a character in a string?</p>
<p>e.g. <code>'a'</code> appears in <code>'Mary had a little lamb'</code> 4 times.</p>
| [
{
"answerId": 1155647,
"score": 1868,
"isAccepted": true,
"createdAt": "2009-07-20T20:04:26",
"ownerDisplayName": "Ogre Codes",
"ownerUserId": 133867,
"bodyText": "str.count(sub[, start[, end]]) Return the number of non-overlapping occurrences of substring sub in the range [start, end] .... | 1 |
534839 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/534839/how-to-create-a-guid-uuid-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 534,839 | How to create a GUID/UUID in Python | 1,345 | 1,393,538 | 8 | true | true | [
"python",
"uuid",
"guid",
"uniqueidentifier"
] | 2009-02-10T23:51:21 | 2024-06-05T23:59:13 | Jonathon Watney | false | CC BY-SA 4.0 | 534,847 | 59,180 | 22,438 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I create a GUID/UUID in Python that is platform independent? I hear there is a method using ActivePython on Windows but it's Windows only because it uses COM. Is there a method using plain Python? | <p>How do I create a GUID/UUID in Python that is platform independent? I hear there is a method using ActivePython on Windows but it's Windows only because it uses COM. Is there a method using plain Python?</p>
| [
{
"answerId": 534847,
"score": 1651,
"isAccepted": true,
"createdAt": "2009-02-10T23:54:26",
"ownerDisplayName": "stuartd",
"ownerUserId": 43846,
"bodyText": "The uuid module provides immutable UUID objects (the UUID class) and the functions uuid1() , uuid3() , uuid4() , uuid5() for gene... | 1 |
12555323 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/12555323/how-to-add-a-new-column-to-an-existing-dataframe | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 12,555,323 | How to add a new column to an existing DataFrame | 1,344 | 2,861,856 | 33 | true | true | [
"python",
"pandas",
"dataframe",
"chained-assignment"
] | 2012-09-23T19:00:01 | 2025-02-04T23:17:05 | tomasz74 | false | CC BY-SA 4.0 | 12,555,510 | 1,661,173 | 16,791 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I have the following indexed DataFrame with named columns and rows not- continuous numbers: a b c d 2 0.671399 0.101208 -0.181532 0.241273 3 0.446172 -0.243316 0.051767 1.577318 5 0.614758 0.075793 -0.451460 -0.012493 I would like to add a new column, 'e' , to the existing data frame and do not want to change anything ... | <p>I have the following indexed DataFrame with named columns and rows not- continuous numbers:</p>
<pre class="lang-none prettyprint-override"><code> a b c d
2 0.671399 0.101208 -0.181532 0.241273
3 0.446172 -0.243316 0.051767 1.577318
5 0.614758 0.075793 -0.451460 -0.012493
</c... | [
{
"answerId": 12555510,
"score": 1324,
"isAccepted": true,
"createdAt": "2012-09-23T19:24:45",
"ownerDisplayName": "joaquin",
"ownerUserId": 308903,
"bodyText": "Edit 2017 As indicated in the comments and by @Alexander, currently the best method to add the values of a Series as a new col... | 1 |
739993 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/739993/how-do-i-get-a-list-of-locally-installed-python-modules | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 739,993 | How do I get a list of locally installed Python modules? | 1,334 | 2,145,470 | 34 | true | true | [
"python",
"module",
"pip"
] | 2009-04-11T12:34:18 | 2026-04-21T13:03:58 | Léo Léopold Hertz 준영 | false | CC BY-SA 4.0 | 23,885,252 | 54,964 | 143,634 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I get a list of Python modules installed on my computer? | <p>How do I get a list of Python modules installed on my computer?</p>
| [
{
"answerId": 740018,
"score": 1343,
"isAccepted": false,
"createdAt": "2009-04-11T12:45:45",
"ownerDisplayName": "ChristopheD",
"ownerUserId": 81179,
"bodyText": "help('modules') in a Python shell/prompt."
}
] | 1 |
1504717 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/1504717/why-does-comparing-strings-using-either-or-is-sometimes-produce-a-differe | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 1,504,717 | Why does comparing strings using either '==' or 'is' sometimes produce a different result? | 1,333 | 1,712,316 | 15 | true | true | [
"python",
"string",
"comparison",
"identity",
"equality"
] | 2009-10-01T15:40:14 | 2025-06-19T07:47:42 | jottos | true | null | 1,504,742 | 14,555 | 20,474 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Two string variables are set to the same value. s1 == s2 always returns True , but s1 is s2 sometimes returns False . If I open my Python interpreter and do the same is comparison, it succeeds: >>> s1 = 'text' >>> s2 = 'text' >>> s1 is s2 True Why is this? | <p>Two string variables are set to the same value. <code>s1 == s2</code> always returns <code>True</code>, but <code>s1 is s2</code> sometimes returns <code>False</code>.</p>
<p>If I open my Python interpreter and do the same <code>is</code> comparison, it succeeds:</p>
<pre><code>>>> s1 = 'text'
>>> ... | [
{
"answerId": 1504742,
"score": 1699,
"isAccepted": true,
"createdAt": "2009-10-01T15:45:20",
"ownerDisplayName": "SilentGhost",
"ownerUserId": 12855,
"bodyText": "is is identity testing, and == is equality testing. What happens in your code would be emulated in the interpreter like this... | 1 |
7604966 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/7604966/maximum-and-minimum-values-for-ints | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 7,604,966 | Maximum and Minimum values for ints | 1,323 | 2,318,467 | 12 | true | true | [
"python",
"integer"
] | 2011-09-30T01:01:06 | 2023-11-07T07:30:43 | bdhar | false | CC BY-SA 4.0 | 7,604,981 | 139,909 | 23,451 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I represent minimum and maximum values for integers in Python? In Java, we have Integer.MIN_VALUE and Integer.MAX_VALUE . See also: What is the maximum float in Python? . | <p>How do I represent minimum and maximum values for integers in Python? In Java, we have <code>Integer.MIN_VALUE</code> and <code>Integer.MAX_VALUE</code>.</p>
<hr />
<p><sub>See also: <a href="https://stackoverflow.com/questions/3477283">What is the maximum float in Python?</a>.</sub></p>
| [
{
"answerId": 7604981,
"score": 1348,
"isAccepted": true,
"createdAt": "2011-09-30T01:03:49",
"ownerDisplayName": "senderle",
"ownerUserId": 577088,
"bodyText": "Python 3 In Python 3, this question doesn't apply. The plain int type is unbounded. However, you might actually be looking for... | 1 |
845058 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/845058/how-to-get-the-line-count-of-a-large-file-cheaply-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 845,058 | How to get the line count of a large file cheaply in Python | 1,323 | 1,172,772 | 44 | true | true | [
"python",
"text-files",
"line-count"
] | 2009-05-10T10:22:05 | 2023-11-03T21:19:20 | SilentGhost | false | CC BY-SA 4.0 | 845,081 | 12,855 | 322,971 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I get a line count of a large file in the most memory- and time-efficient manner? def file_len(filename): with open(filename) as f: for i, _ in enumerate(f): pass return i + 1 | <p>How do I get a line count of a large file in the most memory- and time-efficient manner?</p>
<pre><code>def file_len(filename):
with open(filename) as f:
for i, _ in enumerate(f):
pass
return i + 1
</code></pre>
| null | 0 |
2349991 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/2349991/how-do-i-import-other-python-files | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 2,349,991 | How do I import other Python files? | 1,317 | 3,286,420 | 23 | true | true | [
"python",
"import",
"python-import",
"python-module",
"python-packaging"
] | 2010-02-28T03:40:11 | 2025-01-19T02:03:45 | Tamer | false | CC BY-SA 4.0 | 2,349,998 | 282,944 | 13,187 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I import files in Python? I want to import: a file (e.g. file.py ) a folder a file dynamically at runtime, based on user input one specific part of a file (e.g. a single function) | <p>How do I import files in Python? I want to import:</p>
<ol>
<li>a file (e.g. <code>file.py</code>)</li>
<li>a folder</li>
<li>a file dynamically at runtime, based on user input</li>
<li>one specific part of a file (e.g. a single function)</li>
</ol>
| [
{
"answerId": 20749411,
"score": 1551,
"isAccepted": false,
"createdAt": "2013-12-23T18:46:10",
"ownerDisplayName": "Eric Leschinski",
"ownerUserId": 445131,
"bodyText": "There are many ways to import a Python file, all with their pros and cons. Don't just hastily pick the first import s... | 1 |
27885397 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/27885397/how-do-i-install-a-python-package-with-a-whl-file | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 27,885,397 | How do I install a Python package with a .whl file? | 1,312 | 2,817,927 | 18 | true | true | [
"python",
"pip",
"python-wheel"
] | 2015-01-11T08:48:34 | 2024-11-19T15:37:29 | e9t | false | CC BY-SA 4.0 | 27,909,082 | 1,054,939 | 16,680 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I'm trying to install a Python package on Windows, using Christoph Gohlke's Windows binaries here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype The package is made available here as a .whl file. How do I install that? | <p>I'm trying to install a Python package on Windows, using Christoph Gohlke's Windows binaries here:</p>
<p><a href="http://www.lfd.uci.edu/%7Egohlke/pythonlibs/#jpype" rel="noreferrer">http://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype</a></p>
<p>The package is made available here as a <code>.whl</code> file. How do I ... | [
{
"answerId": 27909082,
"score": 1552,
"isAccepted": true,
"createdAt": "2015-01-12T19:12:41",
"ownerDisplayName": "kpierce8",
"ownerUserId": 76235,
"bodyText": "I just used the following which was quite simple. First open a console then cd to where you've downloaded your file like some-... | 1 |
1663807 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/1663807/how-do-i-iterate-through-two-lists-in-parallel | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 1,663,807 | How do I iterate through two lists in parallel? | 1,312 | 1,350,761 | 9 | true | true | [
"python",
"list",
"for-loop",
"iterator"
] | 2009-11-02T21:26:24 | 2024-02-15T15:10:49 | Nathan Fellman | false | CC BY-SA 4.0 | 1,663,826 | 1,084 | 129,106 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I have two iterables, and I want to go over them in pairs: foo = [1, 2, 3] bar = [4, 5, 6] for (f, b) in iterate_together(foo, bar): print("f:", f, " | b:", b) That should result in: f: 1 | b: 4 f: 2 | b: 5 f: 3 | b: 6 One way to do it is to iterate over the indices: for i in range(len(foo)): print("f:", foo[i], " | b:... | <p>I have two iterables, and I want to go over them in pairs:</p>
<pre class="lang-py prettyprint-override"><code>foo = [1, 2, 3]
bar = [4, 5, 6]
for (f, b) in iterate_together(foo, bar):
print("f:", f, " | b:", b)
</code></pre>
<p>That should result in:</p>
<pre class="lang-none prettyprint-o... | [
{
"answerId": 1663826,
"score": 2024,
"isAccepted": true,
"createdAt": "2009-11-02T21:28:27",
"ownerDisplayName": "unutbu",
"ownerUserId": 190597,
"bodyText": "Python 3 for f, b in zip(foo, bar): print(f, b) zip stops when the shorter of foo or bar stops. In Python 3 , zip returns an ite... | 1 |
1823058 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/1823058/how-to-print-a-number-using-commas-as-thousands-separators | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 1,823,058 | How to print a number using commas as thousands separators | 1,311 | 1,053,870 | 26 | true | true | [
"python",
"number-formatting"
] | 2009-11-30T23:11:43 | 2025-09-17T14:14:06 | Elias Zamaria | false | CC BY-SA 4.0 | 10,742,904 | 28,324 | 101,964 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I print an integer with commas as thousands separators? 1234567 ⟶ 1,234,567 It does not need to be locale-specific to decide between periods and commas. | <p>How do I print an integer with commas as thousands separators?</p>
<pre><code>1234567 ⟶ 1,234,567
</code></pre>
<p>It does not need to be locale-specific to decide between periods and commas.</p>
| [
{
"answerId": 10742904,
"score": 2572,
"isAccepted": true,
"createdAt": "2012-05-24T18:02:17",
"ownerDisplayName": "Ian Schneider",
"ownerUserId": 1415726,
"bodyText": "Locale-agnostic: use _ as the thousand separator f'{value:_}' # For Python ≥3.6 Note that this will NOT format in the u... | 1 |
472000 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/472000/usage-of-slots | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 472,000 | Usage of __slots__? | 1,310 | 445,272 | 14 | true | true | [
"python",
"oop",
"python-internals",
"slots"
] | 2009-01-23T05:37:23 | 2026-07-14T08:27:39 | Jeb | false | CC BY-SA 4.0 | 28,059,785 | 31,830 | 17,269 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | What is the purpose of __slots__ in Python — especially with respect to when I would want to use it, and when not? | <p>What is the purpose of <a href="https://docs.python.org/3/reference/datamodel.html#slots" rel="noreferrer"><code>__slots__</code></a> in Python — especially with respect to when I would want to use it, and when not?</p>
| [
{
"answerId": 28059785,
"score": 1899,
"isAccepted": true,
"createdAt": "2015-01-21T04:46:42",
"ownerDisplayName": "Aaron Hall",
"ownerUserId": 541136,
"bodyText": "TLDR The special attribute __slots__ allows you to explicitly state which instance attributes you expect your object instan... | 1 |
10434599 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/10434599/get-the-data-received-in-a-flask-request | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 10,434,599 | Get the data received in a Flask request | 1,304 | 1,968,742 | 26 | true | true | [
"python",
"flask",
"werkzeug"
] | 2012-05-03T15:31:26 | 2024-10-15T18:31:08 | ddinchev | false | CC BY-SA 4.0 | 16,664,376 | 762,886 | 34,873 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I want to be able to get the data sent to my Flask app. I've tried accessing request.data but it is an empty string. How do you access request data? from flask import request @app.route('/', methods=['GET', 'POST']) def parse_request(): data = request.data # data is empty # need posted data here The answer to this ques... | <p>I want to be able to get the data sent to my Flask app. I've tried accessing <code>request.data</code> but it is an empty string. How do you access request data?</p>
<pre class="lang-py prettyprint-override"><code>from flask import request
@app.route('/', methods=['GET', 'POST'])
def parse_request():
data = re... | [
{
"answerId": 16664376,
"score": 2247,
"isAccepted": true,
"createdAt": "2013-05-21T07:25:07",
"ownerDisplayName": "Robert",
"ownerUserId": 634089,
"bodyText": "The docs describe the attributes available on the request object ( from flask import request ) during a request. In most common... | 1 |
6908143 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/6908143/should-i-put-shebang-in-python-scripts-and-what-form-should-it-take | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 6,908,143 | Should I put #! (shebang) in Python scripts, and what form should it take? | 1,299 | 969,106 | 15 | true | true | [
"python",
"shell",
"python-3.x",
"shebang"
] | 2011-08-02T06:35:42 | 2023-10-21T19:39:37 | treecoder | false | CC BY-SA 3.0 | 19,305,076 | 1,206,051 | 45,669 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Should I put the shebang in my Python scripts? In what form? #!/usr/bin/env python or #!/usr/local/bin/python Are these equally portable? Which form is used most? Note: the tornado project uses the shebang. On the other hand the Django project doesn't. | <p>Should I put the shebang in my Python scripts? In what form?</p>
<pre class="lang-none prettyprint-override"><code>#!/usr/bin/env python
</code></pre>
<p>or</p>
<pre class="lang-none prettyprint-override"><code>#!/usr/local/bin/python
</code></pre>
<p>Are these equally portable? Which form is used most?</p>
<p... | [
{
"answerId": 19305076,
"score": 1736,
"isAccepted": true,
"createdAt": "2013-10-10T19:58:55",
"ownerDisplayName": "GlassGhost",
"ownerUserId": 144020,
"bodyText": "The shebang line in any script determines the script's ability to be executed like a standalone executable without typing p... | 1 |
7571635 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/7571635/fastest-way-to-check-if-a-value-exists-in-a-list | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 7,571,635 | Fastest way to check if a value exists in a list | 1,291 | 3,079,585 | 12 | true | true | [
"python",
"list",
"performance",
"membership"
] | 2011-09-27T15:23:26 | 2026-02-10T19:06:53 | Jean-Francois Gallant | false | CC BY-SA 4.0 | 7,571,665 | 967,334 | 14,173 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | What is the fastest way to check if a value exists in a very large list (with millions of values) and what its index is? | <p>What is the fastest way to check if a value exists in a very large list (with millions of values) and what its index is?</p>
| [
{
"answerId": 7571665,
"score": 2213,
"isAccepted": true,
"createdAt": "2011-09-27T15:25:11",
"ownerDisplayName": "Rafe Kettler",
"ownerUserId": 399815,
"bodyText": "7 in a Clearest and fastest way to do it. You can also consider using a set , but constructing that set from your list may... | 1 |
403421 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/403421/how-do-i-sort-a-list-of-objects-based-on-an-attribute-of-the-objects | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 403,421 | How do I sort a list of objects based on an attribute of the objects? | 1,291 | 1,072,159 | 10 | true | true | [
"python",
"list",
"sorting",
"reverse"
] | 2008-12-31T16:41:32 | 2025-08-31T21:51:39 | Nick Sergeant | false | CC BY-SA 4.0 | 403,426 | 22,468 | 38,803 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I have a list of Python objects that I want to sort by a specific attribute of each object: [Tag(name="toe", count=10), Tag(name="leg", count=2), ...] How do I sort the list by .count in descending order? | <p>I have a list of Python objects that I want to sort by a specific attribute of each object:</p>
<pre><code>[Tag(name="toe", count=10), Tag(name="leg", count=2), ...]
</code></pre>
<p>How do I sort the list by <code>.count</code> in descending order?</p>
| [
{
"answerId": 403426,
"score": 2047,
"isAccepted": true,
"createdAt": "2008-12-31T16:42:59",
"ownerDisplayName": "Kenan Banks",
"ownerUserId": 43089,
"bodyText": "To sort the list in place: orig_list.sort(key=lambda x: x.count, reverse=True) To return a new list, use sorted : new_list = ... | 1 |
8270092 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/8270092/remove-all-whitespace-in-a-string | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 8,270,092 | Remove all whitespace in a string | 1,286 | 3,100,130 | 16 | true | true | [
"python",
"string",
"trim",
"removing-whitespace"
] | 2011-11-25T13:51:21 | 2024-09-25T02:42:06 | Kalanamith | false | CC BY-SA 4.0 | 8,270,146 | 1,004,875 | 20,944 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I want to eliminate all the whitespace from a string, on both ends, and in between words. I have this Python code: def my_handle(self): sentence = ' hello apple ' sentence.strip() But that only eliminates the whitespace on both sides of the string. How do I remove all whitespace? | <p>I want to eliminate all the whitespace from a string, on both ends, and in between words.</p>
<p>I have this Python code:</p>
<pre class="lang-py prettyprint-override"><code>def my_handle(self):
sentence = ' hello apple '
sentence.strip()
</code></pre>
<p>But that only eliminates the whitespace on both sid... | [
{
"answerId": 8270146,
"score": 2424,
"isAccepted": true,
"createdAt": "2011-11-25T13:56:30",
"ownerDisplayName": "Cédric Julien",
"ownerUserId": 718618,
"bodyText": "If you want to remove leading and ending whitespace, use str.strip() : >>> \" hello apple \".strip() 'hello apple' If you... | 1 |
129507 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/129507/how-do-you-test-that-a-python-function-throws-an-exception | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 129,507 | How do you test that a Python function throws an exception? | 1,278 | 1,026,785 | 20 | true | true | [
"python",
"unit-testing",
"exception"
] | 2008-09-24T20:00:35 | 2025-03-02T13:38:31 | Daryl Spitzer | false | CC BY-SA 4.0 | 129,522 | 4,766 | 151,222 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How does one write a unit test that fails only if a function doesn't throw an expected exception? | <p>How does one write a unit test that fails only if a function doesn't throw an expected exception?</p>
| [
{
"answerId": 129522,
"score": 1047,
"isAccepted": true,
"createdAt": "2008-09-24T20:02:29",
"ownerDisplayName": "Moe",
"ownerUserId": 3051,
"bodyText": "Use TestCase.assertRaises from the unittest module, for example: import mymod class MyTestCase(unittest.TestCase): def test1(self): se... | 1 |
19124601 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/19124601/pretty-print-an-entire-pandas-series-dataframe | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 19,124,601 | Pretty-print an entire Pandas Series / DataFrame | 1,270 | 1,701,286 | 15 | true | true | [
"python",
"pandas",
"dataframe"
] | 2013-10-01T19:46:07 | 2025-04-07T04:01:41 | Dun Peal | false | CC BY-SA 4.0 | 30,691,921 | 916,907 | 18,039 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I work with Series and DataFrames on the terminal a lot. The default __repr__ for a Series returns a reduced sample, with some head and tail values, but the rest missing. Is there a builtin way to pretty-print the entire Series / DataFrame? Ideally, it would support proper alignment, perhaps borders between columns, an... | <p>I work with Series and DataFrames on the terminal a lot. The default <code>__repr__</code> for a Series returns a reduced sample, with some head and tail values, but the rest missing.</p>
<p>Is there a builtin way to pretty-print the entire Series / DataFrame? Ideally, it would support proper alignment, perhaps bo... | [
{
"answerId": 30691921,
"score": 1601,
"isAccepted": true,
"createdAt": "2015-06-07T09:22:15",
"ownerDisplayName": "tsvikas",
"ownerUserId": 550269,
"bodyText": "You can also use the option_context , with one or more options: with pd.option_context('display.max_rows', None, 'display.max_... | 2 |
3462143 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/3462143/get-difference-between-two-lists-with-unique-entries | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 3,462,143 | Get difference between two lists with Unique Entries | 1,270 | 1,570,460 | 33 | true | true | [
"python",
"performance",
"list",
"set",
"set-difference"
] | 2010-08-11T19:38:10 | 2023-08-15T08:27:33 | Max Frai | false | CC BY-SA 4.0 | 3,462,160 | 87,152 | 64,832 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I have two lists in Python: temp1 = ['One', 'Two', 'Three', 'Four'] temp2 = ['One', 'Two'] Assuming the elements in each list are unique, I want to create a third list with items from the first list which are not in the second list: temp3 = ['Three', 'Four'] Are there any fast ways without cycles and checking? | <p>I have two lists in Python:</p>
<pre><code>temp1 = ['One', 'Two', 'Three', 'Four']
temp2 = ['One', 'Two']
</code></pre>
<p>Assuming the elements in each list are unique, I want to create a third list with items from the first list which are not in the second list:</p>
<pre><code>temp3 = ['Three', 'Four']
</code></pr... | [
{
"answerId": 3462160,
"score": 1822,
"isAccepted": true,
"createdAt": "2010-08-11T19:40:00",
"ownerDisplayName": "ars",
"ownerUserId": 2611,
"bodyText": "To get elements which are in temp1 but not in temp2 ( assuming uniqueness of the elements in each list ): In [5]: list(set(temp1) - s... | 1 |
12453580 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/12453580/how-to-concatenate-join-items-in-a-list-to-a-single-string | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 12,453,580 | How to concatenate (join) items in a list to a single string | 1,265 | 2,434,741 | 12 | true | true | [
"python",
"string",
"list",
"concatenation"
] | 2012-09-17T05:32:25 | 2024-03-23T22:45:15 | alvas | true | null | 12,453,584 | 610,569 | 123,749 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I concatenate a list of strings into a single string? For example, given ['this', 'is', 'a', 'sentence'] , how do I get "this-is-a-sentence" ? For handling a few strings in separate variables , see How do I append one string to another in Python? . For the opposite process - creating a list from a string - see H... | <p>How do I concatenate a list of strings into a single string?</p>
<p>For example, given <code>['this', 'is', 'a', 'sentence']</code>, how do I get <code>"this-is-a-sentence"</code>?</p>
<hr />
<p><sub>For handling a few strings in <em>separate variables</em>, see <a href="https://stackoverflow.com/questions... | [
{
"answerId": 12453584,
"score": 2098,
"isAccepted": true,
"createdAt": "2012-09-17T05:33:41",
"ownerDisplayName": "Burhan Khalid",
"ownerUserId": 790387,
"bodyText": "Use str.join : >>> words = ['this', 'is', 'a', 'sentence'] >>> '-'.join(words) 'this-is-a-sentence' >>> ' '.join(words) ... | 1 |
4028904 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/4028904/what-is-a-cross-platform-way-to-get-the-home-directory | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 4,028,904 | What is a cross-platform way to get the home directory? | 1,262 | 728,564 | 5 | true | true | [
"python",
"cross-platform",
"home-directory"
] | 2010-10-26T23:43:19 | 2025-10-03T14:19:01 | Nathan Osman | false | CC BY-SA 4.0 | 4,028,943 | 193,619 | 73,759 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I need to get the location of the home directory of the current logged-on user. Currently, I've been using the following on Linux: os.getenv("HOME") However, this does not work on Windows. What is the correct cross-platform way to do this ? | <p>I need to get the location of the home directory of the current logged-on user. Currently, I've been using the following on Linux:</p>
<pre class="lang-py prettyprint-override"><code>os.getenv("HOME")
</code></pre>
<p>However, this does not work on Windows. What is the correct cross-platform way to do this... | [
{
"answerId": 4028943,
"score": 2173,
"isAccepted": true,
"createdAt": "2010-10-26T23:52:39",
"ownerDisplayName": "Dan",
"ownerUserId": 287279,
"bodyText": "On Python 3.5+ you can use pathlib.Path.home() : from pathlib import Path home = Path.home() # example usage: with open(home / \".s... | 1 |
2970608 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/2970608/what-are-named-tuples-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 2,970,608 | What are "named tuples" in Python? | 1,255 | 715,439 | 14 | true | true | [
"python",
"types",
"tuples",
"terminology",
"namedtuple"
] | 2010-06-03T23:50:16 | 2024-08-25T01:46:25 | Denilson Sá Maia | false | CC BY-SA 4.0 | 2,970,722 | 124,946 | 50,047 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | What are named tuples and how do I use them? When should I use named tuples instead of normal tuples, or vice versa? Are there "named lists" too? (i.e. mutable named tuples) For the last question specifically, see also Existence of mutable named tuple in Python? . | <ul>
<li>What are named tuples and how do I use them?</li>
<li>When should I use named tuples instead of normal tuples, or vice versa?</li>
<li>Are there "named lists" too? (i.e. mutable named tuples)</li>
</ul>
<hr />
<p><sub>For the last question specifically, see also <a href="https://stackoverflow.com/que... | [
{
"answerId": 2970722,
"score": 1548,
"isAccepted": true,
"createdAt": "2010-06-04T00:19:37",
"ownerDisplayName": "fmark",
"ownerUserId": 103225,
"bodyText": "Named tuples are basically easy-to-create, lightweight object types. Named tuple instances can be referenced using object-like va... | 1 |
1185524 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/1185524/how-do-i-trim-whitespace | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 1,185,524 | How do I trim whitespace? | 1,254 | 1,352,980 | 15 | true | true | [
"python",
"string",
"whitespace",
"trim",
"strip"
] | 2009-07-26T20:54:38 | 2022-06-22T04:15:54 | Chris | false | CC BY-SA 4.0 | 1,185,529 | 104,060 | 22,425 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Is there a Python function that will trim whitespace (spaces and tabs) from a string? So that given input " \t example string\t " becomes "example string" . | <p>Is there a Python function that will trim whitespace (spaces and tabs) from a string?</p>
<p>So that given input <code>" \t example string\t "</code> becomes <code>"example string"</code>.</p>
| [
{
"answerId": 1185529,
"score": 1834,
"isAccepted": true,
"createdAt": "2009-07-26T20:56:26",
"ownerDisplayName": "James Thompson",
"ownerUserId": 57458,
"bodyText": "For whitespace on both sides, use str.strip : s = \" \\t a string example\\t \" s = s.strip() For whitespace on the right... | 1 |
10214827 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/10214827/find-which-version-of-package-is-installed-with-pip | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 10,214,827 | Find which version of package is installed with pip | 1,246 | 1,726,760 | 17 | true | true | [
"python",
"pip"
] | 2012-04-18T17:37:20 | 2025-12-24T14:52:32 | Alexis | false | CC BY-SA 3.0 | 10,215,100 | 207,795 | 25,631 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Using pip, is it possible to figure out which version of a package is currently installed? I know about pip install XYZ --upgrade but I am wondering if there is anything like pip info XYZ . If not what would be the best way to tell what version I am currently using. | <p>Using pip, is it possible to figure out which version of a package is currently installed?</p>
<p>I know about <code>pip install XYZ --upgrade</code> but I am wondering if there is anything like <code>pip info XYZ</code>. If not what would be the best way to tell what version I am currently using.</p>
| [
{
"answerId": 10215100,
"score": 1750,
"isAccepted": true,
"createdAt": "2012-04-18T17:53:51",
"ownerDisplayName": "AdamKG",
"ownerUserId": 16361,
"bodyText": "As of pip 1.3 , there is a pip show command. $ pip show Jinja2 --- Name: Jinja2 Version: 2.7.3 Location: /path/to/virtualenv/lib... | 1 |
20101834 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/20101834/pip-install-from-git-repo-branch | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 20,101,834 | pip install from git repo branch | 1,231 | 1,153,766 | 11 | true | true | [
"python",
"git",
"pip"
] | 2013-11-20T16:46:42 | 2025-10-31T02:53:10 | goh | false | CC BY-SA 4.0 | 20,101,940 | 357,236 | 29,929 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Trying to pip install a repo's specific branch. Google tells me to pip install https://github.com/user/repo.git@branch The branch's name is issue/34/oscar-0.6 so I did pip install https://github.com/tangentlabs/django-oscar-paypal.git@/issue/34/oscar-0.6 but its returning a 404. How do I install this branch? | <p>Trying to <code>pip</code> install a repo's specific branch. Google tells me to</p>
<pre><code>pip install https://github.com/user/repo.git@branch
</code></pre>
<p>The branch's name is <code>issue/34/oscar-0.6</code> so I did <code>pip install https://github.com/tangentlabs/django-oscar-paypal.git@/issue/34/oscar-0... | [
{
"answerId": 20101940,
"score": 1646,
"isAccepted": true,
"createdAt": "2013-11-20T16:51:32",
"ownerDisplayName": "falsetru",
"ownerUserId": 2225682,
"bodyText": "Prepend the url prefix git+ (See VCS Support ): pip install git+https://github.com/tangentlabs/django-oscar-paypal.git@issue... | 1 |
441147 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/441147/how-to-subtract-a-day-from-a-date | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 441,147 | How to subtract a day from a date? | 1,226 | 1,305,260 | 8 | true | true | [
"python",
"date",
"datetime",
"timedelta"
] | 2009-01-13T22:39:36 | 2023-02-22T23:46:58 | defrex | false | CC BY-SA 4.0 | 441,152 | 6,007 | 16,575 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I have a Python datetime.datetime object. What is the best way to subtract one day? | <p>I have a Python <a href="https://docs.python.org/3/library/datetime.html#datetime-objects" rel="noreferrer"><code>datetime.datetime</code></a> object. What is the best way to subtract one day?</p>
| [
{
"answerId": 441152,
"score": 2051,
"isAccepted": true,
"createdAt": "2009-01-13T22:41:39",
"ownerDisplayName": "Steve B.",
"ownerUserId": 19479,
"bodyText": "You can use a timedelta object: from datetime import datetime, timedelta d = datetime.today() - timedelta(days=days_to_subtract)... | 1 |
988228 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/988228/convert-a-string-representation-of-a-dictionary-to-a-dictionary | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 988,228 | Convert a String representation of a Dictionary to a dictionary | 1,222 | 1,549,988 | 13 | true | true | [
"python",
"string",
"dictionary",
"type-conversion"
] | 2009-06-12T18:25:02 | 2024-07-10T01:18:32 | UberJumper | false | CC BY-SA 4.0 | 988,251 | 34,395 | 21,465 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How can I convert the str representation of a dictionary, such as the following string, into a dict ? s = "{'muffin' : 'lolz', 'foo' : 'kitty'}" I prefer not to use eval . What else can I use? | <p>How can I convert the <code>str</code> representation of a dictionary, such as the following string, into a <code>dict</code>?</p>
<pre class="lang-py prettyprint-override"><code>s = "{'muffin' : 'lolz', 'foo' : 'kitty'}"
</code></pre>
<p>I prefer not to use <code>eval</code>. What else can I use?</p>
| [
{
"answerId": 988251,
"score": 1757,
"isAccepted": true,
"createdAt": "2009-06-12T18:30:45",
"ownerDisplayName": "Jacob Gabrielson",
"ownerUserId": 68127,
"bodyText": "You can use the built-in ast.literal_eval : >>> import ast >>> ast.literal_eval(\"{'muffin' : 'lolz', 'foo' : 'kitty'}\"... | 1 |
886221 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/886221/has-django-served-an-excess-of-100k-daily-visits | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 886,221 | Has Django served an excess of 100k daily visits? | 1,221 | 211,262 | 29 | true | true | [
"python",
"django",
"web-applications",
"scalability"
] | 2009-05-20T05:07:55 | 2023-03-14T19:24:56 | Roee Adler | true | null | 886,645 | 103,532 | 34,134 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I'm building a web application with Django. The reasons I chose Django were: I wanted to work with free/open-source tools. I like Python and feel it's a long-term language, whereas regarding Ruby I wasn't sure, and PHP seemed like a huge hassle to learn. I'm building a prototype for an idea and wasn't thinking too much... | <p>I'm building a web application with Django. The reasons I chose Django were:</p>
<ul>
<li>I wanted to work with free/open-source tools.</li>
<li>I like Python and feel it's a <strong>long-term</strong> language, whereas regarding Ruby I wasn't sure, and PHP seemed like a huge hassle to learn.</li>
<li>I'm building a... | null | 0 |
20638006 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/20638006/convert-list-of-dictionaries-to-a-pandas-dataframe | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 20,638,006 | Convert list of dictionaries to a pandas DataFrame | 1,219 | 1,033,835 | 8 | true | true | [
"python",
"dictionary",
"pandas",
"dataframe"
] | 2013-12-17T15:24:51 | 2024-02-24T15:54:59 | appleLover | false | CC BY-SA 4.0 | 20,638,258 | 1,560,517 | 15,839 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How can I convert a list of dictionaries into a DataFrame? I want to turn [{'points': 50, 'time': '5:00', 'year': 2010}, {'points': 25, 'time': '6:00', 'month': "february"}, {'points':90, 'time': '9:00', 'month': 'january'}, {'points_h1':20, 'month': 'june'}] into month points points_h1 time year 0 NaN 50 NaN 5:00 2010... | <p>How can I convert a list of dictionaries into a DataFrame?
I want to turn</p>
<pre class="lang-py prettyprint-override"><code>[{'points': 50, 'time': '5:00', 'year': 2010},
{'points': 25, 'time': '6:00', 'month': "february"},
{'points':90, 'time': '9:00', 'month': 'january'},
{'points_h1':20, 'month'... | [
{
"answerId": 20638258,
"score": 1697,
"isAccepted": true,
"createdAt": "2013-12-17T15:35:13",
"ownerDisplayName": "joris",
"ownerUserId": 653364,
"bodyText": "If ds is a list of dict s: df = pd.DataFrame(ds) Note: this does not work with nested data."
}
] | 1 |
2793324 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/2793324/is-there-a-simple-way-to-delete-a-list-element-by-value | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 2,793,324 | Is there a simple way to delete a list element by value? | 1,217 | 2,046,528 | 27 | true | true | [
"python",
"list"
] | 2010-05-08T07:48:28 | 2025-03-18T13:32:10 | zjm1126 | false | CC BY-SA 4.0 | 2,793,341 | 234,322 | 67,657 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | I want to remove a value from a list if it exists in the list (which it may not). a = [1, 2, 3, 4] b = a.index(6) del a[b] print(a) The above gives the error: ValueError: list.index(x): x not in list So I have to do this: a = [1, 2, 3, 4] try: b = a.index(6) del a[b] except: pass print(a) But is there not a simpler way... | <p>I want to remove a value from a list if it exists in the list (which it may not).</p>
<pre><code>a = [1, 2, 3, 4]
b = a.index(6)
del a[b]
print(a)
</code></pre>
<p>The above gives the error:</p>
<pre class="lang-none prettyprint-override"><code>ValueError: list.index(x): x not in list
</code></pre>
<p>So I have to ... | [
{
"answerId": 2793341,
"score": 1914,
"isAccepted": true,
"createdAt": "2010-05-08T07:56:03",
"ownerDisplayName": "Johannes Charra",
"ownerUserId": 178560,
"bodyText": "To remove the first occurrence of an element, use list.remove : >>> xs = ['a', 'b', 'c', 'd'] >>> xs.remove('b') >>> pr... | 1 |
11520492 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/11520492/difference-between-del-remove-and-pop-on-lists-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 11,520,492 | Difference between del, remove, and pop on lists in Python | 1,213 | 2,068,651 | 15 | true | true | [
"python",
"list"
] | 2012-07-17T10:21:41 | 2024-02-21T07:50:54 | sachin irukula | false | CC BY-SA 4.0 | 11,520,540 | 1,477,714 | 13,049 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | Is there any difference between these three methods to remove an element from a list in Python? a = [1, 2, 3] a.remove(2) a # [1, 3] a = [1, 2, 3] del a[1] a # [1, 3] a = [1, 2, 3] a.pop(1) # 2 a # [1, 3] | <p>Is there any difference between these three methods to remove an element from a list in Python?</p>
<pre class="lang-py prettyprint-override"><code>a = [1, 2, 3]
a.remove(2)
a # [1, 3]
a = [1, 2, 3]
del a[1]
a # [1, 3]
a = [1, 2, 3]
a.pop(1) # 2
a # [1, 3]
</code></... | [
{
"answerId": 11520540,
"score": 1695,
"isAccepted": true,
"createdAt": "2012-07-17T10:24:09",
"ownerDisplayName": "Martijn Pieters",
"ownerUserId": 100297,
"bodyText": "The effects of the three different methods to remove an element from a list: remove removes the first matching value ,... | 1 |
2104080 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/2104080/how-do-i-check-file-size-in-python | OcN7A9CDxbrWVwaw5 | unPv1LuxmpaTYkIgE | 2,104,080 | How do I check file size in Python? | 1,212 | 1,137,763 | 11 | true | true | [
"python",
"file"
] | 2010-01-20T18:58:29 | 2025-01-02T18:06:38 | 5YrsLaterDBA | false | CC BY-SA 4.0 | 2,104,107 | 117,039 | 35,126 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | How do I get the size of a file in Python? | <p>How do I get the size of a file in Python?</p>
| [
{
"answerId": 2104083,
"score": 1560,
"isAccepted": false,
"createdAt": "2010-01-20T18:59:16",
"ownerDisplayName": "danben",
"ownerUserId": 217332,
"bodyText": "Use os.path.getsize : >>> import os >>> os.path.getsize(\"/path/to/file.mp3\") 2071611 The output is in bytes."
},
{
"a... | 2 |
79989978 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989978/importerror-cannot-import-name-builddependencyinstallerror-while-compiling-py | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,978 | ImportError: cannot import name 'BuildDependencyInstallError' while compiling Python Kivy 2.1.0 with Buildozer 1.4.0 | 1 | 20 | 1 | false | false | [
"python",
"pip",
"importerror",
"buildozer",
"python-3.10"
] | 2026-08-03T00:09:37 | 2026-08-03T00:38:36 | Triangle Brannsverberder | false | CC BY-SA 4.0 | null | 32,994,876 | 11 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989814 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989814/why-do-my-nested-loops-only-execute-once-in-python-leetcode-longest-palindromi | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,814 | Why do my nested loops only execute once in Python? (LeetCode Longest Palindromic Substring) | -4 | 74 | 0 | false | false | [
"python"
] | 2026-08-02T04:05:03 | 2026-08-02T07:48:54 | James | true | null | null | 32,991,740 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989759 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989759/how-to-ping-back-to-client-with-python-socket-io | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,759 | How to ping back to client with Python socket.io | -3 | 42 | 0 | false | false | [
"python",
"flask",
"flask-socketio"
] | 2026-08-01T19:34:10 | 2026-08-01T19:37:50 | Noah Bergh | true | null | null | 32,919,780 | 27 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989687 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989687/pywin32-excel-com-pastespecial-fails-with-all-the-merged-cells-need-to-be-the | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,687 | pywin32 Excel COM: PasteSpecial fails with “all the merged cells need to be the same size” when writing into a sheet with merged cells | 0 | 50 | 0 | false | false | [
"python",
"excel",
"pywin32",
"win32com"
] | 2026-08-01T12:24:56 | 2026-08-01T15:32:04 | Dhimesh Parmar | false | CC BY-SA 4.0 | null | 9,254,892 | 11 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989600 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989600/pyqt-stuck-in-loop-window-not-opening | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,600 | pyqt - stuck in loop, window not opening | -3 | 58 | 0 | false | false | [
"python",
"user-interface",
"pyqt"
] | 2026-07-31T22:21:15 | 2026-07-31T22:21:15 | samrad Tangestani | true | null | null | 29,950,733 | 13 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989585 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989585/how-do-i-get-the-autocomplete-hints-to-work-for-items-in-my-generic-dictionary-c | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,585 | How do I get the autocomplete hints to work for items in my generic dictionary class? | 2 | 121 | 1 | true | false | [
"python",
"python-typing"
] | 2026-07-31T20:55:30 | 2026-08-01T02:54:28 | iamthebull | false | CC BY-SA 4.0 | null | 8,512,755 | 351 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989572 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989572/how-to-programmatically-add-missing-elements-into-a-list-of-arguments | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,572 | How to programmatically add missing elements into a list of arguments | -5 | 113 | 0 | false | false | [
"python",
"list"
] | 2026-07-31T19:42:12 | 2026-08-01T05:47:06 | troppapolvere | true | null | null | 16,501,119 | 115 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989568 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989568/why-is-scrapy-not-returning-items-despite-crawling | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,568 | Why is scrapy not returning items despite crawling? | 2 | 62 | 1 | true | false | [
"python",
"web-scraping",
"scrapy"
] | 2026-07-31T19:15:50 | 2026-08-01T00:26:42 | Gabriel Silva | false | CC BY-SA 4.0 | null | 32,229,208 | 29 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989494 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989494/excel-com-autofilter-fails-with-1004-on-valid-relative-field-range-av5er15 | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,494 | Excel COM AutoFilter fails with 1004 on valid relative Field (range $AV$5:$ER$1501, Field=101) after PivotTable refresh (Python win32com) | 1 | 67 | 1 | false | false | [
"python",
"excel",
"autofilter"
] | 2026-07-31T13:31:01 | 2026-08-01T06:33:02 | Dhimesh Parmar | false | CC BY-SA 4.0 | null | 9,254,892 | 11 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989470 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989470/apply-a-user-defined-function-udf-to-pandas | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,470 | Apply a user-defined function (UDF) to Pandas | -4 | 170 | 2 | true | false | [
"python",
"pandas",
"user-defined-functions"
] | 2026-07-31T11:44:38 | 2026-07-31T18:43:11 | kpra | false | CC BY-SA 4.0 | null | 4,309,315 | 25 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989338 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989338/trying-to-change-a-pixel-in-python | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,338 | Trying to Change A Pixel in Python | 2 | 191 | 1 | true | false | [
"python",
"numpy",
"opencv",
"matplotlib",
"variable-assignment"
] | 2026-07-31T00:39:31 | 2026-07-31T15:13:18 | Razgriz | false | CC BY-SA 4.0 | null | 32,984,248 | 39 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989280 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989280/connectionreseterror-winerror-10054-in-asyncio-proactor-event-loop-on-windows | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,280 | ConnectionResetError: [WinError 10054] in asyncio Proactor event loop on Windows (Python 3.13) without explicit socket handling | 1 | 87 | 1 | true | true | [
"python",
"python-3.x",
"windows",
"socket.io",
"webrtc"
] | 2026-07-30T18:22:23 | 2026-07-31T14:03:51 | Zain Ul Abidin | false | CC BY-SA 4.0 | 79,989,500 | 2,355,176 | 2,770 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989086 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989086/yaml-scanner-scannererror-mapping-values-are-not-allowed-here-error-when-tryi | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,086 | yaml.scanner.ScannerError: mapping values are not allowed here - error when trying to use Detectron2 for layout mapping in WSL2 in Windows 11 | -1 | 56 | 0 | false | false | [
"python",
"yaml",
"detectron",
"pdf-extraction"
] | 2026-07-30T06:25:54 | 2026-07-30T12:48:11 | Bussller | false | CC BY-SA 4.0 | null | 4,661,875 | 2,082 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989072 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989072/constraint-programming-beginner-why-arent-my-constraints-showing-up | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,072 | Constraint Programming beginner -- why aren't my constraints showing up? | -4 | 124 | 0 | false | false | [
"python",
"or-tools",
"constraint-programming"
] | 2026-07-30T05:42:24 | 2026-07-31T13:42:15 | Chip Uni | false | CC BY-SA 4.0 | null | 209,359 | 7,534 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79989057 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79989057/ppo-agent-refuses-to-place-orders-in-custom-gymnasium-inventory-environment-stu | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,989,057 | PPO Agent refuses to place orders in custom Gymnasium Inventory Environment (stuck in local minimum) | -1 | 50 | 0 | false | false | [
"python",
"reinforcement-learning",
"inventory-management",
"gymnasium",
"stablebaseline3"
] | 2026-07-30T03:58:34 | 2026-07-30T03:58:34 | Ryan Foster | false | CC BY-SA 4.0 | null | 31,272,945 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79988040 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79988040/copy-to-stdout-with-csv-header-always-hangs | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,988,040 | Copy to stdout with CSV header always hangs | 1 | 126 | 2 | true | false | [
"python",
"sqlalchemy",
"psycopg3"
] | 2026-07-30T01:12:05 | 2026-07-30T19:14:16 | Jim Garrison | false | CC BY-SA 4.0 | null | 18,157 | 87,148 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79988030 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79988030/how-do-i-get-correct-type-hints-in-subclass | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,988,030 | How do I get correct type hints in subclass? | 2 | 130 | 2 | true | true | [
"python",
"python-typing",
"type-hinting"
] | 2026-07-30T00:16:28 | 2026-07-31T15:45:30 | iamthebull | false | CC BY-SA 4.0 | 79,989,235 | 8,512,755 | 351 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
79988026 | question | stackoverflow | 2026-08-03T01:37:29 | null | null | null | null | null | https://stackoverflow.com/questions/79988026/b64encode-b64decode-unbalanced-encoding | 2EnEpWXmgrDNgcaO7 | OPgwtXmLxaEk9xGVW | 79,988,026 | b64encode() / b64decode - unbalanced encoding | 0 | 123 | 3 | true | true | [
"python"
] | 2026-07-29T22:56:36 | 2026-07-30T04:03:00 | NickC | false | CC BY-SA 4.0 | 79,988,042 | 669,301 | 1,421 | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.