File: remove_ccbysa_snippets.patch

package info (click to toggle)
pandas 2.2.3%2Bdfsg-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 66,784 kB
  • sloc: python: 422,228; ansic: 9,190; sh: 270; xml: 102; makefile: 83
file content (229 lines) | stat: -rw-r--r-- 8,537 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
Description: Remove code from Stack Overflow

Stack Overflow content is CC-BY-SA licensed,
which this package is not supposed to be.  These snippets may be
too small to be copyrightable, but removing them to be safe.

https://lists.debian.org/debian-legal/2020/04/threads.html#00018

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Forwarded: no - deletes some tests/examples without replacement

--- /dev/null
+++ b/doc/source/user_guide/cookbook.rst
@@ -0,0 +1,22 @@
+.. _cookbook:
+
+{{ header }}
+
+.. _cookbook.idioms:
+.. _cookbook.selection:
+.. _cookbook.multi_index:
+.. _cookbook.missing_data:
+.. _cookbook.grouping:
+.. _cookbook.pivot:
+.. _cookbook.resample:
+.. _cookbook.merge:
+.. _cookbook.plotting:
+.. _cookbook.csv:
+.. _cookbook.csv.multiple_files:
+.. _cookbook.sql:
+.. _cookbook.excel:
+.. _cookbook.html:
+.. _cookbook.hdf:
+.. _cookbook.binary:
+
+This page has been removed for copyright reasons.
--- a/doc/source/user_guide/index.rst
+++ b/doc/source/user_guide/index.rst
@@ -87,4 +87,3 @@ Guides
     scale
     sparse
     gotchas
-    cookbook
--- a/pandas/io/sql.py
+++ b/pandas/io/sql.py
@@ -2465,14 +2465,14 @@ def _get_valid_sqlite_name(name: object)
     # Replace all " with "".
     # Wrap the entire thing in double quotes.
 
-    uname = _get_unicode_name(name)
-    if not len(uname):
+    name = _get_unicode_name(name)
+    if not len(name):
         raise ValueError("Empty table or column name specified")
 
-    nul_index = uname.find("\x00")
-    if nul_index >= 0:
+    if '\0' in name:
         raise ValueError("SQLite identifier cannot contain NULs")
-    return '"' + uname.replace('"', '""') + '"'
+    name = name.replace('"', '""')
+    return '"' + name + '"'
 
 
 class SQLiteTable(SQLTable):
--- a/pandas/tests/groupby/test_categorical.py
+++ b/pandas/tests/groupby/test_categorical.py
@@ -988,28 +988,6 @@ def test_groupby_empty_with_category():
     tm.assert_series_equal(result, expected)
 
 
-def test_sort():
-    # https://stackoverflow.com/questions/23814368/sorting-pandas-
-    #        categorical-labels-after-groupby
-    # This should result in a properly sorted Series so that the plot
-    # has a sorted x axis
-    # self.cat.groupby(['value_group'])['value_group'].count().plot(kind='bar')
-
-    df = DataFrame({"value": np.random.default_rng(2).integers(0, 10000, 100)})
-    labels = [f"{i} - {i+499}" for i in range(0, 10000, 500)]
-    cat_labels = Categorical(labels, labels)
-
-    df = df.sort_values(by=["value"], ascending=True)
-    df["value_group"] = pd.cut(
-        df.value, range(0, 10500, 500), right=False, labels=cat_labels
-    )
-
-    res = df.groupby(["value_group"], observed=False)["value_group"].count()
-    exp = res[sorted(res.index, key=lambda x: float(x.split()[0]))]
-    exp.index = CategoricalIndex(exp.index, name=exp.index.name)
-    tm.assert_series_equal(res, exp)
-
-
 @pytest.mark.parametrize("ordered", [True, False])
 def test_sort2(sort, ordered):
     # dataframe groupby sort was being ignored # GH 8868
