Skip to content

Commit 3efd46a

Browse files
Debian Science Teamrebecca-palmer
Debian Science Team
authored andcommitted
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 <[email protected]> Forwarded: no - deletes some tests/examples without replacement Gbp-Pq: Name remove_ccbysa_snippets.patch
1 parent ff4be2b commit 3efd46a

File tree

8 files changed

+27
-124
lines changed

8 files changed

+27
-124
lines changed

doc/source/user_guide/cookbook.rst

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. _cookbook:
2+
3+
{{ header }}
4+
5+
.. _cookbook.idioms:
6+
.. _cookbook.selection:
7+
.. _cookbook.multi_index:
8+
.. _cookbook.missing_data:
9+
.. _cookbook.grouping:
10+
.. _cookbook.pivot:
11+
.. _cookbook.resample:
12+
.. _cookbook.merge:
13+
.. _cookbook.plotting:
14+
.. _cookbook.csv:
15+
.. _cookbook.csv.multiple_files:
16+
.. _cookbook.sql:
17+
.. _cookbook.excel:
18+
.. _cookbook.html:
19+
.. _cookbook.hdf:
20+
.. _cookbook.binary:
21+
22+
This page has been removed for copyright reasons.

doc/source/user_guide/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,3 @@ Guides
8787
scale
8888
sparse
8989
gotchas
90-
cookbook

pandas/io/sql.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -2465,14 +2465,14 @@ def _get_valid_sqlite_name(name: object):
24652465
# Replace all " with "".
24662466
# Wrap the entire thing in double quotes.
24672467

2468-
uname = _get_unicode_name(name)
2469-
if not len(uname):
2468+
name = _get_unicode_name(name)
2469+
if not len(name):
24702470
raise ValueError("Empty table or column name specified")
24712471

2472-
nul_index = uname.find("\x00")
2473-
if nul_index >= 0:
2472+
if '\0' in name:
24742473
raise ValueError("SQLite identifier cannot contain NULs")
2475-
return '"' + uname.replace('"', '""') + '"'
2474+
name = name.replace('"', '""')
2475+
return '"' + name + '"'
24762476

24772477

24782478
class SQLiteTable(SQLTable):

pandas/tests/groupby/test_categorical.py

-22
Original file line numberDiff line numberDiff line change
@@ -988,28 +988,6 @@ def test_groupby_empty_with_category():
988988
tm.assert_series_equal(result, expected)
989989

990990

991-
def test_sort():
992-
# https://stackoverflow.com/questions/23814368/sorting-pandas-
993-
# categorical-labels-after-groupby
994-
# This should result in a properly sorted Series so that the plot
995-
# has a sorted x axis
996-
# self.cat.groupby(['value_group'])['value_group'].count().plot(kind='bar')
997-
998-
df = DataFrame({"value": np.random.default_rng(2).integers(0, 10000, 100)})
999-
labels = [f"{i} - {i+499}" for i in range(0, 10000, 500)]
1000-
cat_labels = Categorical(labels, labels)
1001-
1002-
df = df.sort_values(by=["value"], ascending=True)
1003-
df["value_group"] = pd.cut(
1004-
df.value, range(0, 10500, 500), right=False, labels=cat_labels
1005-
)
1006-
1007-
res = df.groupby(["value_group"], observed=False)["value_group"].count()
1008-
exp = res[sorted(res.index, key=lambda x: float(x.split()[0]))]
1009-
exp.index = CategoricalIndex(exp.index, name=exp.index.name)
1010-
tm.assert_series_equal(res, exp)
1011-
1012-
1013991
@pytest.mark.parametrize("ordered", [True, False])
1014992
def test_sort2(sort, ordered):
1015993
# dataframe groupby sort was being ignored # GH 8868

pandas/tests/indexing/multiindex/test_chaining_and_caching.py

-29
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,6 @@
1313
import pandas._testing as tm
1414

1515

16-
def test_detect_chained_assignment(using_copy_on_write, warn_copy_on_write):
17-
# Inplace ops, originally from:
18-
# https://stackoverflow.com/questions/20508968/series-fillna-in-a-multiindex-dataframe-does-not-fill-is-this-a-bug
19-
a = [12, 23]
20-
b = [123, None]
21-
c = [1234, 2345]
22-
d = [12345, 23456]
23-
tuples = [("eyes", "left"), ("eyes", "right"), ("ears", "left"), ("ears", "right")]
24-
events = {
25-
("eyes", "left"): a,
26-
("eyes", "right"): b,
27-
("ears", "left"): c,
28-
("ears", "right"): d,
29-
}
30-
multiind = MultiIndex.from_tuples(tuples, names=["part", "side"])
31-
zed = DataFrame(events, index=["a", "b"], columns=multiind)
32-
33-
if using_copy_on_write:
34-
with tm.raises_chained_assignment_error():
35-
zed["eyes"]["right"].fillna(value=555, inplace=True)
36-
elif warn_copy_on_write:
37-
with tm.assert_produces_warning(None):
38-
zed["eyes"]["right"].fillna(value=555, inplace=True)
39-
else:
40-
msg = "A value is trying to be set on a copy of a slice from a DataFrame"
41-
with pytest.raises(SettingWithCopyError, match=msg):
42-
with tm.assert_produces_warning(None):
43-
zed["eyes"]["right"].fillna(value=555, inplace=True)
44-
4516

