def df(request):
par = request.param
if par == "empty":
return pd.DataFrame()
if par == "int":
return pd.DataFrame({"a": sp.random.randint(-20, 20, 100),
"b": sp.random.randint(-20, 20, 100)})
if par == "float":
return pd.DataFrame({"a": sp.randn(100),
"b": sp.randn(100)})
if par == "non_numeric_str":
return pd.DataFrame({"a": ["foo", "bar"],
"b": ["bar", "foo"]})
if par == "numeric_str":
return pd.DataFrame({"a": list(map(str, sp.randn(100))),
"b": list(map(str,
sp.random.randint(-20, 20, 100)))})
if par == "int-float-numeric_str":
return pd.DataFrame({"a": sp.random.randint(-20, 20, 100),
"b": sp.randn(100),
"c": list(map(str,
sp.random.randint(-20, 20, 100)))})
if par == "int-float-non_numeric_str-str_ind":
return pd.DataFrame({"a": [1, 2],
"b": [1.1, 2.2],
"c": ["foo", "bar"]},
index=["first", "second"])
if par == "int-float-numeric_str-str_ind":
return pd.DataFrame({"a": [1, 2],
"b": [1.1, 2.2],
"c": ["1", "2"]},
index=["first", "second"])
raise Exception("Invalid Test DataFrame Type")
评论列表
文章目录