neulab/docprompting-conala huggingface dataset:
pandas.Series.transform   Series.transform(func, axis=0, *args, **kwargs)[source]
 
Call func on self producing a Series with the same axis shape as self.  Parameters 
 
func:function, str, list-like or dict-like


Function to use for transforming the data. If a function, must either work when passed a Series or when passed to Series.apply. If func is both list-like and dict-like, dict-like behavior takes precedence. Accepted combinations are:  function string function name list-like of functions and/or function names, e.g. [np.exp, 'sqrt'] dict-like of axis labels -> functions, function names or list-like of such.   
axis:{0 or ‘index’}


Parameter needed for compatibility with DataFrame.  *args

Positional arguments to pass to func.  **kwargs

Keyword arguments to pass to func.    Returns 
 Series

A Series that must have the same length as self.    Raises 
 
ValueError:If the returned Series has a different length than self.

    See also  Series.agg

Only perform aggregating type operations.  Series.apply

Invoke function on a Series.    Notes Functions that mutate the passed object can produce unexpected behavior or errors and are not supported. See Mutating with User Defined Function (UDF) methods for more details. Examples 
>>> df = pd.DataFrame({'A': range(3), 'B': range(1, 4)})
>>> df
   A  B
0  0  1
1  1  2
2  2  3
>>> df.transform(lambda x: x + 1)
   A  B
0  1  2
1  2  3
2  3  4
  Even though the resulting Series must have the same length as the input Series, it is possible to provide several input functions: 
>>> s = pd.Series(range(3))
>>> s
0    0
1    1
2    2
dtype: int64
>>> s.transform([np.sqrt, np.exp])
       sqrt        exp
0  0.000000   1.000000
1  1.000000   2.718282
2  1.414214   7.389056
  You can call transform on a GroupBy object: 
>>> df = pd.DataFrame({
...     "Date": [
...         "2015-05-08", "2015-05-07", "2015-05-06", "2015-05-05",
...         "2015-05-08", "2015-05-07", "2015-05-06", "2015-05-05"],
...     "Data": [5, 8, 6, 1, 50, 100, 60, 120],
... })
>>> df
         Date  Data
0  2015-05-08     5
1  2015-05-07     8
2  2015-05-06     6
3  2015-05-05     1
4  2015-05-08    50
5  2015-05-07   100
6  2015-05-06    60
7  2015-05-05   120
>>> df.groupby('Date')['Data'].transform('sum')
0     55
1    108
2     66
3    121
4     55
5    108
6     66
7    121
Name: Data, dtype: int64
  
>>> df = pd.DataFrame({
...     "c": [1, 1, 1, 2, 2, 2, 2],
...     "type": ["m", "n", "o", "m", "m", "n", "n"]
... })
>>> df
   c type
0  1    m
1  1    n
2  1    o
3  2    m
4  2    m
5  2    n
6  2    n
>>> df['size'] = df.groupby('c')['type'].transform(len)
>>> df
   c type size
0  1    m    3
1  1    n    3
2  1    o    3
3  2    m    4
4  2    m    4
5  2    n    4
6  2    n    4
pandas.Series.transpose   Series.transpose(*args, **kwargs)[source]
 
Return the transpose, which is by definition self.  Returns 
 %(klass)s
pandas.Series.truediv   Series.truediv(other, level=None, fill_value=None, axis=0)[source]
 
Return Floating division of series and other, element-wise (binary operator truediv). Equivalent to series / other, but with support to substitute a fill_value for missing data in either one of the inputs.  Parameters 
 
other:Series or scalar value


fill_value:None or float value, default None (NaN)


Fill existing missing (NaN) values, and any new element needed for successful Series alignment, with this value before computation. If data in both corresponding Series locations is missing the result of filling (at that location) will be missing.  
level:int or name


Broadcast across a level, matching Index values on the passed MultiIndex level.    Returns 
 Series

The result of the operation.      See also  Series.rtruediv