--- a/pandas/tests/indexing/multiindex/test_chaining_and_caching.py
+++ b/pandas/tests/indexing/multiindex/test_chaining_and_caching.py
@@ -13,35 +13,6 @@ from pandas import (
 import pandas._testing as tm
 
 
-def test_detect_chained_assignment(using_copy_on_write, warn_copy_on_write):
-    # Inplace ops, originally from:
-    # https://stackoverflow.com/questions/20508968/series-fillna-in-a-multiindex-dataframe-does-not-fill-is-this-a-bug
-    a = [12, 23]
-    b = [123, None]
-    c = [1234, 2345]
-    d = [12345, 23456]
-    tuples = [("eyes", "left"), ("eyes", "right"), ("ears", "left"), ("ears", "right")]
-    events = {
-        ("eyes", "left"): a,
-        ("eyes", "right"): b,
-        ("ears", "left"): c,
-        ("ears", "right"): d,
-    }
-    multiind = MultiIndex.from_tuples(tuples, names=["part", "side"])
-    zed = DataFrame(events, index=["a", "b"], columns=multiind)
-
-    if using_copy_on_write:
-        with tm.raises_chained_assignment_error():
-            zed["eyes"]["right"].fillna(value=555, inplace=True)
-    elif warn_copy_on_write:
-        with tm.assert_produces_warning(None):
-            zed["eyes"]["right"].fillna(value=555, inplace=True)
-    else:
-        msg = "A value is trying to be set on a copy of a slice from a DataFrame"
-        with pytest.raises(SettingWithCopyError, match=msg):
-            with tm.assert_produces_warning(None):
-                zed["eyes"]["right"].fillna(value=555, inplace=True)
-
 
 @td.skip_array_manager_invalid_test  # with ArrayManager df.loc[0] is not a view
 def test_cache_updating(using_copy_on_write, warn_copy_on_write):
--- a/pandas/tests/indexing/multiindex/test_setitem.py
+++ b/pandas/tests/indexing/multiindex/test_setitem.py
@@ -154,36 +154,7 @@ class TestMultiIndexSetItem:
         with pytest.raises(TypeError, match=msg):
             df.loc["bar"] *= 2
 
-    def test_multiindex_setitem2(self):
-        # from SO
-        # https://stackoverflow.com/questions/24572040/pandas-access-the-level-of-multiindex-for-inplace-operation
-        df_orig = DataFrame.from_dict(
-            {
-                "price": {
-                    ("DE", "Coal", "Stock"): 2,
-                    ("DE", "Gas", "Stock"): 4,
-                    ("DE", "Elec", "Demand"): 1,
-                    ("FR", "Gas", "Stock"): 5,
-                    ("FR", "Solar", "SupIm"): 0,
-                    ("FR", "Wind", "SupIm"): 0,
-                }
-            }
-        )
-        df_orig.index = MultiIndex.from_tuples(
-            df_orig.index, names=["Sit", "Com", "Type"]
-        )
 
-        expected = df_orig.copy()
-        expected.iloc[[0, 1, 3]] *= 2
-
-        idx = pd.IndexSlice
-        df = df_orig.copy()
-        df.loc[idx[:, :, "Stock"], :] *= 2
-        tm.assert_frame_equal(df, expected)
-
-        df = df_orig.copy()
-        df.loc[idx[:, :, "Stock"], "price"] *= 2
-        tm.assert_frame_equal(df, expected)
 
     def test_multiindex_assignment(self):
         # GH3777 part 2
--- a/pandas/tests/indexing/test_chaining_and_caching.py
+++ b/pandas/tests/indexing/test_chaining_and_caching.py
@@ -429,27 +429,6 @@ class TestChaining:
         df["column1"] = df["column1"] + "c"
         str(df)
 
-    @pytest.mark.arm_slow
-    def test_detect_chained_assignment_undefined_column(
-        self, using_copy_on_write, warn_copy_on_write
-    ):
-        # from SO:
-        # https://stackoverflow.com/questions/24054495/potential-bug-setting-value-for-undefined-column-using-iloc
-        df = DataFrame(np.arange(0, 9), columns=["count"])
-        df["group"] = "b"
-        df_original = df.copy()
-
-        if using_copy_on_write:
-            with tm.raises_chained_assignment_error():
-                df.iloc[0:5]["group"] = "a"
-            tm.assert_frame_equal(df, df_original)
-        elif warn_copy_on_write:
-            with tm.raises_chained_assignment_error():
-                df.iloc[0:5]["group"] = "a"
-        else:
-            with pytest.raises(SettingWithCopyError, match=msg):
-                with tm.raises_chained_assignment_error():
-                    df.iloc[0:5]["group"] = "a"
 
     @pytest.mark.arm_slow
     def test_detect_chained_assignment_changing_dtype(
--- a/pandas/tests/io/parser/common/test_common_basic.py
+++ b/pandas/tests/io/parser/common/test_common_basic.py
@@ -381,23 +381,6 @@ def test_trailing_delimiters(all_parsers
     tm.assert_frame_equal(result, expected)
 
 
-def test_escapechar(all_parsers):
-    # https://stackoverflow.com/questions/13824840/feature-request-for-
-    # pandas-read-csv
-    data = '''SEARCH_TERM,ACTUAL_URL
-"bra tv board","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"
-"tv p\xc3\xa5 hjul","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"
-"SLAGBORD, \\"Bergslagen\\", IKEA:s 1700-tals series","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"'''
-
-    parser = all_parsers
-    result = parser.read_csv(
-        StringIO(data), escapechar="\\", quotechar='"', encoding="utf-8"
-    )
-
-    assert result["SEARCH_TERM"][2] == 'SLAGBORD, "Bergslagen", IKEA:s 1700-tals series'
-
-    tm.assert_index_equal(result.columns, Index(["SEARCH_TERM", "ACTUAL_URL"]))
-
 
 def test_ignore_leading_whitespace(all_parsers):
     # see gh-3374, gh-6607