Skip to content

Commit 9d81dbb

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 8e4a6e7 commit 9d81dbb

File tree

9 files changed

+27
-128
lines changed

9 files changed

+27
-128
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
@@ -42,4 +42,3 @@ Further information on any specific method can be obtained in the
4242
scale
4343
sparse
4444
gotchas
45-
cookbook

pandas/io/sql.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1401,14 +1401,14 @@ def _get_valid_sqlite_name(name):
14011401
# Replace all " with "".
14021402
# Wrap the entire thing in double quotes.
14031403

1404-
uname = _get_unicode_name(name)
1405-
if not len(uname):
1404+
name = _get_unicode_name(name)
1405+
if not len(name):
14061406
raise ValueError("Empty table or column name specified")
14071407

1408-
nul_index = uname.find("\x00")
1409-
if nul_index >= 0:
1408+
if '\0' in name:
14101409
raise ValueError("SQLite identifier cannot contain NULs")
1411-
return '"' + uname.replace('"', '""') + '"'
1410+
name = name.replace('"', '""')
1411+
return '"' + name + '"'
14121412

14131413

14141414
_SAFE_NAMES_WARNING = (

pandas/tests/groupby/aggregate/test_other.py

-24
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,6 @@
2424
from pandas.io.formats.printing import pprint_thing
2525

2626

27-
def test_agg_api():
28-
# GH 6337
29-
# https://stackoverflow.com/questions/21706030/pandas-groupby-agg-function-column-dtype-error
30-
# different api for agg when passed custom function with mixed frame
31-
32-
df = DataFrame(
33-
{
34-
"data1": np.random.randn(5),
35-
"data2": np.random.randn(5),
36-
"key1": ["a", "a", "b", "b", "a"],
37-
"key2": ["one", "two", "one", "two", "one"],
38-
}
39-
)
40-
grouped = df.groupby("key1")
41-
42-
def peak_to_peak(arr):
43-
return arr.max() - arr.min()
44-
45-
expected = grouped.agg([peak_to_peak])
46-
expected.columns = ["data1", "data2"]
47-
result = grouped.agg(peak_to_peak)
48-
tm.assert_frame_equal(result, expected)
49-
50-
5127
def test_agg_datetimes_mixed():
5228
data = [[1, "2012-01-01", 1.0], [2, "2012-01-02", 2.0], [3, None, 3.0]]
5329

pandas/tests/groupby/test_categorical.py

-23
Original file line numberDiff line numberDiff line change
@@ -796,29 +796,6 @@ def test_groupby_empty_with_category():
796796
tm.assert_series_equal(result, expected)
797797

798798

799-
def test_sort():
800-
801-
# https://stackoverflow.com/questions/23814368/sorting-pandas-
802-
# categorical-labels-after-groupby
803-
# This should result in a properly sorted Series so that the plot
804-
# has a sorted x axis
805-
# self.cat.groupby(['value_group'])['value_group'].count().plot(kind='bar')
806-
807-
df = DataFrame({"value": np.random.randint(0, 10000, 100)})
808-
labels = [f"{i} - {i+499}" for i in range(0, 10000, 500)]
809-
cat_labels = Categorical(labels, labels)
810-
811-
df = df.sort_values(by=["value"], ascending=True)
812-
df["value_group"] = pd.cut(
813-
df.value, range(0, 10500, 500), right=False, labels=cat_labels
814-
)
815-
816-
res = df.groupby(["value_group"], observed=False)["value_group"].count()
817-
exp = res[sorted(res.index, key=lambda x: float(x.split()[0]))]
818-
exp.index = CategoricalIndex(exp.index, name=exp.index.name)
819-
tm.assert_series_equal(res, exp)
820-
821-
822799
def test_sort2():
823800
# dataframe groupby sort was being ignored # GH 8868
824801
df = DataFrame(

pandas/tests/indexing/multiindex/test_chaining_and_caching.py

-21
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,6 @@
66
import pandas.core.common as com
77

88

9-
def test_detect_chained_assignment():
10-
# Inplace ops, originally from:
11-
# https://stackoverflow.com/questions/20508968/series-fillna-in-a-multiindex-dataframe-does-not-fill-is-this-a-bug
12-
a = [12, 23]
13-
b = [123, None]
14-
c = [1234, 2345]
15-
d = [12345, 23456]
16-
tuples = [("eyes", "left"), ("eyes", "right"), ("ears", "left"), ("ears", "right")]
17-
events = {
18-
("eyes", "left"): a,
19-
("eyes", "right"): b,
20-
("ears", "left"): c,
21-
("ears", "right"): d,
22-
}
23-
multiind = MultiIndex.from_tuples(tuples, names=["part", "side"])
24-
zed = DataFrame(events, index=["a", "b"], columns=multiind)
25-
26-
with pytest.raises(com.SettingWithCopyError):
27-
zed["eyes"]["right"].fillna(value=555, inplace=True)
28-
29-
309
def test_cache_updating():
3110
# 5216
3211
# make sure that we don't try to set a dead cache

pandas/tests/indexing/multiindex/test_setitem.py

-28
Original file line numberDiff line numberDiff line change
@@ -140,35 +140,7 @@ def test_multiindex_setitem(self):
140140
with pytest.raises(TypeError):
141141
df.loc["bar"] *= 2
142142

143-
# from SO
144-
# https://stackoverflow.com/questions/24572040/pandas-access-the-level-of-multiindex-for-inplace-operation
145-
df_orig = DataFrame.from_dict(
146-
{
147-
"price": {
148-
("DE", "Coal", "Stock"): 2,
149-
("DE", "Gas", "Stock"): 4,
150-
("DE", "Elec", "Demand"): 1,
151-
("FR", "Gas", "Stock"): 5,
152-
("FR", "Solar", "SupIm"): 0,
153-
("FR", "Wind", "SupIm"): 0,
154-
}
155-
}
156-
)
157-
df_orig.index = MultiIndex.from_tuples(
158-
df_orig.index, names=["Sit", "Com", "Type"]
159-
)
160-
161-
expected = df_orig.copy()
162-
expected.iloc[[0, 2, 3]] *= 2
163-
164-
idx = pd.IndexSlice
165-
df = df_orig.copy()
166-
df.loc[idx[:, :, "Stock"], :] *= 2
167-
tm.assert_frame_equal(df, expected)
168143

169-
df = df_orig.copy()
170-
df.loc[idx[:, :, "Stock"], "price"] *= 2
171-
tm.assert_frame_equal(df, expected)
172144

173145
def test_multiindex_assignment(self):
174146

pandas/tests/indexing/test_chaining_and_caching.py

-8
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,6 @@ def random_text(nobs=100):
272272
df["column1"] = df["column1"] + "c"
273273
str(df)
274274

275-
# from SO:
276-
# https://stackoverflow.com/questions/24054495/potential-bug-setting-value-for-undefined-column-using-iloc
277-
df = DataFrame(np.arange(0, 9), columns=["count"])
278-
df["group"] = "b"
279-
280-
with pytest.raises(com.SettingWithCopyError):
281-
df.iloc[0:5]["group"] = "a"
282-
283275
# Mixed type setting but same dtype & changing dtype
284276
df = DataFrame(
285277
dict(

pandas/tests/io/parser/test_common.py

-18
Original file line numberDiff line numberDiff line change
@@ -1057,24 +1057,6 @@ def test_trailing_delimiters(all_parsers):
10571057
tm.assert_frame_equal(result, expected)
10581058

10591059

1060-
def test_escapechar(all_parsers):
1061-
# https://stackoverflow.com/questions/13824840/feature-request-for-
1062-
# pandas-read-csv
1063-
data = '''SEARCH_TERM,ACTUAL_URL
1064-
"bra tv bord","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"
1065-
"tv p\xc3\xa5 hjul","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"
1066-
"SLAGBORD, \\"Bergslagen\\", IKEA:s 1700-tals serie","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"''' # noqa
1067-
1068-
parser = all_parsers
1069-
result = parser.read_csv(
1070-
StringIO(data), escapechar="\\", quotechar='"', encoding="utf-8"
1071-
)
1072-
1073-
assert result["SEARCH_TERM"][2] == 'SLAGBORD, "Bergslagen", IKEA:s 1700-tals serie'
1074-
1075-
tm.assert_index_equal(result.columns, Index(["SEARCH_TERM", "ACTUAL_URL"]))
1076-
1077-
10781060
def test_int64_min_issues(all_parsers):
10791061
# see gh-2599
10801062
parser = all_parsers

0 commit comments

Comments
 (0)