Skip to content

Conversation

@ylin00
Copy link
Contributor

@ylin00 ylin00 commented Sep 8, 2020

@WillAyd
Copy link
Member

WillAyd commented Sep 9, 2020

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@WillAyd
Copy link
Member

WillAyd commented Sep 9, 2020

Can you add a note about the increase dependency in the 1.2 what’s new?

@WillAyd WillAyd added the IO Data IO issues that don't fit into a more specific label label Sep 9, 2020
@ylin00
Copy link
Contributor Author

ylin00 commented Sep 11, 2020

Can you add a note about the increase dependency in the 1.2 what’s new?

Just added.

@mroeschke
Copy link
Member

You will also need to update this reference here:

"tabulate": "0.8.3",

@ylin00
Copy link
Contributor Author

ylin00 commented Sep 19, 2020

You will also need to update this reference here:

"tabulate": "0.8.3",

Updated

@jreback jreback changed the title TST/DOC: Fixed #31771 BUG: df.to_markdown() with empty frame incorrect output Sep 19, 2020
@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Nov 23, 2020
Copy link
Contributor

@arw2019 arw2019 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ylin00 sorry about the delay. If you can merge master and resolve conflicts this looks good to go in!

@arw2019
Copy link
Contributor

arw2019 commented Dec 3, 2020

The CI failures on Python 3.8 look related:

