本文整理汇总了Python中pandas._libs.lib.to_object_array方法的典型用法代码示例。如果您正苦于以下问题:Python lib.to_object_array方法的具体用法?Python lib.to_object_array怎么用?Python lib.to_object_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas._libs.lib
的用法示例。
在下文中一共展示了lib.to_object_array方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_object_array_width
# 需要导入模块: from pandas._libs import lib [as 别名]
# 或者: from pandas._libs.lib import to_object_array [as 别名]
def test_to_object_array_width(self):
# see gh-13320
rows = [[1, 2, 3], [4, 5, 6]]
expected = np.array(rows, dtype=object)
out = lib.to_object_array(rows)
tm.assert_numpy_array_equal(out, expected)
expected = np.array(rows, dtype=object)
out = lib.to_object_array(rows, min_width=1)
tm.assert_numpy_array_equal(out, expected)
expected = np.array([[1, 2, 3, None, None],
[4, 5, 6, None, None]], dtype=object)
out = lib.to_object_array(rows, min_width=5)
tm.assert_numpy_array_equal(out, expected)
示例2: _list_to_arrays
# 需要导入模块: from pandas._libs import lib [as 别名]
# 或者: from pandas._libs.lib import to_object_array [as 别名]
def _list_to_arrays(data, columns, coerce_float=False, dtype=None):
if len(data) > 0 and isinstance(data[0], tuple):
content = list(lib.to_object_array_tuples(data).T)
else:
# list of lists
content = list(lib.to_object_array(data).T)
return _convert_object_array(content, columns, dtype=dtype,
coerce_float=coerce_float)