4617
@td.skip_array_manager_invalid_test # with ArrayManager df.loc[0] is not a view
4718
def test_cache_updating(using_copy_on_write, warn_copy_on_write):

pandas/tests/indexing/multiindex/test_setitem.py

-29
Original file line numberDiff line numberDiff line change
@@ -154,36 +154,7 @@ def test_multiindex_setitem(self):
154154
with pytest.raises(TypeError, match=msg):
155155
df.loc["bar"] *= 2
156156

157-
def test_multiindex_setitem2(self):
158-
# from SO
159-
# https://stackoverflow.com/questions/24572040/pandas-access-the-level-of-multiindex-for-inplace-operation
160-
df_orig = DataFrame.from_dict(
161-
{
162-
"price": {
163-
("DE", "Coal", "Stock"): 2,
164-
("DE", "Gas", "Stock"): 4,
165-
("DE", "Elec", "Demand"): 1,
166-
("FR", "Gas", "Stock"): 5,
167-
("FR", "Solar", "SupIm"): 0,
168-
("FR", "Wind", "SupIm"): 0,
169-
}
170-
}
171-
)
172-
df_orig.index = MultiIndex.from_tuples(
173-
df_orig.index, names=["Sit", "Com", "Type"]
174-
)
175-
176-
expected = df_orig.copy()
177-
expected.iloc[[0, 1, 3]] *= 2
178-
179-
idx = pd.IndexSlice
180-
df = df_orig.copy()
181-
df.loc[idx[:, :, "Stock"], :] *= 2
182-
tm.assert_frame_equal(df, expected)
183157

184-
df = df_orig.copy()
185-
df.loc[idx[:, :, "Stock"], "price"] *= 2
186-
tm.assert_frame_equal(df, expected)
187158

188159
def test_multiindex_assignment(self):
189160
# GH3777 part 2

pandas/tests/indexing/test_chaining_and_caching.py

-21
Original file line numberDiff line numberDiff line change
@@ -429,27 +429,6 @@ def test_detect_chained_assignment_false_positives(self):
429429
df["column1"] = df["column1"] + "c"
430430
str(df)
431431

432-
@pytest.mark.arm_slow
433-
def test_detect_chained_assignment_undefined_column(
434-
self, using_copy_on_write, warn_copy_on_write
435-
):
436-
# from SO:
437-
# https://stackoverflow.com/questions/24054495/potential-bug-setting-value-for-undefined-column-using-iloc
438-
df = DataFrame(np.arange(0, 9), columns=["count"])
439-
df["group"] = "b"
440-
df_original = df.copy()
441-
442-
if using_copy_on_write:
443-
with tm.raises_chained_assignment_error():
444-
df.iloc[0:5]["group"] = "a"
445-
tm.assert_frame_equal(df, df_original)
446-
elif warn_copy_on_write:
447-
with tm.raises_chained_assignment_error():
448-
df.iloc[0:5]["group"] = "a"
449-
else:
450-
with pytest.raises(SettingWithCopyError, match=msg):
451-
with tm.raises_chained_assignment_error():
452-
df.iloc[0:5]["group"] = "a"
453432

454433
@pytest.mark.arm_slow
455434
def test_detect_chained_assignment_changing_dtype(

pandas/tests/io/parser/common/test_common_basic.py

-17
Original file line numberDiff line numberDiff line change
@@ -381,23 +381,6 @@ def test_trailing_delimiters(all_parsers):
381381
tm.assert_frame_equal(result, expected)
382382

383383

384-
def test_escapechar(all_parsers):
385-
# https://stackoverflow.com/questions/13824840/feature-request-for-
386-
# pandas-read-csv
387-
data = '''SEARCH_TERM,ACTUAL_URL
388-
"bra tv board","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"
389-
"tv p\xc3\xa5 hjul","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"
390-
"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"'''
391-
392-
parser = all_parsers
393-
result = parser.read_csv(
394-
StringIO(data), escapechar="\\", quotechar='"', encoding="utf-8"
395-
)
396-
397-
assert result["SEARCH_TERM"][2] == 'SLAGBORD, "Bergslagen", IKEA:s 1700-tals series'
398-
399-
tm.assert_index_equal(result.columns, Index(["SEARCH_TERM", "ACTUAL_URL"]))
400-
401384

402385
def test_ignore_leading_whitespace(all_parsers):
403386
# see gh-3374, gh-6607

0 commit comments

Comments
 (0)