neulab/docprompting-conala huggingface dataset:
pandas.api.extensions.ExtensionArray.take   ExtensionArray.take(indices, *, allow_fill=False, fill_value=None)[source]
 
Take elements from an array.  Parameters 
 
indices:sequence of int or one-dimensional np.ndarray of int


Indices to be taken.  
allow_fill:bool, default False


How to handle negative values in indices.  False: negative values in indices indicate positional indices from the right (the default). This is similar to numpy.take(). True: negative values in indices indicate missing values. These values are set to fill_value. Any other other negative values raise a ValueError.   
fill_value:any, optional


Fill value to use for NA-indices when allow_fill is True. This may be None, in which case the default NA value for the type, self.dtype.na_value, is used. For many ExtensionArrays, there will be two representations of fill_value: a user-facing “boxed” scalar, and a low-level physical NA value. fill_value should be the user-facing version, and the implementation should handle translating that to the physical version for processing the take if necessary.    Returns 
 ExtensionArray
  Raises 
 IndexError

When the indices are out of bounds for the array.  ValueError

When indices contains negative values other than -1 and allow_fill is True.      See also  numpy.take

Take elements from an array along an axis.  api.extensions.take

Take elements from an array.    Notes ExtensionArray.take is called by Series.__getitem__, .loc, iloc, when indices is a sequence of values. Additionally, it’s called by Series.reindex(), or any other method that causes realignment, with a fill_value. Examples Here’s an example implementation, which relies on casting the extension array to object dtype. This uses the helper method pandas.api.extensions.take(). 
def take(self, indices, allow_fill=False, fill_value=None):
    from pandas.core.algorithms import take

    # If the ExtensionArray is backed by an ndarray, then
    # just pass that here instead of coercing to object.
    data = self.astype(object)

    if allow_fill and fill_value is None:
        fill_value = self.dtype.na_value

    # fill value should always be translated from the scalar
    # type for the array, to the physical storage type for
    # the data, before passing to take.

    result = take(data, indices, fill_value=fill_value,
                  allow_fill=allow_fill)
    return self._from_sequence(result, dtype=self.dtype)
pandas.api.extensions.ExtensionArray.tolist   ExtensionArray.tolist()[source]
 
Return a list of the values. These are each a scalar type, which is a Python scalar (for str, int, float) or a pandas scalar (for Timestamp/Timedelta/Interval/Period)  Returns 
 list
pandas.api.extensions.ExtensionArray.unique   ExtensionArray.unique()[source]
 
Compute the ExtensionArray of unique values.  Returns 
 
uniques:ExtensionArray
pandas.api.extensions.ExtensionArray.view   ExtensionArray.view(dtype=None)[source]
 
Return a view on the array.  Parameters 
 
dtype:str, np.dtype, or ExtensionDtype, optional


Default None.    Returns 
 ExtensionArray or np.ndarray

A view on the ExtensionArray’s data.
pandas.api.extensions.ExtensionDtype   classpandas.api.extensions.ExtensionDtype[source]
 
A custom data type, to be paired with an ExtensionArray.  See also  extensions.register_extension_dtype

Register an ExtensionType with pandas as class decorator.  extensions.ExtensionArray

Abstract base class for custom 1-D array types.    Notes The interface includes the following abstract methods that must be implemented by subclasses:  type name construct_array_type  The following attributes and methods influence the behavior of the dtype in pandas operations  _is_numeric _is_boolean _get_common_dtype  The na_value class attribute can be used to set the default NA value for this type. numpy.nan is used by default. ExtensionDtypes are required to be hashable. The base class provides a default implementation, which relies on the _metadata class attribute. _metadata should be a tuple containing the strings that define your data type. For example, with PeriodDtype that’s the freq attribute. If you have a parametrized dtype you should set the ``_metadata`` class property. Ideally, the attributes in _metadata will match the parameters to your ExtensionDtype.__init__ (if any). If any of the attributes in _metadata don’t implement the standard __eq__ or __hash__, the default implementations here will not work. For interaction with Apache Arrow (pyarrow), a __from_arrow__ method can be implemented: this method receives a pyarrow Array or ChunkedArray as only argument and is expected to return the appropriate pandas ExtensionArray for this dtype and the passed values: 
class ExtensionDtype:

    def __from_arrow__(
        self, array: Union[pyarrow.Array, pyarrow.ChunkedArray]
    ) -> ExtensionArray:
        ...
  This class does not inherit from ‘abc.ABCMeta’ for performance reasons. Methods and properties required by the interface raise pandas.errors.AbstractMethodError and no register method is provided for registering virtual subclasses. Attributes       