Reverse of the Floating division operator, see Python documentation for more details.    Examples 
>>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
>>> a
a    1.0
b    1.0
c    1.0
d    NaN
dtype: float64
>>> b = pd.Series([1, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])
>>> b
a    1.0
b    NaN
d    1.0
e    NaN
dtype: float64
>>> a.divide(b, fill_value=0)
a    1.0
b    inf
c    inf
d    0.0
e    NaN
dtype: float64
pandas.Series.truncate   Series.truncate(before=None, after=None, axis=None, copy=True)[source]
 
Truncate a Series or DataFrame before and after some index value. This is a useful shorthand for boolean indexing based on index values above or below certain thresholds.  Parameters 
 
before:date, str, int


Truncate all rows before this index value.  
after:date, str, int


Truncate all rows after this index value.  
axis:{0 or ‘index’, 1 or ‘columns’}, optional


Axis to truncate. Truncates the index (rows) by default.  
copy:bool, default is True,


Return a copy of the truncated section.    Returns 
 type of caller

The truncated Series or DataFrame.      See also  DataFrame.loc

Select a subset of a DataFrame by label.  DataFrame.iloc

Select a subset of a DataFrame by position.    Notes If the index being truncated contains only datetime values, before and after may be specified as strings instead of Timestamps. Examples 
>>> df = pd.DataFrame({'A': ['a', 'b', 'c', 'd', 'e'],
...                    'B': ['f', 'g', 'h', 'i', 'j'],
...                    'C': ['k', 'l', 'm', 'n', 'o']},
...                   index=[1, 2, 3, 4, 5])
>>> df
   A  B  C
1  a  f  k
2  b  g  l
3  c  h  m
4  d  i  n
5  e  j  o
  
>>> df.truncate(before=2, after=4)
   A  B  C
2  b  g  l
3  c  h  m
4  d  i  n
  The columns of a DataFrame can be truncated. 
>>> df.truncate(before="A", after="B", axis="columns")
   A  B
1  a  f
2  b  g
3  c  h
4  d  i
5  e  j
  For Series, only rows can be truncated. 
>>> df['A'].truncate(before=2, after=4)
2    b
3    c
4    d
Name: A, dtype: object
  The index values in truncate can be datetimes or string dates. 
>>> dates = pd.date_range('2016-01-01', '2016-02-01', freq='s')
>>> df = pd.DataFrame(index=dates, data={'A': 1})
>>> df.tail()
                     A
2016-01-31 23:59:56  1
2016-01-31 23:59:57  1
2016-01-31 23:59:58  1
2016-01-31 23:59:59  1
2016-02-01 00:00:00  1
  
>>> df.truncate(before=pd.Timestamp('2016-01-05'),
...             after=pd.Timestamp('2016-01-10')).tail()
                     A
2016-01-09 23:59:56  1
2016-01-09 23:59:57  1
2016-01-09 23:59:58  1
2016-01-09 23:59:59  1
2016-01-10 00:00:00  1
  Because the index is a DatetimeIndex containing only dates, we can specify before and after as strings. They will be coerced to Timestamps before truncation. 
>>> df.truncate('2016-01-05', '2016-01-10').tail()
                     A
2016-01-09 23:59:56  1
2016-01-09 23:59:57  1
2016-01-09 23:59:58  1
2016-01-09 23:59:59  1
2016-01-10 00:00:00  1
  Note that truncate assumes a 0 value for any unspecified time component (midnight). This differs from partial string slicing, which returns any partially matching dates. 
>>> df.loc['2016-01-05':'2016-01-10', :].tail()
                     A
2016-01-10 23:59:55  1
2016-01-10 23:59:56  1
2016-01-10 23:59:57  1
2016-01-10 23:59:58  1
2016-01-10 23:59:59  1
pandas.Series.tshift   Series.tshift(periods=1, freq=None, axis=0)[source]
 
Shift the time index, using the index’s frequency if available.  Deprecated since version 1.1.0: Use shift instead.   Parameters 
 
periods:int


Number of periods to move, can be positive or negative.  
freq:DateOffset, timedelta, or str, default None


Increment to use from the tseries module or time rule expressed as a string (e.g. ‘EOM’).  
axis:{0 or ‘index’, 1 or ‘columns’, None}, default 0


Corresponds to the axis that contains the Index.    Returns 
 
