本文整理匯總了Python中pandas.io.common._expand_user方法的典型用法代碼示例。如果您正苦於以下問題:Python common._expand_user方法的具體用法?Python common._expand_user怎麽用?Python common._expand_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandas.io.common
的用法示例。
在下文中一共展示了common._expand_user方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_read_expands_user_home_dir
# 需要導入模塊: from pandas.io import common [as 別名]
# 或者: from pandas.io.common import _expand_user [as 別名]
def test_read_expands_user_home_dir(self, reader, module,
error_class, fn_ext, monkeypatch):
pytest.importorskip(module)
path = os.path.join('~', 'does_not_exist.' + fn_ext)
monkeypatch.setattr(icom, '_expand_user',
lambda x: os.path.join('foo', x))
msg1 = (r"File (b')?.+does_not_exist\.{}'? does not exist"
.format(fn_ext))
msg2 = (r"\[Errno 2\] No such file or directory:"
r" '.+does_not_exist\.{}'").format(fn_ext)
msg3 = "Unexpected character found when decoding 'false'"
msg4 = "path_or_buf needs to be a string file path or file-like"
msg5 = (r"\[Errno 2\] File .+does_not_exist\.{} does not exist:"
r" '.+does_not_exist\.{}'").format(fn_ext, fn_ext)
with pytest.raises(error_class, match=r"({}|{}|{}|{}|{})".format(
msg1, msg2, msg3, msg4, msg5)):
reader(path)
示例2: test_expand_user
# 需要導入模塊: from pandas.io import common [as 別名]
# 或者: from pandas.io.common import _expand_user [as 別名]
def test_expand_user(self):
filename = '~/sometest'
expanded_name = icom._expand_user(filename)
assert expanded_name != filename
assert os.path.isabs(expanded_name)
assert os.path.expanduser(filename) == expanded_name
示例3: test_expand_user_normal_path
# 需要導入模塊: from pandas.io import common [as 別名]
# 或者: from pandas.io.common import _expand_user [as 別名]
def test_expand_user_normal_path(self):
filename = '/somefolder/sometest'
expanded_name = icom._expand_user(filename)
assert expanded_name == filename
assert os.path.expanduser(filename) == expanded_name
示例4: test_expand_user
# 需要導入模塊: from pandas.io import common [as 別名]
# 或者: from pandas.io.common import _expand_user [as 別名]
def test_expand_user(self):
filename = '~/sometest'
expanded_name = common._expand_user(filename)
assert expanded_name != filename
assert isabs(expanded_name)
assert os.path.expanduser(filename) == expanded_name
示例5: test_expand_user_normal_path
# 需要導入模塊: from pandas.io import common [as 別名]
# 或者: from pandas.io.common import _expand_user [as 別名]
def test_expand_user_normal_path(self):
filename = '/somefolder/sometest'
expanded_name = common._expand_user(filename)
assert expanded_name == filename
assert os.path.expanduser(filename) == expanded_name
示例6: __init__
# 需要導入模塊: from pandas.io import common [as 別名]
# 或者: from pandas.io.common import _expand_user [as 別名]
def __init__(self, frame, buf=None, columns=None, col_space=None,
header=True, index=True, na_rep='NaN', formatters=None,
justify=None, float_format=None, sparsify=None,
index_names=True, line_width=None, max_rows=None,
max_cols=None, show_dimensions=False, decimal='.',
table_id=None, render_links=False, **kwds):
self.frame = frame
if buf is not None:
self.buf = _expand_user(_stringify_path(buf))
else:
self.buf = StringIO()
self.show_index_names = index_names
if sparsify is None:
sparsify = get_option("display.multi_sparse")
self.sparsify = sparsify
self.float_format = float_format
self.formatters = formatters if formatters is not None else {}
self.na_rep = na_rep
self.decimal = decimal
self.col_space = col_space
self.header = header
self.index = index
self.line_width = line_width
self.max_rows = max_rows
self.max_cols = max_cols
self.max_rows_displayed = min(max_rows or len(self.frame),
len(self.frame))
self.show_dimensions = show_dimensions
self.table_id = table_id
self.render_links = render_links
if justify is None:
self.justify = get_option("display.colheader_justify")
else:
self.justify = justify
self.kwds = kwds
if columns is not None:
self.columns = ensure_index(columns)
self.frame = self.frame[self.columns]
else:
self.columns = frame.columns
self._chk_truncate()
self.adj = _get_adjustment()