MCPcopy
hub / github.com/pathwaycom/pathway / _markdown_to_pandas

Function _markdown_to_pandas

python/pathway/debug/__init__.py:422–443  ·  view source on GitHub ↗
(table_def: str, split_on_whitespace: bool = True)

Source from the content-addressed store, hash-verified

420
421
422def _markdown_to_pandas(table_def: str, split_on_whitespace: bool = True):
423 table_def = table_def.lstrip("\n")
424 if split_on_whitespace:
425 sep = r"(?:\s*\|\s*)|\s+"
426 else:
427 sep = r"\s*\|\s*"
428 header = table_def.partition("\n")[0].strip()
429 column_names = re.split(sep, header)
430 for index, name in enumerate(column_names):
431 if name in ("", "id"):
432 index_col = index
433 break
434 else:
435 index_col = None
436 return pd.read_table(
437 io.StringIO(table_def),
438 sep=sep,
439 index_col=index_col,
440 engine="python",
441 na_values=("", "None", "NaN", "nan", "NA", "NULL"),
442 keep_default_na=False,
443 ).convert_dtypes()
444
445
446def table_from_markdown(

Callers 6

write_csvFunction · 0.90
test_debug_datasourceFunction · 0.90
static_table_from_mdFunction · 0.90
table_from_markdownFunction · 0.85
table_from_markdownMethod · 0.85

Calls 2

stripMethod · 0.80
splitMethod · 0.80

Tested by 3

test_debug_datasourceFunction · 0.72
static_table_from_mdFunction · 0.72