shifted:Series/DataFrame

   Notes If freq is not specified then tries to use the freq or inferred_freq attributes of the index. If neither of those attributes exist, a ValueError is thrown
pandas.Series.tz_convert   Series.tz_convert(tz, axis=0, level=None, copy=True)[source]
 
Convert tz-aware axis to target time zone.  Parameters 
 
tz:str or tzinfo object


axis:the axis to convert


level:int, str, default None


If axis is a MultiIndex, convert a specific level. Otherwise must be None.  
copy:bool, default True


Also make a copy of the underlying data.    Returns 
 {klass}

Object with time zone converted axis.    Raises 
 TypeError

If the axis is tz-naive.
pandas.Series.unique   Series.unique()[source]
 
Return unique values of Series object. Uniques are returned in order of appearance. Hash table-based unique, therefore does NOT sort.  Returns 
 ndarray or ExtensionArray

The unique values returned as a NumPy array. See Notes.      See also  unique

Top-level unique method for any 1-d array-like object.  Index.unique

Return Index with unique values from an Index object.    Notes Returns the unique values as a NumPy array. In case of an extension-array backed Series, a new ExtensionArray of that type with just the unique values is returned. This includes  
 Categorical Period Datetime with Timezone Interval Sparse IntegerNA  
 See Examples section. Examples 
>>> pd.Series([2, 1, 3, 3], name='A').unique()
array([2, 1, 3])
  