kind A character code (one of 'biufcmMOSUV'), default 'O'  
na_value Default NA value to use for this type.  
name A string identifying the data type.  
names Ordered list of field names, or None if there are no fields.  
type The scalar type for the array, e.g.    Methods       
construct_array_type() Return the array type associated with this dtype.  
construct_from_string(string) Construct this type from a string.  
empty(shape) Construct an ExtensionArray of this dtype with the given shape.  
is_dtype(dtype) Check if we match 'dtype'.
pandas.api.extensions.ExtensionDtype.construct_array_type   classmethodExtensionDtype.construct_array_type()[source]
 
Return the array type associated with this dtype.  Returns 
 type
pandas.api.extensions.ExtensionDtype.construct_from_string   classmethodExtensionDtype.construct_from_string(string)[source]
 
Construct this type from a string. This is useful mainly for data types that accept parameters. For example, a period dtype accepts a frequency parameter that can be set as period[H] (where H means hourly frequency). By default, in the abstract class, just the name of the type is expected. But subclasses can overwrite this method to accept parameters.  Parameters 
 
string:str


The name of the type, for example category.    Returns 
 ExtensionDtype

Instance of the dtype.    Raises 
 TypeError

If a class cannot be constructed from this ‘string’.     Examples For extension dtypes with arguments the following may be an adequate implementation. 
>>> @classmethod
... def construct_from_string(cls, string):
...     pattern = re.compile(r"^my_type\[(?P<arg_name>.+)\]$")
...     match = pattern.match(string)
...     if match:
...         return cls(**match.groupdict())
...     else:
...         raise TypeError(
...             f"Cannot construct a '{cls.__name__}' from '{string}'"
...         )
pandas.api.extensions.ExtensionDtype.empty   ExtensionDtype.empty(shape)[source]
 
Construct an ExtensionArray of this dtype with the given shape. Analogous to numpy.empty.  Parameters 
 
shape:int or tuple[int]

  Returns 
 ExtensionArray
pandas.api.extensions.ExtensionDtype.is_dtype   classmethodExtensionDtype.is_dtype(dtype)[source]
 
Check if we match ‘dtype’.  Parameters 
 
dtype:object


The object to check.    Returns 
 bool
   Notes The default implementation is True if  cls.construct_from_string(dtype) is an instance of cls. dtype is an object and is an instance of cls dtype has a dtype attribute, and any of the above conditions is true for dtype.dtype.
pandas.api.extensions.ExtensionDtype.kind   propertyExtensionDtype.kind
 
A character code (one of ‘biufcmMOSUV’), default ‘O’ This should match the NumPy dtype used when the array is converted to an ndarray, which is probably ‘O’ for object if the extension type cannot be represented as a built-in NumPy type.  See also  numpy.dtype.kind
pandas.api.extensions.ExtensionDtype.na_value   propertyExtensionDtype.na_value
 
Default NA value to use for this type. This is used in e.g. ExtensionArray.take. This should be the user-facing “boxed” version of the NA value, not the physical NA value for storage. e.g. for JSONArray, this is an empty dictionary.
pandas.api.extensions.ExtensionDtype.name   propertyExtensionDtype.name
 
A string identifying the data type. Will be used for display in, e.g. Series.dtype
pandas.api.extensions.ExtensionDtype.names   propertyExtensionDtype.names
 
