Skip to content

Commit c6b03f9

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 e41e00f commit c6b03f9

File tree

9 files changed

+27
-149
lines changed

9 files changed

+27
-149
lines changed

doc/source/user_guide/cookbook.rst

Lines changed: 22 additions & 0 deletions
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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,3 @@ Guides
8585
scale
8686
sparse
8787
gotchas
88-
cookbook

pandas/io/sql.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,14 +1832,14 @@ def _get_valid_sqlite_name(name):
18321832
# Replace all " with "".
18331833
# Wrap the entire thing in double quotes.
18341834

1835-
uname = _get_unicode_name(name)
1836-
if not len(uname):
1835+
name = _get_unicode_name(name)
1836+
if not len(name):
18371837
raise ValueError("Empty table or column name specified")
18381838

1839-
nul_index = uname.find("\x00")
1840-
if nul_index >= 0:
1839+
if '\0' in name:
18411840
raise ValueError("SQLite identifier cannot contain NULs")
1842-
return '"' + uname.replace('"', '""') + '"'
1841+
name = name.replace('"', '""')
1842+
return '"' + name + '"'
18431843

18441844

18451845
class SQLiteTable(SQLTable):

pandas/tests/groupby/aggregate/test_other.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,7 @@
2525
from pandas.io.formats.printing import pprint_thing
2626

2727

28-
def test_agg_api():
29-
# GH 6337
30-
# https://stackoverflow.com/questions/21706030/pandas-groupby-agg-function-column-dtype-error
31-
# different api for agg when passed custom function with mixed frame
3228

33-
df = DataFrame(
34-
{
35-
"data1": np.random.randn(5),
36-
"data2": np.random.randn(5),
37-
"key1": ["a", "a", "b", "b", "a"],
38-
"key2": ["one", "two", "one", "two", "one"],
39-
}
40-
)
41-
grouped = df.groupby("key1")
42-
43-
def peak_to_peak(arr):
44-
return arr.max() - arr.min()
45-
46-
with tm.assert_produces_warning(
47-
FutureWarning,
48-
match=r"\['key2'\] did not aggregate successfully",
49-
):
50-
expected = grouped.agg([peak_to_peak])
51-
expected.columns = ["data1", "data2"]
52-
53-
with tm.assert_produces_warning(
54-
FutureWarning,
55-
match=r"\['key2'\] did not aggregate successfully",
56-
):
57-
result = grouped.agg(peak_to_peak)
58-
tm.assert_frame_equal(result, expected)
5929

6030

6131
def test_agg_datetimes_mixed():

pandas/tests/groupby/test_categorical.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -901,29 +901,6 @@ def test_groupby_empty_with_category():
901901
tm.assert_series_equal(result, expected)
902902

903903

904-
def test_sort():
905-
906-
# https://stackoverflow.com/questions/23814368/sorting-pandas-
907-
# categorical-labels-after-groupby
908-
# This should result in a properly sorted Series so that the plot
909-
# has a sorted x axis
910-
# self.cat.groupby(['value_group'])['value_group'].count().plot(kind='bar')
911-
912-
df = DataFrame({"value": np.random.randint(0, 10000, 100)})
913-
labels = [f"{i} - {i+499}" for i in range(0, 10000, 500)]
914-
cat_labels = Categorical(labels, labels)
915-
916-
df = df.sort_values(by=["value"], ascending=True)
917-
df["value_group"] = pd.cut(
918-
df.value, range(0, 10500, 500), right=False, labels=cat_labels
919-
)
920-
921-
res = df.groupby(["value_group"], observed=False)["value_group"].count()
922-
exp = res[sorted(res.index, key=lambda x: float(x.split()[0]))]
923-
exp.index = CategoricalIndex(exp.index, name=exp.index.name)
924-
tm.assert_series_equal(res, exp)
925-
926-
927904
def test_sort2():
928905
# dataframe groupby sort was being ignored # GH 8868
929906
df = DataFrame(

pandas/tests/indexing/multiindex/test_chaining_and_caching.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,6 @@
1212
import pandas._testing as tm
1313

1414

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

pandas/tests/indexing/multiindex/test_setitem.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -148,37 +148,7 @@ def test_multiindex_setitem(self):
148148
with pytest.raises(TypeError, match=msg):
149149
df.loc["bar"] *= 2
150150

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

179-
df = df_orig.copy()
180-
df.loc[idx[:, :, "Stock"], "price"] *= 2
181-
tm.assert_frame_equal(df, expected)
182152

183153
def test_multiindex_assignment(self):
184154

pandas/tests/indexing/test_chaining_and_caching.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -406,23 +406,6 @@ def test_detect_chained_assignment_false_positives(self):
406406
df["column1"] = df["column1"] + "c"
407407
str(df)
408408

409-
@pytest.mark.arm_slow
410-
def test_detect_chained_assignment_undefined_column(self, using_copy_on_write):
411-
412-
# from SO:
413-
# https://stackoverflow.com/questions/24054495/potential-bug-setting-value-for-undefined-column-using-iloc
414-
df = DataFrame(np.arange(0, 9), columns=["count"])
415-
df["group"] = "b"
416-
df_original = df.copy()
417-
418-
if using_copy_on_write:
419-
# TODO(CoW) can we still warn here?
420-
df.iloc[0:5]["group"] = "a"
421-
tm.assert_frame_equal(df, df_original)
422-
else:
423-
with pytest.raises(SettingWithCopyError, match=msg):
424-
df.iloc[0:5]["group"] = "a"
425-
426409
@pytest.mark.arm_slow
427410
def test_detect_chained_assignment_changing_dtype(
428411
self, using_array_manager, using_copy_on_write

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -379,24 +379,6 @@ def test_trailing_delimiters(all_parsers):
379379
tm.assert_frame_equal(result, expected)
380380

381381

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

0 commit comments

Comments
 (0)