Skip to content
New issue

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

Annotate DataFrame (Part 1) #26867

Merged
merged 28 commits into from
Sep 12, 2019
Merged
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bc01d66
type a few functions
vaibhavhrt Jun 15, 2019
5e70e01
fix flake errors
vaibhavhrt Jun 15, 2019
305329e
minor changes
vaibhavhrt Jun 15, 2019
58a7da6
create type for Axes in _typing and make parameters of __init__ optional
vaibhavhrt Jun 17, 2019
691d1bb
update from master
vaibhavhrt Jul 17, 2019
c54642f
WIP type for data
vaibhavhrt Jul 17, 2019
0fd42eb
move types for 'data' in 'frame.py' from 'pandas._typing'
vaibhavhrt Jul 24, 2019
38bf4e0
merge master
vaibhavhrt Jul 24, 2019
e413504
use ABCDataFrame instead of 'DataFrame'
vaibhavhrt Jul 25, 2019
77f93fc
merge master
vaibhavhrt Jul 25, 2019
5ec1c87
use Index instead of ABCIndex
vaibhavhrt Jul 26, 2019
161dfcc
merge master
vaibhavhrt Jul 26, 2019
17214ea
use typing.Dict instead of dict
vaibhavhrt Jul 26, 2019
fba0fcc
add more tyoes in data, error expected
vaibhavhrt Jul 29, 2019
4560a97
Merge branch 'master' into annotate-DataFrame
vaibhavhrt Aug 24, 2019
6da817c
remove anootation of data as it's causing problems
vaibhavhrt Aug 26, 2019
c4ceab0
remove unused import
vaibhavhrt Aug 26, 2019
8830f54
don't change anything in _typing
vaibhavhrt Aug 26, 2019
2e65291
put Axes back in pandas._typing
vaibhavhrt Aug 27, 2019
d99cc1a
format with black
vaibhavhrt Aug 28, 2019
c935b58
Merge branch 'master' into annotate-DataFrame
vaibhavhrt Aug 28, 2019
1740ef2
use Collection for Axes
vaibhavhrt Sep 7, 2019
a118f67
merge origin
vaibhavhrt Sep 7, 2019
f2edb32
revert Axes with comment
vaibhavhrt Sep 10, 2019
112f550
Apply suggestions from code review
vaibhavhrt Sep 11, 2019
8814eb3
Merge branch 'master' into annotate-DataFrame
vaibhavhrt Sep 12, 2019
4d78c4b
Merge branch 'annotate-DataFrame' of https://github.com/vaibhavhrt/pa…
vaibhavhrt Sep 12, 2019
d03e33c
Update _typing.py
WillAyd Sep 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import sys
import warnings
from textwrap import dedent
from typing import FrozenSet, List, Optional, Set, Type, Union
from typing import FrozenSet, List, Optional, Set, Tuple, Type, Union

import numpy as np
import numpy.ma as ma
Expand All @@ -25,6 +25,8 @@

from pandas._libs import lib, algos as libalgos

from pandas._typing import ArrayLike, Dtype

from pandas.util._decorators import (Appender, Substitution,
rewrite_axis_style_signature,
deprecate_kwarg)
Expand Down Expand Up @@ -358,7 +360,7 @@ class DataFrame(NDFrame):
"""

@property
def _constructor(self):
def _constructor(self) -> Type['DataFrame']:
vaibhavhrt marked this conversation as resolved.
Show resolved Hide resolved
return DataFrame

_constructor_sliced = Series # type: Type[Series]
Expand All @@ -374,8 +376,12 @@ def _constructor_expanddim(self):
# ----------------------------------------------------------------------
# Constructors

def __init__(self, data=None, index=None, columns=None, dtype=None,
copy=False):
def __init__(self,
data=None,
vaibhavhrt marked this conversation as resolved.
Show resolved Hide resolved
index: ArrayLike = None,
vaibhavhrt marked this conversation as resolved.
Show resolved Hide resolved
columns: ArrayLike = None,
dtype: Dtype = None,
vaibhavhrt marked this conversation as resolved.
Show resolved Hide resolved
vaibhavhrt marked this conversation as resolved.
Show resolved Hide resolved
copy: bool = False) -> None:
if data is None:
data = {}
vaibhavhrt marked this conversation as resolved.
Show resolved Hide resolved
if dtype is not None:
Expand Down Expand Up @@ -471,7 +477,7 @@ def __init__(self, data=None, index=None, columns=None, dtype=None,
# ----------------------------------------------------------------------

@property
def axes(self):
def axes(self) -> List[ArrayLike]:
vaibhavhrt marked this conversation as resolved.
Show resolved Hide resolved
"""
Return a list representing the axes of the DataFrame.

Expand All @@ -488,7 +494,7 @@ def axes(self):
return [self.index, self.columns]

@property
def shape(self):
def shape(self) -> Tuple[int, int]:
"""
Return a tuple representing the dimensionality of the DataFrame.

Expand All @@ -510,7 +516,7 @@ def shape(self):
return len(self.index), len(self.columns)

@property
def _is_homogeneous_type(self):
def _is_homogeneous_type(self) -> bool:
"""
Whether all the columns in a DataFrame have the same type.

Expand Down