Ordered list of field names, or None if there are no fields. This is for compatibility with NumPy arrays, and may be removed in the future.
pandas.api.extensions.ExtensionDtype.type   propertyExtensionDtype.type
 
The scalar type for the array, e.g. int It’s expected ExtensionArray[item] returns an instance of ExtensionDtype.type for scalar item, assuming that value is valid (not NA). NA values do not need to be instances of type.
pandas.api.extensions.register_dataframe_accessor   pandas.api.extensions.register_dataframe_accessor(name)[source]
 
Register a custom accessor on DataFrame objects.  Parameters 
 
name:str


Name under which the accessor should be registered. A warning is issued if this name conflicts with a preexisting attribute.    Returns 
 callable

A class decorator.      See also  register_dataframe_accessor

Register a custom accessor on DataFrame objects.  register_series_accessor

Register a custom accessor on Series objects.  register_index_accessor

Register a custom accessor on Index objects.    Notes When accessed, your accessor will be initialized with the pandas object the user is interacting with. So the signature must be 
def __init__(self, pandas_object):  # noqa: E999
    ...
  For consistency with pandas methods, you should raise an AttributeError if the data passed to your accessor has an incorrect dtype. 
>>> pd.Series(['a', 'b']).dt
Traceback (most recent call last):
...
AttributeError: Can only use .dt accessor with datetimelike values
  Examples In your library code: 
import pandas as pd

@pd.api.extensions.register_dataframe_accessor("geo")
class GeoAccessor:
    def __init__(self, pandas_obj):
        self._obj = pandas_obj

    @property
    def center(self):
        # return the geographic center point of this DataFrame
        lat = self._obj.latitude
        lon = self._obj.longitude
        return (float(lon.mean()), float(lat.mean()))

    def plot(self):
        # plot this array's data on a map, e.g., using Cartopy
        pass
  Back in an interactive IPython session:  

In [1]: ds = pd.DataFrame({"longitude": np.linspace(0, 10),
   ...:                    "latitude": np.linspace(0, 20)})
In [2]: ds.geo.center
Out[2]: (5.0, 10.0)
In [3]: ds.geo.plot()  # plots data on a map
pandas.api.extensions.register_extension_dtype   pandas.api.extensions.register_extension_dtype(cls)[source]
 
Register an ExtensionType with pandas as class decorator. This enables operations like .astype(name) for the name of the ExtensionDtype.  Returns 
 callable

A class decorator.     Examples 
>>> from pandas.api.extensions import register_extension_dtype, ExtensionDtype
>>> @register_extension_dtype
... class MyExtensionDtype(ExtensionDtype):
...     name = "myextension"
pandas.api.extensions.register_index_accessor   pandas.api.extensions.register_index_accessor(name)[source]
 
Register a custom accessor on Index objects.  Parameters 
 
name:str


Name under which the accessor should be registered. A warning is issued if this name conflicts with a preexisting attribute.    Returns 
 callable

A class decorator.      See also  register_dataframe_accessor

Register a custom accessor on DataFrame objects.  register_series_accessor

Register a custom accessor on Series objects.  register_index_accessor

Register a custom accessor on Index objects.    Notes When accessed, your accessor will be initialized with the pandas object the user is interacting with. So the signature must be 
def __init__(self, pandas_object):  # noqa: E999
    ...
  For consistency with pandas methods, you should raise an AttributeError if the data passed to your accessor has an incorrect dtype. 
>>> pd.Series(['a', 'b']).dt
Traceback (most recent call last):
...
AttributeError: Can only use .dt accessor with datetimelike values
  Examples In your library code: 
import pandas as pd

@pd.api.extensions.register_dataframe_accessor("geo")
class GeoAccessor:
    def __init__(self, pandas_obj):
        self._obj = pandas_obj

    @property
    def center(self):
        # return the geographic center point of this DataFrame
        lat = self._obj.latitude
        lon = self._obj.longitude
        return (float(lon.mean()), float(lat.mean()))

    def plot(self):
        # plot this array's data on a map, e.g., using Cartopy
        pass
  Back in an interactive IPython session:  

In [1]: ds = pd.DataFrame({"longitude": np.linspace(0, 10),
   ...:                    "latitude": np.linspace(0, 20)})
In [2]: ds.geo.center
Out[2]: (5.0, 10.0)
In [3]: ds.geo.plot()  # plots data on a map
pandas.api.extensions.register_series_accessor   pandas.api.extensions.register_series_accessor(name)[source]
 
Register a custom accessor on Series objects.  Parameters 
 
name:str


Name under which the accessor should be registered. A warning is issued if this name conflicts with a preexisting attribute.    Returns 
 callable

A class decorator.      See also  register_dataframe_accessor

Register a custom accessor on DataFrame objects.  register_series_accessor

Register a custom accessor on Series objects.  register_index_accessor

Register a custom accessor on Index objects.    Notes When accessed, your accessor will be initialized with the pandas object the user is interacting with. So the signature must be 
def __init__(self, pandas_object):  # noqa: E999
    ...
  For consistency with pandas methods, you should raise an AttributeError if the data passed to your accessor has an incorrect dtype. 
>>> pd.Series(['a', 'b']).dt
Traceback (most recent call last):
...
AttributeError: Can only use .dt accessor with datetimelike values
  Examples In your library code: 
import pandas as pd

@pd.api.extensions.register_dataframe_accessor("geo")
class GeoAccessor:
    def __init__(self, pandas_obj):
        self._obj = pandas_obj

    @property
    def center(self):
        # return the geographic center point of this DataFrame
        lat = self._obj.latitude
        lon = self._obj.longitude
        return (float(lon.mean()), float(lat.mean()))

    def plot(self):
        # plot this array's data on a map, e.g., using Cartopy
        pass
  Back in an interactive IPython session:  

In [1]: ds = pd.DataFrame({"longitude": np.linspace(0, 10),
   ...:                    "latitude": np.linspace(0, 20)})
In [2]: ds.geo.center
Out[2]: (5.0, 10.0)
In [3]: ds.geo.plot()  # plots data on a map
pandas.api.indexers.BaseIndexer   classpandas.api.indexers.BaseIndexer(index_array=None, window_size=0, **kwargs)[source]
 
Base class for window bounds calculations. Methods       
get_window_bounds([num_values, min_periods, ...]) Computes the bounds of a window.
pandas.api.indexers.BaseIndexer.get_window_bounds   BaseIndexer.get_window_bounds(num_values=0, min_periods=None, center=None, closed=None)[source]
 
Computes the bounds of a window.  Parameters 
 
num_values:int, default 0


number of values that will be aggregated over  
window_size:int, default 0


the number of rows in a window  
min_periods:int, default None


min_periods passed from the top level rolling API  
center:bool, default None


center passed from the top level rolling API  
closed:str, default None


closed passed from the top level rolling API  
win_type:str, default None


win_type passed from the top level rolling API    Returns 
 A tuple of ndarray[int64]s, indicating the boundaries of each
window
pandas.api.indexers.check_array_indexer   pandas.api.indexers.check_array_indexer(array, indexer)[source]
 
Check if indexer is a valid array indexer for array. For a boolean mask, array and indexer are checked to have the same length. The dtype is validated, and if it is an integer or boolean ExtensionArray, it is checked if there are missing values present, and it is converted to the appropriate numpy array. Other dtypes will raise an error. Non-array indexers (integer, slice, Ellipsis, tuples, ..) are passed through as is.  New in version 1.0.0.   Parameters 
 
array:array-like


The array that is being indexed (only used for the length).  
indexer:array-like or list-like


The array-like that’s used to index. List-like input that is not yet a numpy array or an ExtensionArray is converted to one. Other input types are passed through as is.    Returns 
 numpy.ndarray

The validated indexer as a numpy array that can be used to index.    Raises 
 IndexError

When the lengths don’t match.  ValueError

When indexer cannot be converted to a numpy ndarray to index (e.g. presence of missing values).      See also  api.types.is_bool_dtype

Check if key is of boolean dtype.    Examples When checking a boolean mask, a boolean ndarray is returned when the arguments are all valid. 
>>> mask = pd.array([True, False])
>>> arr = pd.array([1, 2])
>>> pd.api.indexers.check_array_indexer(arr, mask)
array([ True, False])
  An IndexError is raised when the lengths don’t match. 
>>> mask = pd.array([True, False, True])
>>> pd.api.indexers.check_array_indexer(arr, mask)
Traceback (most recent call last):
...
IndexError: Boolean index has wrong length: 3 instead of 2.
  NA values in a boolean array are treated as False. 
>>> mask = pd.array([True, pd.NA])
>>> pd.api.indexers.check_array_indexer(arr, mask)
array([ True, False])
  A numpy boolean mask will get passed through (if the length is correct): 
>>> mask = np.array([True, False])
>>> pd.api.indexers.check_array_indexer(arr, mask)
array([ True, False])
  Similarly for integer indexers, an integer ndarray is returned when it is a valid indexer, otherwise an error is (for integer indexers, a matching length is not required): 
>>> indexer = pd.array([0, 2], dtype="Int64")
>>> arr = pd.array([1, 2, 3])
>>> pd.api.indexers.check_array_indexer(arr, indexer)
array([0, 2])
  
>>> indexer = pd.array([0, pd.NA], dtype="Int64")
>>> pd.api.indexers.check_array_indexer(arr, indexer)
Traceback (most recent call last):
...
ValueError: Cannot index with an integer indexer containing NA values
  For non-integer/boolean dtypes, an appropriate error is raised: 
>>> indexer = np.array([0., 2.], dtype="float64")
>>> pd.api.indexers.check_array_indexer(arr, indexer)
Traceback (most recent call last):
...
IndexError: arrays used as indices must be of integer or boolean type
pandas.api.indexers.FixedForwardWindowIndexer   classpandas.api.indexers.FixedForwardWindowIndexer(index_array=None, window_size=0, **kwargs)[source]
 
Creates window boundaries for fixed-length windows that include the current row. Examples 
>>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]})
>>> df
     B
0  0.0
1  1.0
2  2.0
3  NaN
4  4.0
  
>>> indexer = pd.api.indexers.FixedForwardWindowIndexer(window_size=2)
>>> df.rolling(window=indexer, min_periods=1).sum()
     B
0  1.0
1  3.0
2  2.0
3  4.0
4  4.0
  Methods       
get_window_bounds([num_values, min_periods, ...]) Computes the bounds of a window.
pandas.api.indexers.FixedForwardWindowIndexer.get_window_bounds   FixedForwardWindowIndexer.get_window_bounds(num_values=0, min_periods=None, center=None, closed=None)[source]
 
Computes the bounds of a window.  Parameters 
 
num_values:int, default 0


number of values that will be aggregated over  
window_size:int, default 0


the number of rows in a window  
min_periods:int, default None


min_periods passed from the top level rolling API  
center:bool, default None


center passed from the top level rolling API  
closed:str, default None


closed passed from the top level rolling API  
win_type:str, default None


win_type passed from the top level rolling API    Returns 
 A tuple of ndarray[int64]s, indicating the boundaries of each
window
pandas.api.indexers.VariableOffsetWindowIndexer   classpandas.api.indexers.VariableOffsetWindowIndexer(index_array=None, window_size=0, index=None, offset=None, **kwargs)[source]
 
Calculate window boundaries based on a non-fixed offset such as a BusinessDay. Methods       
get_window_bounds([num_values, min_periods, ...]) Computes the bounds of a window.
pandas.api.indexers.VariableOffsetWindowIndexer.get_window_bounds   VariableOffsetWindowIndexer.get_window_bounds(num_values=0, min_periods=None, center=None, closed=None)[source]
 
Computes the bounds of a window.  Parameters 
 
num_values:int, default 0


number of values that will be aggregated over  
window_size:int, default 0


the number of rows in a window  
min_periods:int, default None


min_periods passed from the top level rolling API  
center:bool, default None


center passed from the top level rolling API  
closed:str, default None


closed passed from the top level rolling API  
win_type:str, default None


win_type passed from the top level rolling API    Returns 
 A tuple of ndarray[int64]s, indicating the boundaries of each
window
pandas.api.types.infer_dtype   pandas.api.types.infer_dtype()
 
Efficiently infer the type of a passed val, or list-like array of values. Return a string describing the type.  Parameters 
 
value:scalar, list, ndarray, or pandas type


skipna:bool, default True


Ignore NaN values when inferring the type.    Returns 
 str

Describing the common type of the input data.  Results can include:
  
 string
  
 bytes
  
 floating
  
 integer
  
 mixed-integer
  
 mixed-integer-float
  
 decimal
  
 complex
  
 categorical
  
 boolean
  
 datetime64
  
 datetime
  
 date
  
 timedelta64
  
 timedelta
  
 time
  
 period
  
 mixed
  
 unknown-array
    Raises 
 TypeError

If ndarray-like but cannot infer the dtype     Notes  ‘mixed’ is the catchall for anything that is not otherwise specialized ‘mixed-integer-float’ are floats and integers ‘mixed-integer’ are integers mixed with non-integers ‘unknown-array’ is the catchall for something that is an array (has a dtype attribute), but has a dtype unknown to pandas (e.g. external extension array)  Examples 
>>> import datetime
>>> infer_dtype(['foo', 'bar'])
'string'
  
>>> infer_dtype(['a', np.nan, 'b'], skipna=True)
'string'
  
>>> infer_dtype(['a', np.nan, 'b'], skipna=False)
'mixed'
  
>>> infer_dtype([b'foo', b'bar'])
'bytes'
  
>>> infer_dtype([1, 2, 3])
'integer'
  
>>> infer_dtype([1, 2, 3.5])
'mixed-integer-float'
  
>>> infer_dtype([1.0, 2.0, 3.5])
'floating'
  
>>> infer_dtype(['a', 1])
'mixed-integer'
  
>>> infer_dtype([Decimal(1), Decimal(2.0)])
'decimal'
  
>>> infer_dtype([True, False])
'boolean'
  
>>> infer_dtype([True, False, np.nan])
'boolean'
  
>>> infer_dtype([pd.Timestamp('20130101')])
'datetime'
  
>>> infer_dtype([datetime.date(2013, 1, 1)])
'date'
  
>>> infer_dtype([np.datetime64('2013-01-01')])
'datetime64'
  
>>> infer_dtype([datetime.timedelta(0, 1, 1)])
'timedelta'
  
>>> infer_dtype(pd.Series(list('aabc')).astype('category'))
'categorical'
pandas.api.types.is_bool   pandas.api.types.is_bool()
 
Return True if given object is boolean.  Returns 
 bool
pandas.api.types.is_bool_dtype   pandas.api.types.is_bool_dtype(arr_or_dtype)[source]
 
Check whether the provided array or dtype is of a boolean dtype.  Parameters 
 
arr_or_dtype:array-like or dtype


The array or dtype to check.    Returns 
 boolean

Whether or not the array or dtype is of a boolean dtype.     Notes An ExtensionArray is considered boolean when the _is_boolean attribute is set to True. Examples 
>>> is_bool_dtype(str)
False
>>> is_bool_dtype(int)
False
>>> is_bool_dtype(bool)
True
>>> is_bool_dtype(np.bool_)
True
>>> is_bool_dtype(np.array(['a', 'b']))
False
>>> is_bool_dtype(pd.Series([1, 2]))
False
>>> is_bool_dtype(np.array([True, False]))
True
>>> is_bool_dtype(pd.Categorical([True, False]))
True
>>> is_bool_dtype(pd.arrays.SparseArray([True, False]))
True