We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python 3.6 pandas 1.1.5 pandas-stubs 1.2.0.1
The docs state that a list of bools is accepted for the ascending argument, but the stubs raise an error in that instance.
ascending
Minimal example of some (valid) code that fails type checking:
import pandas df = pandas.DataFrame( [[1, 'a'], [2, 'b'], [2, 'c']], columns=['num', 'char'] ) print(df) df = df.sort_values( by=['num', 'char'], ascending=[True, False], ) print(df)
Output:
num char 0 1 a 1 2 b 2 2 c num char 0 1 a 2 2 c 1 2 b
mypy error:
error: No overload variant of "sort_values" of "DataFrame" matches argument types "List[str]", "List[bool]", "bool" [call-overload] note: Possible overload variant: note: def sort_values(self, by: Union[str, List[str]], axis: Union[Literal[0], Literal[1], Union[Literal['index'], Literal['columns']]] = ..., ascending: bool = ..., kind: Union[Literal['quicksort'], Literal['mergesort'], Literal['heapsort']] = ..., na_position: Union[Literal['first'], Literal['last']] = ..., ignore_index: bool = ..., key: Optional[Callable[[Series], Union[Series, Union[Union[ExtensionArray, Any], Index, Series]]]] = ..., *, inplace: Literal[False] = ...) -> DataFrame note: <1 more non-matching overload not shown>
A workaround if you came here from a search engine:
import pandas df = pandas.DataFrame( [[1, 'a'], [2, 'b'], [2, 'c']], columns=['num', 'char'] ) print(df) ascending: Any = [True, False] df = df.sort_values( by=['num', 'char'], ascending=ascending, ) print(df)
The text was updated successfully, but these errors were encountered:
Hi! Thank you for reporting an issue. Please see #64 for a fix. It should be merged soon.
Sorry, something went wrong.
joannasendorek
Successfully merging a pull request may close this issue.
python 3.6
pandas 1.1.5
pandas-stubs 1.2.0.1
The docs state that a list of bools is accepted for the
ascending
argument, but the stubs raise an error in that instance.Minimal example of some (valid) code that fails type checking:
Output:
mypy error:
A workaround if you came here from a search engine:
The text was updated successfully, but these errors were encountered: