本文整理匯總了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)