__init__.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. """
  2. pandas._config is considered explicitly upstream of everything else in pandas,
  3. should have no intra-pandas dependencies.
  4. importing `dates` and `display` ensures that keys needed by _libs
  5. are initialized.
  6. """
  7. __all__ = [
  8. "config",
  9. "detect_console_encoding",
  10. "get_option",
  11. "set_option",
  12. "reset_option",
  13. "describe_option",
  14. "option_context",
  15. "options",
  16. "using_copy_on_write",
  17. "warn_copy_on_write",
  18. ]
  19. from pandas._config import config
  20. from pandas._config import dates # pyright: ignore[reportUnusedImport] # noqa: F401
  21. from pandas._config.config import (
  22. _global_config,
  23. describe_option,
  24. get_option,
  25. option_context,
  26. options,
  27. reset_option,
  28. set_option,
  29. )
  30. from pandas._config.display import detect_console_encoding
  31. def using_copy_on_write() -> bool:
  32. _mode_options = _global_config["mode"]
  33. return (
  34. _mode_options["copy_on_write"] is True
  35. and _mode_options["data_manager"] == "block"
  36. )
  37. def warn_copy_on_write() -> bool:
  38. _mode_options = _global_config["mode"]
  39. return (
  40. _mode_options["copy_on_write"] == "warn"
  41. and _mode_options["data_manager"] == "block"
  42. )
  43. def using_nullable_dtypes() -> bool:
  44. _mode_options = _global_config["mode"]
  45. return _mode_options["nullable_dtypes"]
  46. def using_string_dtype() -> bool:
  47. _mode_options = _global_config["future"]
  48. return _mode_options["infer_string"]