2020-12-03T03:15:02.4153573Z pandas/compat/_optional.py:126: ImportError
2020-12-03T03:15:02.4153907Z _____________________________ test_other_tablefmt ______________________________
2020-12-03T03:15:02.4154452Z [gw1] linux -- Python 3.8.5 /home/vsts/miniconda3/envs/pandas-dev/bin/python
2020-12-03T03:15:02.4154736Z 
2020-12-03T03:15:02.4154989Z     def test_other_tablefmt():
2020-12-03T03:15:02.4155228Z         buf = StringIO()
2020-12-03T03:15:02.4155482Z         df = pd.DataFrame([1, 2, 3])
2020-12-03T03:15:02.4155771Z >       df.to_markdown(buf=buf, tablefmt="jira")
2020-12-03T03:15:02.4155979Z 
2020-12-03T03:15:02.4156225Z pandas/tests/io/formats/test_to_markdown.py:35: 
2020-12-03T03:15:02.4156545Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2020-12-03T03:15:02.4156876Z pandas/core/frame.py:2342: in to_markdown
2020-12-03T03:15:02.4157155Z     tabulate = import_optional_dependency("tabulate")
2020-12-03T03:15:02.4157471Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2020-12-03T03:15:02.4157737Z 
2020-12-03T03:15:02.4158184Z name = 'tabulate', extra = '', raise_on_missing = True, on_version = 'raise'
2020-12-03T03:15:02.4158489Z 
2020-12-03T03:15:02.4158709Z     def import_optional_dependency(
2020-12-03T03:15:02.4159195Z         name: str, extra: str = "", raise_on_missing: bool = True, on_version: str = "raise"
2020-12-03T03:15:02.4159540Z     ):
2020-12-03T03:15:02.4159902Z         """
2020-12-03T03:15:02.4160163Z         Import an optional dependency.
2020-12-03T03:15:02.4160390Z     
2020-12-03T03:15:02.4160653Z         By default, if a dependency is missing an ImportError with a nice
2020-12-03T03:15:02.4161023Z         message will be raised. If a dependency is present, but too old,
2020-12-03T03:15:02.4161305Z         we raise.
2020-12-03T03:15:02.4161525Z     
2020-12-03T03:15:02.4161720Z         Parameters
2020-12-03T03:15:02.4162130Z         ----------
2020-12-03T03:15:02.4162403Z         name : str
2020-12-03T03:15:02.4162889Z             The module name. This should be top-level only, so that the
2020-12-03T03:15:02.4163522Z             version may be checked.
2020-12-03T03:15:02.4163773Z         extra : str
2020-12-03T03:15:02.4164085Z             Additional text to include in the ImportError message.
2020-12-03T03:15:02.4164398Z         raise_on_missing : bool, default True
2020-12-03T03:15:02.4164723Z             Whether to raise if the optional dependency is not found.
2020-12-03T03:15:02.4165055Z             When False and the module is not present, None is returned.
2020-12-03T03:15:02.4165571Z         on_version : str {'raise', 'warn'}
2020-12-03T03:15:02.4166089Z             What to do when a dependency's version is too old.
2020-12-03T03:15:02.4166379Z     
2020-12-03T03:15:02.4166637Z             * raise : Raise an ImportError
2020-12-03T03:15:02.4166944Z             * warn : Warn that the version is too old. Returns None
2020-12-03T03:15:02.4167302Z             * ignore: Return the module, even if the version is too old.
2020-12-03T03:15:02.4167830Z               It's expected that users validate the version locally when
2020-12-03T03:15:02.4168221Z               using ``on_version="ignore"`` (see. ``io/html.py``)
2020-12-03T03:15:02.4168480Z     
2020-12-03T03:15:02.4168665Z         Returns
2020-12-03T03:15:02.4169032Z         -------
2020-12-03T03:15:02.4169317Z         maybe_module : Optional[ModuleType]
2020-12-03T03:15:02.4169657Z             The imported module, when found and the version is correct.
2020-12-03T03:15:02.4170004Z             None is returned when the package is not found and `raise_on_missing`
2020-12-03T03:15:02.4170565Z             is False, or when the package's version is too old and `on_version`
2020-12-03T03:15:02.4171046Z             is ``'warn'``.
2020-12-03T03:15:02.4171316Z         """
2020-12-03T03:15:02.4171512Z     
2020-12-03T03:15:02.4171734Z         package_name = INSTALL_MAPPING.get(name)
2020-12-03T03:15:02.4172059Z         install_name = package_name if package_name is not None else name
2020-12-03T03:15:02.4172335Z     
2020-12-03T03:15:02.4172545Z         msg = (
2020-12-03T03:15:02.4172993Z             f"Missing optional dependency '{install_name}'. {extra} "
2020-12-03T03:15:02.4173530Z             f"Use pip or conda to install {install_name}."
2020-12-03T03:15:02.4173831Z         )
2020-12-03T03:15:02.4174037Z         try:
2020-12-03T03:15:02.4174305Z             module = importlib.import_module(name)
2020-12-03T03:15:02.4174587Z         except ImportError:
2020-12-03T03:15:02.4174873Z             if raise_on_missing:
2020-12-03T03:15:02.4175157Z                 raise ImportError(msg) from None
2020-12-03T03:15:02.4175609Z             else:
2020-12-03T03:15:02.4176051Z                 return None
2020-12-03T03:15:02.4176282Z     
2020-12-03T03:15:02.4176544Z         minimum_version = VERSIONS.get(name)
2020-12-03T03:15:02.4176837Z         if minimum_version:
2020-12-03T03:15:02.4177116Z             version = _get_version(module)
2020-12-03T03:15:02.4177499Z             if distutils.version.LooseVersion(version) < minimum_version:
2020-12-03T03:15:02.4177891Z                 assert on_version in {"warn", "raise", "ignore"}
2020-12-03T03:15:02.4178374Z                 msg = (
2020-12-03T03:15:02.4179083Z                     f"Pandas requires version '{minimum_version}' or newer of '{name}' "
2020-12-03T03:15:02.4179949Z                     f"(version '{version}' currently installed)."
2020-12-03T03:15:02.4180262Z                 )
2020-12-03T03:15:02.4180536Z                 if on_version == "warn":
2020-12-03T03:15:02.4180823Z                     warnings.warn(msg, UserWarning)
2020-12-03T03:15:02.4181086Z                     return None
2020-12-03T03:15:02.4181481Z                 elif on_version == "raise":
2020-12-03T03:15:02.4181786Z >                   raise ImportError(msg)
2020-12-03T03:15:02.4182413Z E                   ImportError: Pandas requires version '0.8.7' or newer of 'tabulate' (version '0.8.3' currently installed).
2020-12-03T03:15:02.4182768Z 
2020-12-03T03:15:02.4183024Z pandas/compat/_optional.py:126: ImportError
2020-12-03T03:15:02.4183444Z ______________________________ test_other_headers ______________________________
2020-12-03T03:15:02.4184003Z [gw1] linux -- Python 3.8.5 /home/vsts/miniconda3/envs/pandas-dev/bin/python
2020-12-03T03:15:02.4184315Z 
2020-12-03T03:15:02.4184537Z     def test_other_headers():
2020-12-03T03:15:02.4184789Z         buf = StringIO()
2020-12-03T03:15:02.4185026Z         df = pd.DataFrame([1, 2, 3])
2020-12-03T03:15:02.4185294Z >       df.to_markdown(buf=buf, headers=["foo", "bar"])
2020-12-03T03:15:02.4185524Z 
2020-12-03T03:15:02.4185754Z pandas/tests/io/formats/test_to_markdown.py:43: 
2020-12-03T03:15:02.4186199Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2020-12-03T03:15:02.4186572Z pandas/core/frame.py:2342: in to_markdown
2020-12-03T03:15:02.4186852Z     tabulate = import_optional_dependency("tabulate")
2020-12-03T03:15:02.4187191Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2020-12-03T03:15:02.4187625Z 
2020-12-03T03:15:02.4188133Z name = 'tabulate', extra = '', raise_on_missing = True, on_version = 'raise'
2020-12-03T03:15:02.4188436Z 
2020-12-03T03:15:02.4188666Z     def import_optional_dependency(
2020-12-03T03:15:02.4189052Z         name: str, extra: str = "", raise_on_missing: bool = True, on_version: str = "raise"
2020-12-03T03:15:02.4189560Z     ):
2020-12-03T03:15:02.4189784Z         """
2020-12-03T03:15:02.4190024Z         Import an optional dependency.
2020-12-03T03:15:02.4190299Z     
2020-12-03T03:15:02.4190575Z         By default, if a dependency is missing an ImportError with a nice
2020-12-03T03:15:02.4191114Z         message will be raised. If a dependency is present, but too old,
2020-12-03T03:15:02.4191416Z         we raise.
2020-12-03T03:15:02.4191617Z     
2020-12-03T03:15:02.4191832Z         Parameters
2020-12-03T03:15:02.4192443Z         ----------
2020-12-03T03:15:02.4192731Z         name : str
2020-12-03T03:15:02.4193246Z             The module name. This should be top-level only, so that the
2020-12-03T03:15:02.4193611Z             version may be checked.
2020-12-03T03:15:02.4193898Z         extra : str
2020-12-03T03:15:02.4194188Z             Additional text to include in the ImportError message.
2020-12-03T03:15:02.4194542Z         raise_on_missing : bool, default True
2020-12-03T03:15:02.4194878Z             Whether to raise if the optional dependency is not found.
2020-12-03T03:15:02.4195255Z             When False and the module is not present, None is returned.
2020-12-03T03:15:02.4195763Z         on_version : str {'raise', 'warn'}
2020-12-03T03:15:02.4196307Z             What to do when a dependency's version is too old.
2020-12-03T03:15:02.4196638Z     
2020-12-03T03:15:02.4196898Z             * raise : Raise an ImportError
2020-12-03T03:15:02.4197246Z             * warn : Warn that the version is too old. Returns None
2020-12-03T03:15:02.4197619Z             * ignore: Return the module, even if the version is too old.
2020-12-03T03:15:02.4198378Z               It's expected that users validate the version locally when
2020-12-03T03:15:02.4198947Z               using ``on_version="ignore"`` (see. ``io/html.py``)
2020-12-03T03:15:02.4199243Z     
2020-12-03T03:15:02.4199469Z         Returns
2020-12-03T03:15:02.4200150Z         -------
2020-12-03T03:15:02.4200479Z         maybe_module : Optional[ModuleType]
2020-12-03T03:15:02.4200812Z             The imported module, when found and the version is correct.
2020-12-03T03:15:02.4201193Z             None is returned when the package is not found and `raise_on_missing`
2020-12-03T03:15:02.4201965Z             is False, or when the package's version is too old and `on_version`
2020-12-03T03:15:02.4203309Z             is ``'warn'``.
2020-12-03T03:15:02.4203605Z         """
2020-12-03T03:15:02.4203808Z     
2020-12-03T03:15:02.4204065Z         package_name = INSTALL_MAPPING.get(name)
2020-12-03T03:15:02.4204386Z         install_name = package_name if package_name is not None else name
2020-12-03T03:15:02.4204674Z     
2020-12-03T03:15:02.4204872Z         msg = (
2020-12-03T03:15:02.4205648Z             f"Missing optional dependency '{install_name}'. {extra} "
2020-12-03T03:15:02.4206047Z             f"Use pip or conda to install {install_name}."
2020-12-03T03:15:02.4206303Z         )
2020-12-03T03:15:02.4206519Z         try:
2020-12-03T03:15:02.4206757Z             module = importlib.import_module(name)
2020-12-03T03:15:02.4207037Z         except ImportError:
2020-12-03T03:15:02.4207299Z             if raise_on_missing:
2020-12-03T03:15:02.4207568Z                 raise ImportError(msg) from None
2020-12-03T03:15:02.4207832Z             else:
2020-12-03T03:15:02.4208053Z                 return None
2020-12-03T03:15:02.4208269Z     
2020-12-03T03:15:02.4208485Z         minimum_version = VERSIONS.get(name)
2020-12-03T03:15:02.4208756Z         if minimum_version:
2020-12-03T03:15:02.4209010Z             version = _get_version(module)
2020-12-03T03:15:02.4209362Z             if distutils.version.LooseVersion(version) < minimum_version:
2020-12-03T03:15:02.4209739Z                 assert on_version in {"warn", "raise", "ignore"}
2020-12-03T03:15:02.4210004Z                 msg = (
2020-12-03T03:15:02.4210520Z                     f"Pandas requires version '{minimum_version}' or newer of '{name}' "
2020-12-03T03:15:02.4211086Z                     f"(version '{version}' currently installed)."
2020-12-03T03:15:02.4211417Z                 )
2020-12-03T03:15:02.4211670Z                 if on_version == "warn":
2020-12-03T03:15:02.4211953Z                     warnings.warn(msg, UserWarning)
2020-12-03T03:15:02.4212230Z                     return None
2020-12-03T03:15:02.4212497Z                 elif on_version == "raise":
2020-12-03T03:15:02.4212794Z >                   raise ImportError(msg)
2020-12-03T03:15:02.4213389Z E                   ImportError: Pandas requires version '0.8.7' or newer of 'tabulate' (version '0.8.3' currently installed).
2020-12-03T03:15:02.4213765Z 
2020-12-03T03:15:02.4213996Z pandas/compat/_optional.py:126: ImportError

Might we want to bump the version of tabulate in that environment?

@arw2019
Copy link
Contributor

arw2019 commented Dec 11, 2020

Closing in favor of #38406

@arw2019 arw2019 closed this Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

IO Data IO issues that don't fit into a more specific label Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: df.to_markdown() with empty frame incorrect output

4 participants