本文整理汇总了Python中pandas.compat.FileNotFoundError方法的典型用法代码示例。如果您正苦于以下问题:Python compat.FileNotFoundError方法的具体用法?Python compat.FileNotFoundError怎么用?Python compat.FileNotFoundError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.compat
的用法示例。
在下文中一共展示了compat.FileNotFoundError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nonexistent_path
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import FileNotFoundError [as 别名]
def test_nonexistent_path(all_parsers):
# gh-2428: pls no segfault
# gh-14086: raise more helpful FileNotFoundError
parser = all_parsers
path = "%s.csv" % tm.rands(10)
msg = ("does not exist" if parser.engine == "c"
else r"\[Errno 2\]")
with pytest.raises(compat.FileNotFoundError, match=msg) as e:
parser.read_csv(path)
filename = e.value.filename
filename = filename.decode() if isinstance(
filename, bytes) else filename
assert path == filename
示例2: get_filepath_or_buffer
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import FileNotFoundError [as 别名]
def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
compression=None, mode=None):
if mode is None:
mode = 'rb'
fs = s3fs.S3FileSystem(anon=False)
try:
filepath_or_buffer = fs.open(_strip_schema(filepath_or_buffer), mode)
except (compat.FileNotFoundError, NoCredentialsError):
# boto3 has troubles when trying to access a public file
# when credentialed...
# An OSError is raised if you have credentials, but they
# aren't valid for that bucket.
# A NoCredentialsError is raised if you don't have creds
# for that bucket.
fs = s3fs.S3FileSystem(anon=True)
filepath_or_buffer = fs.open(_strip_schema(filepath_or_buffer), mode)
return filepath_or_buffer, None, compression, True
示例3: test_read_non_existant_read_table
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import FileNotFoundError [as 别名]
def test_read_non_existant_read_table(self):
path = os.path.join(HERE, 'data', 'does_not_exist.' + 'csv')
msg1 = r"File b'.+does_not_exist\.csv' does not exist"
msg2 = (r"\[Errno 2\] File .+does_not_exist\.csv does not exist:"
r" '.+does_not_exist\.csv'")
with pytest.raises(FileNotFoundError, match=r"({}|{})".format(
msg1, msg2)):
with tm.assert_produces_warning(FutureWarning):
pd.read_table(path)
示例4: test_nonexistent_path
# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import FileNotFoundError [as 别名]
def test_nonexistent_path(self):
# gh-2428: pls no segfault
# gh-14086: raise more helpful FileNotFoundError
path = '%s.csv' % tm.rands(10)
pytest.raises(compat.FileNotFoundError, self.read_csv, path)