>>> pd.Series([pd.Timestamp('2016-01-01') for _ in range(3)]).unique()
array(['2016-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
  
>>> pd.Series([pd.Timestamp('2016-01-01', tz='US/Eastern')
...            for _ in range(3)]).unique()
<DatetimeArray>
['2016-01-01 00:00:00-05:00']
Length: 1, dtype: datetime64[ns, US/Eastern]
  An Categorical will return categories in the order of appearance and with the same dtype. 
>>> pd.Series(pd.Categorical(list('baabc'))).unique()
['b', 'a', 'c']
Categories (3, object): ['a', 'b', 'c']
>>> pd.Series(pd.Categorical(list('baabc'), categories=list('abc'),
...                          ordered=True)).unique()
['b', 'a', 'c']
Categories (3, object): ['a' < 'b' < 'c']
pandas.Series.unstack   Series.unstack(level=- 1, fill_value=None)[source]
 
Unstack, also known as pivot, Series with MultiIndex to produce DataFrame.  Parameters 
 
level:int, str, or list of these, default last level


Level(s) to unstack, can pass level name.  
fill_value:scalar value, default None


Value to use when replacing NaN values.    Returns 
 DataFrame

Unstacked Series.     Examples 
>>> s = pd.Series([1, 2, 3, 4],
...               index=pd.MultiIndex.from_product([['one', 'two'],
...                                                 ['a', 'b']]))
>>> s
one  a    1
     b    2
two  a    3
     b    4
dtype: int64
  
>>> s.unstack(level=-1)
     a  b
one  1  2
two  3  4
  
>>> s.unstack(level=0)
   one  two
a    1    3
b    2    4
pandas.Series.update   Series.update(other)[source]
 
Modify Series in place using values from passed Series. Uses non-NA values from passed Series to make updates. Aligns on index.  Parameters 
 
other:Series, or object coercible into Series

   Examples 
>>> s = pd.Series([1, 2, 3])
>>> s.update(pd.Series([4, 5, 6]))
>>> s
0    4
1    5
2    6
dtype: int64
  
>>> s = pd.Series(['a', 'b', 'c'])
>>> s.update(pd.Series(['d', 'e'], index=[0, 2]))
>>> s
0    d
1    b
2    e
dtype: object
  
>>> s = pd.Series([1, 2, 3])
>>> s.update(pd.Series([4, 5, 6, 7, 8]))
>>> s
0    4
1    5
2    6
dtype: int64
  If other contains NaNs the corresponding values are not updated in the original Series. 
>>> s = pd.Series([1, 2, 3])
>>> s.update(pd.Series([4, np.nan, 6]))
>>> s
0    4
1    2
2    6
dtype: int64
  other can also be a non-Series object type that is coercible into a Series 
>>> s = pd.Series([1, 2, 3])
>>> s.update([4, np.nan, 6])
>>> s
0    4
1    2
2    6
dtype: int64
  
>>> s = pd.Series([1, 2, 3])
>>> s.update({1: 9})
>>> s
0    1
1    9
2    3
dtype: int64
pandas.Series.value_counts   Series.value_counts(normalize=False, sort=True, ascending=False, bins=None, dropna=True)[source]
 
Return a Series containing counts of unique values. The resulting object will be in descending order so that the first element is the most frequently-occurring element. Excludes NA values by default.  Parameters 
 
normalize:bool, default False


If True then the object returned will contain the relative frequencies of the unique values.  
sort:bool, default True


Sort by frequencies.  
ascending:bool, default False


Sort in ascending order.  
bins:int, optional


Rather than count values, group them into half-open bins, a convenience for pd.cut, only works with numeric data.  
dropna:bool, default True


Don’t include counts of NaN.    Returns 
 Series
    See also  Series.count

Number of non-NA elements in a Series.  DataFrame.count

Number of non-NA elements in a DataFrame.  DataFrame.value_counts

Equivalent method on DataFrames.    Examples 
>>> index = pd.Index([3, 1, 2, 3, 4, np.nan])
>>> index.value_counts()
3.0    2
1.0    1
2.0    1
4.0    1
dtype: int64
  With normalize set to True, returns the relative frequency by dividing all values by the sum of values. 
>>> s = pd.Series([3, 1, 2, 3, 4, np.nan])
>>> s.value_counts(normalize=True)
3.0    0.4
1.0    0.2
2.0    0.2
4.0    0.2
dtype: float64
  bins Bins can be useful for going from a continuous variable to a categorical variable; instead of counting unique apparitions of values, divide the index in the specified number of half-open bins. 
>>> s.value_counts(bins=3)
(0.996, 2.0]    2
(2.0, 3.0]      2
(3.0, 4.0]      1
dtype: int64
  dropna With dropna set to False we can also see NaN index values. 
>>> s.value_counts(dropna=False)
3.0    2
1.0    1
2.0    1
4.0    1
NaN    1
dtype: int64
pandas.Series.values   propertySeries.values
 
Return Series as ndarray or ndarray-like depending on the dtype.  Warning We recommend using Series.array or Series.to_numpy(), depending on whether you need a reference to the underlying data or a NumPy array.   Returns 
 numpy.ndarray or ndarray-like
    See also  Series.array

Reference to the underlying data.  Series.to_numpy

A NumPy array representing the underlying data.    Examples 
>>> pd.Series([1, 2, 3]).values
array([1, 2, 3])
  
>>> pd.Series(list('aabc')).values
array(['a', 'a', 'b', 'c'], dtype=object)
  
>>> pd.Series(list('aabc')).astype('category').values
['a', 'a', 'b', 'c']
Categories (3, object): ['a', 'b', 'c']
  Timezone aware datetime data is converted to UTC: 
>>> pd.Series(pd.date_range('20130101', periods=3,
...                         tz='US/Eastern')).values
array(['2013-01-01T05:00:00.000000000',
       '2013-01-02T05:00:00.000000000',
       '2013-01-03T05:00:00.000000000'], dtype='datetime64[ns]')
pandas.Series.var   Series.var(axis=None, skipna=True, level=None, ddof=1, numeric_only=None, **kwargs)[source]
 
Return unbiased variance over requested axis. Normalized by N-1 by default. This can be changed using the ddof argument.  Parameters 
 
axis:{index (0)}


skipna:bool, default True


Exclude NA/null values. If an entire row/column is NA, the result will be NA.  
level:int or level name, default None


If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a scalar.  
ddof:int, default 1


Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.  
numeric_only:bool, default None


Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data. Not implemented for Series.    Returns 
 scalar or Series (if level specified)
   Examples 
>>> df = pd.DataFrame({'person_id': [0, 1, 2, 3],
...                   'age': [21, 25, 62, 43],
...                   'height': [1.61, 1.87, 1.49, 2.01]}
...                  ).set_index('person_id')
>>> df
           age  height
person_id
0           21    1.61
1           25    1.87
2           62    1.49
3           43    2.01
  
>>> df.var()
age       352.916667
height      0.056367
  Alternatively, ddof=0 can be set to normalize by N instead of N-1: 
>>> df.var(ddof=0)
age       264.687500
height      0.042275
pandas.Series.view   Series.view(dtype=None)[source]
 
Create a new view of the Series. This function will return a new Series with a view of the same underlying values in memory, optionally reinterpreted with a new data type. The new data type must preserve the same size in bytes as to not cause index misalignment.  Parameters 
 
dtype:data type


Data type object or one of their string representations.    Returns 
 Series

A new Series object as a view of the same data in memory.      See also  numpy.ndarray.view

Equivalent numpy function to create a new view of the same data in memory.    Notes Series are instantiated with dtype=float64 by default. While numpy.ndarray.view() will return a view with the same data type as the original array, Series.view() (without specified dtype) will try using float64 and may fail if the original data type size in bytes is not the same. Examples 
>>> s = pd.Series([-2, -1, 0, 1, 2], dtype='int8')
>>> s
0   -2
1   -1
2    0
3    1
4    2
dtype: int8
  The 8 bit signed integer representation of -1 is 0b11111111, but the same bytes represent 255 if read as an 8 bit unsigned integer: 
>>> us = s.view('uint8')
>>> us
0    254
1    255
2      0
3      1
4      2
dtype: uint8
  The views share the same underlying values: 
>>> us[0] = 128
>>> s
0   -128
1     -1
2      0
3      1
4      2
dtype: int8
pandas.Series.where   Series.where(cond, other=NoDefault.no_default, inplace=False, axis=None, level=None, errors=NoDefault.no_default, try_cast=NoDefault.no_default)[source]
 
Replace values where the condition is False.  Parameters 
 
cond:bool Series/DataFrame, array-like, or callable


Where cond is True, keep the original value. Where False, replace with corresponding value from other. If cond is callable, it is computed on the Series/DataFrame and should return boolean Series/DataFrame or array. The callable must not change input Series/DataFrame (though pandas doesn’t check it).  
other:scalar, Series/DataFrame, or callable


Entries where cond is False are replaced with corresponding value from other. If other is callable, it is computed on the Series/DataFrame and should return scalar or Series/DataFrame. The callable must not change input Series/DataFrame (though pandas doesn’t check it).  
inplace:bool, default False


Whether to perform the operation in place on the data.  
axis:int, default None


Alignment axis if needed.  
level:int, default None


Alignment level if needed.  
errors:str, {‘raise’, ‘ignore’}, default ‘raise’


Note that currently this parameter won’t affect the results and will always coerce to a suitable dtype.  ‘raise’ : allow exceptions to be raised. ‘ignore’ : suppress exceptions. On error return original object.   
try_cast:bool, default None


Try to cast the result back to the input type (if possible).  Deprecated since version 1.3.0: Manually cast back if necessary.     Returns 
 Same type as caller or None if inplace=True.
    See also  DataFrame.mask()

Return an object of same shape as self.    Notes The where method is an application of the if-then idiom. For each element in the calling DataFrame, if cond is True the element is used; otherwise the corresponding element from the DataFrame other is used. The signature for DataFrame.where() differs from numpy.where(). Roughly df1.where(m, df2) is equivalent to np.where(m, df1, df2). For further details and examples see the where documentation in indexing. Examples 
>>> s = pd.Series(range(5))
>>> s.where(s > 0)
0    NaN
1    1.0
2    2.0
3    3.0
4    4.0
dtype: float64
>>> s.mask(s > 0)
0    0.0
1    NaN
2    NaN
3    NaN
4    NaN
dtype: float64
  
>>> s.where(s > 1, 10)
0    10
1    10
2    2
3    3
4    4
dtype: int64
>>> s.mask(s > 1, 10)
0     0
1     1
2    10
3    10
4    10
dtype: int64
  
>>> df = pd.DataFrame(np.arange(10).reshape(-1, 2), columns=['A', 'B'])
>>> df
   A  B
0  0  1
1  2  3
2  4  5
3  6  7
4  8  9
>>> m = df % 3 == 0
>>> df.where(m, -df)
   A  B
0  0 -1
1 -2  3
2 -4 -5
3  6 -7
4 -8  9
>>> df.where(m, -df) == np.where(m, df, -df)
      A     B
0  True  True
1  True  True
2  True  True
3  True  True
4  True  True
>>> df.where(m, -df) == df.mask(~m, -df)
      A     B
0  True  True
1  True  True
2  True  True
3  True  True
4  True  True
pandas.Series.xs   Series.xs(key, axis=0, level=None, drop_level=True)[source]
 
Return cross-section from the Series/DataFrame. This method takes a key argument to select data at a particular level of a MultiIndex.  Parameters 
 
key:label or tuple of label


Label contained in the index, or partially in a MultiIndex.  
axis:{0 or ‘index’, 1 or ‘columns’}, default 0


Axis to retrieve cross-section on.  
level:object, defaults to first n levels (n=1 or len(key))


In case of a key partially contained in a MultiIndex, indicate which levels are used. Levels can be referred by label or position.  
drop_level:bool, default True


If False, returns object with same levels as self.    Returns 
 Series or DataFrame

Cross-section from the original Series or DataFrame corresponding to the selected index levels.      See also  DataFrame.loc

Access a group of rows and columns by label(s) or a boolean array.  DataFrame.iloc

Purely integer-location based indexing for selection by position.    Notes xs can not be used to set values. MultiIndex Slicers is a generic way to get/set values on any level or levels. It is a superset of xs functionality, see MultiIndex Slicers. Examples 
>>> d = {'num_legs': [4, 4, 2, 2],
...      'num_wings': [0, 0, 2, 2],
...      'class': ['mammal', 'mammal', 'mammal', 'bird'],
...      'animal': ['cat', 'dog', 'bat', 'penguin'],
...      'locomotion': ['walks', 'walks', 'flies', 'walks']}
>>> df = pd.DataFrame(data=d)
>>> df = df.set_index(['class', 'animal', 'locomotion'])
>>> df
                           num_legs  num_wings
class  animal  locomotion
mammal cat     walks              4          0
       dog     walks              4          0
       bat     flies              2          2
bird   penguin walks              2          2
  Get values at specified index 
>>> df.xs('mammal')
                   num_legs  num_wings
animal locomotion
cat    walks              4          0
dog    walks              4          0
bat    flies              2          2
  Get values at several indexes 
>>> df.xs(('mammal', 'dog'))
            num_legs  num_wings
locomotion
walks              4          0
  Get values at specified index and level 
>>> df.xs('cat', level=1)
                   num_legs  num_wings
class  locomotion
mammal walks              4          0
  Get values at several indexes and levels 
>>> df.xs(('bird', 'walks'),
...       level=[0, 'locomotion'])
         num_legs  num_wings
animal
penguin         2          2
  Get values at specified column and axis 
>>> df.xs('num_wings', axis=1)
class   animal   locomotion
mammal  cat      walks         0
        dog      walks         0
        bat      flies         2
bird    penguin  walks         2
Name: num_wings, dtype: int64
pandas.show_versions   pandas.show_versions(as_json=False)[source]
 
Provide useful information, important for bug reports. It comprises info about hosting operation system, pandas version, and versions of other installed relative packages.  Parameters 
 
as_json:str or bool, default False


 If False, outputs info in a human readable form to the console. If str, it will be considered as a path to a file. Info will be written to that file in JSON format. If True, outputs info in JSON format to the console.
pandas.SparseDtype   classpandas.SparseDtype(dtype=<class 'numpy.float64'>, fill_value=None)[source]
 
Dtype for data stored in SparseArray. This dtype implements the pandas ExtensionDtype interface.  Parameters 
 
dtype:str, ExtensionDtype, numpy.dtype, type, default numpy.float64


The dtype of the underlying array storing the non-fill value values.  
fill_value:scalar, optional


The scalar value not stored in the SparseArray. By default, this depends on dtype.       
dtype na_value    
float np.nan  
int 0  
bool False  
datetime64 pd.NaT  
timedelta64 pd.NaT    The default value may be overridden by specifying a fill_value.     Attributes       
None     Methods       
None