test_dataframeserialization.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:pyabc 作者: neuralyzer 项目源码 文件源码
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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号