neulab/docprompting-conala huggingface dataset:
pandas.DataFrame.filter   DataFrame.filter(items=None, like=None, regex=None, axis=None)[source]
 
Subset the dataframe rows or columns according to the specified index labels. Note that this routine does not filter a dataframe on its contents. The filter is applied to the labels of the index.  Parameters 
 
items:list-like


Keep labels from axis which are in items.  
like:str


Keep labels from axis for which “like in label == True”.  
regex:str (regular expression)


Keep labels from axis for which re.search(regex, label) == True.  
axis:{0 or ‘index’, 1 or ‘columns’, None}, default None


The axis to filter on, expressed either as an index (int) or axis name (str). By default this is the info axis, ‘index’ for Series, ‘columns’ for DataFrame.    Returns 
 same type as input object
    See also  DataFrame.loc

Access a group of rows and columns by label(s) or a boolean array.    Notes The items, like, and regex parameters are enforced to be mutually exclusive. axis defaults to the info axis that is used when indexing with []. Examples 
>>> df = pd.DataFrame(np.array(([1, 2, 3], [4, 5, 6])),
...                   index=['mouse', 'rabbit'],
...                   columns=['one', 'two', 'three'])
>>> df
        one  two  three
mouse     1    2      3
rabbit    4    5      6
  
>>> # select columns by name
>>> df.filter(items=['one', 'three'])
         one  three
mouse     1      3
rabbit    4      6
  
>>> # select columns by regular expression
>>> df.filter(regex='e$', axis=1)
         one  three
mouse     1      3
rabbit    4      6
  
>>> # select rows containing 'bbi'
>>> df.filter(like='bbi', axis=0)
         one  two  three
rabbit    4    5      6
pandas.DataFrame.first   DataFrame.first(offset)[source]
 
Select initial periods of time series data based on a date offset. When having a DataFrame with dates as index, this function can select the first few rows based on a date offset.  Parameters 
 
offset:str, DateOffset or dateutil.relativedelta


The offset length of the data that will be selected. For instance, ‘1M’ will display all the rows having their index within the first month.    Returns 
 Series or DataFrame

A subset of the caller.    Raises 
 TypeError

If the index is not a DatetimeIndex      See also  last

Select final periods of time series based on a date offset.  at_time

Select values at a particular time of the day.  between_time

Select values between particular times of the day.    Examples 
>>> i = pd.date_range('2018-04-09', periods=4, freq='2D')
>>> ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i)
>>> ts
            A
2018-04-09  1
2018-04-11  2
2018-04-13  3
2018-04-15  4
  Get the rows for the first 3 days: 
>>> ts.first('3D')
            A
2018-04-09  1
2018-04-11  2
  Notice the data for 3 first calendar days were returned, not the first 3 days observed in the dataset, and therefore data for 2018-04-13 was not returned.
pandas.DataFrame.first_valid_index   DataFrame.first_valid_index()[source]
 
Return index for first non-NA value or None, if no NA value is found.  Returns 
 
scalar:type of index

   Notes If all elements are non-NA/null, returns None. Also returns None for empty Series/DataFrame.
pandas.DataFrame.flags   propertyDataFrame.flags
 
Get the properties associated with this pandas object. The available flags are  Flags.allows_duplicate_labels   See also  Flags

Flags that apply to pandas objects.  DataFrame.attrs

Global metadata applying to this dataset.    Notes “Flags” differ from “metadata”. Flags reflect properties of the pandas object (the Series or DataFrame). Metadata refer to properties of the dataset, and should be stored in DataFrame.attrs. Examples 
>>> df = pd.DataFrame({"A": [1, 2]})
>>> df.flags
<Flags(allows_duplicate_labels=True)>
  Flags can be get or set using . 
>>> df.flags.allows_duplicate_labels
True
>>> df.flags.allows_duplicate_labels = False
  Or by slicing with a key 
>>> df.flags["allows_duplicate_labels"]
False
>>> df.flags["allows_duplicate_labels"] = True
pandas.DataFrame.from_dict   classmethodDataFrame.from_dict(data, orient='columns', dtype=None, columns=None)[source]
 
Construct DataFrame from dict of array-like or dicts. Creates DataFrame object from dictionary by columns or by index allowing dtype specification.  Parameters 
 
data:dict


Of the form {field : array-like} or {field : dict}.  
orient:{‘columns’, ‘index’, ‘tight’}, default ‘columns’


The “orientation” of the data. If the keys of the passed dict should be the columns of the resulting DataFrame, pass ‘columns’ (default). Otherwise if the keys should be rows, pass ‘index’. If ‘tight’, assume a dict with keys [‘index’, ‘columns’, ‘data’, ‘index_names’, ‘column_names’].  New in version 1.4.0: ‘tight’ as an allowed value for the orient argument   
dtype:dtype, default None


Data type to force, otherwise infer.  
columns:list, default None


Column labels to use when orient='index'. Raises a ValueError if used with orient='columns' or orient='tight'.    Returns 
 DataFrame
    See also  DataFrame.from_records

DataFrame from structured ndarray, sequence of tuples or dicts, or DataFrame.  DataFrame

DataFrame object creation using constructor.  DataFrame.to_dict

Convert the DataFrame to a dictionary.    Examples By default the keys of the dict become the DataFrame columns: 
>>> data = {'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
>>> pd.DataFrame.from_dict(data)
   col_1 col_2
0      3     a
1      2     b
2      1     c
3      0     d
  Specify orient='index' to create the DataFrame using dictionary keys as rows: 
>>> data = {'row_1': [3, 2, 1, 0], 'row_2': ['a', 'b', 'c', 'd']}
>>> pd.DataFrame.from_dict(data, orient='index')
       0  1  2  3
row_1  3  2  1  0
row_2  a  b  c  d
  When using the ‘index’ orientation, the column names can be specified manually: 
>>> pd.DataFrame.from_dict(data, orient='index',
...                        columns=['A', 'B', 'C', 'D'])
       A  B  C  D
row_1  3  2  1  0
row_2  a  b  c  d
  Specify orient='tight' to create the DataFrame using a ‘tight’ format: 
>>> data = {'index': [('a', 'b'), ('a', 'c')],
...         'columns': [('x', 1), ('y', 2)],
...         'data': [[1, 3], [2, 4]],
...         'index_names': ['n1', 'n2'],
...         'column_names': ['z1', 'z2']}
>>> pd.DataFrame.from_dict(data, orient='tight')
z1     x  y
z2     1  2
n1 n2
a  b   1  3
   c   2  4
pandas.DataFrame.from_records   classmethodDataFrame.from_records(data, index=None, exclude=None, columns=None, coerce_float=False, nrows=None)[source]
 
Convert structured or record ndarray to DataFrame. Creates a DataFrame object from a structured ndarray, sequence of tuples or dicts, or DataFrame.  Parameters 
 
data:structured ndarray, sequence of tuples or dicts, or DataFrame


Structured input data.  
index:str, list of fields, array-like


Field of array to use as the index, alternately a specific set of input labels to use.  
exclude:sequence, default None


Columns or fields to exclude.  
columns:sequence, default None


Column names to use. If the passed data do not have names associated with them, this argument provides names for the columns. Otherwise this argument indicates the order of the columns in the result (any names not found in the data will become all-NA columns).  
coerce_float:bool, default False


Attempt to convert values of non-string, non-numeric objects (like decimal.Decimal) to floating point, useful for SQL result sets.  
nrows:int, default None


Number of rows to read if data is an iterator.    Returns 
 DataFrame
    See also  DataFrame.from_dict

DataFrame from dict of array-like or dicts.  DataFrame

DataFrame object creation using constructor.    Examples Data can be provided as a structured ndarray: 
>>> data = np.array([(3, 'a'), (2, 'b'), (1, 'c'), (0, 'd')],
...                 dtype=[('col_1', 'i4'), ('col_2', 'U1')])
>>> pd.DataFrame.from_records(data)
   col_1 col_2
0      3     a
1      2     b
2      1     c
3      0     d
  Data can be provided as a list of dicts: 
>>> data = [{'col_1': 3, 'col_2': 'a'},
...         {'col_1': 2, 'col_2': 'b'},
...         {'col_1': 1, 'col_2': 'c'},
...         {'col_1': 0, 'col_2': 'd'}]
>>> pd.DataFrame.from_records(data)
   col_1 col_2
0      3     a
1      2     b
2      1     c
3      0     d
  Data can be provided as a list of tuples with corresponding columns: 
>>> data = [(3, 'a'), (2, 'b'), (1, 'c'), (0, 'd')]
>>> pd.DataFrame.from_records(data, columns=['col_1', 'col_2'])
   col_1 col_2
0      3     a
1      2     b
2      1     c
3      0     d
pandas.DataFrame.get   DataFrame.get(key, default=None)[source]
 
Get item from object for given key (ex: DataFrame column). Returns default value if not found.  Parameters 
 
key:object

  Returns 
 
value:same type as items contained in object

   Examples 
>>> df = pd.DataFrame(
...     [
...         [24.3, 75.7, "high"],
...         [31, 87.8, "high"],
...         [22, 71.6, "medium"],
...         [35, 95, "medium"],
...     ],
...     columns=["temp_celsius", "temp_fahrenheit", "windspeed"],
...     index=pd.date_range(start="2014-02-12", end="2014-02-15", freq="D"),
... )
  
>>> df
            temp_celsius  temp_fahrenheit windspeed
2014-02-12          24.3             75.7      high
2014-02-13          31.0             87.8      high
2014-02-14          22.0             71.6    medium
2014-02-15          35.0             95.0    medium
  
>>> df.get(["temp_celsius", "windspeed"])
            temp_celsius windspeed
2014-02-12          24.3      high
2014-02-13          31.0      high
2014-02-14          22.0    medium
2014-02-15          35.0    medium
  If the key isn’t found, the default value will be used. 
>>> df.get(["temp_celsius", "temp_kelvin"], default="default_value")
'default_value'
pandas.DataFrame.head   DataFrame.head(n=5)[source]
 
Return the first n rows. This function returns the first n rows for the object based on position. It is useful for quickly testing if your object has the right type of data in it. For negative values of n, this function returns all rows except the last n rows, equivalent to df[:-n].  Parameters 
 
n:int, default 5


Number of rows to select.    Returns 
 same type as caller

The first n rows of the caller object.      See also  DataFrame.tail

Returns the last n rows.    Examples 
>>> df = pd.DataFrame({'animal': ['alligator', 'bee', 'falcon', 'lion',
...                    'monkey', 'parrot', 'shark', 'whale', 'zebra']})
>>> df
      animal
0  alligator
1        bee
2     falcon
3       lion
4     monkey
5     parrot
6      shark
7      whale
8      zebra
  Viewing the first 5 lines 
>>> df.head()
      animal
0  alligator
1        bee
2     falcon
3       lion
4     monkey
  Viewing the first n lines (three in this case) 
>>> df.head(3)
      animal
0  alligator
1        bee
2     falcon
  For negative values of n 
>>> df.head(-3)
      animal
0  alligator
1        bee
2     falcon
3       lion
4     monkey
5     parrot
pandas.DataFrame.hist   DataFrame.hist(column=None, by=None, grid=True, xlabelsize=None, xrot=None, ylabelsize=None, yrot=None, ax=None, sharex=False, sharey=False, figsize=None, layout=None, bins=10, backend=None, legend=False, **kwargs)[source]
 
Make a histogram of the DataFrame’s columns. A histogram is a representation of the distribution of data. This function calls matplotlib.pyplot.hist(), on each series in the DataFrame, resulting in one histogram per column.  Parameters 
 
data:DataFrame


The pandas object holding the data.  
column:str or sequence, optional


If passed, will be used to limit data to a subset of columns.  
by:object, optional


If passed, then used to form histograms for separate groups.  
grid:bool, default True


Whether to show axis grid lines.  
xlabelsize:int, default None


If specified changes the x-axis label size.  
xrot:float, default None


Rotation of x axis labels. For example, a value of 90 displays the x labels rotated 90 degrees clockwise.  
ylabelsize:int, default None


If specified changes the y-axis label size.  
yrot:float, default None


Rotation of y axis labels. For example, a value of 90 displays the y labels rotated 90 degrees clockwise.  
ax:Matplotlib axes object, default None


The axes to plot the histogram on.  
sharex:bool, default True if ax is None else False


In case subplots=True, share x axis and set some x axis labels to invisible; defaults to True if ax is None otherwise False if an ax is passed in. Note that passing in both an ax and sharex=True will alter all x axis labels for all subplots in a figure.  
sharey:bool, default False


In case subplots=True, share y axis and set some y axis labels to invisible.  
figsize:tuple, optional


The size in inches of the figure to create. Uses the value in matplotlib.rcParams by default.  
layout:tuple, optional


Tuple of (rows, columns) for the layout of the histograms.  
bins:int or sequence, default 10


Number of histogram bins to be used. If an integer is given, bins + 1 bin edges are calculated and returned. If bins is a sequence, gives bin edges, including left edge of first bin and right edge of last bin. In this case, bins is returned unmodified.  
backend:str, default None


Backend to use instead of the backend specified in the option plotting.backend. For instance, ‘matplotlib’. Alternatively, to specify the plotting.backend for the whole session, set pd.options.plotting.backend.  New in version 1.0.0.   
legend:bool, default False


Whether to show the legend.  New in version 1.1.0.   **kwargs

All other plotting keyword arguments to be passed to matplotlib.pyplot.hist().    Returns 
 matplotlib.AxesSubplot or numpy.ndarray of them
    See also  matplotlib.pyplot.hist

Plot a histogram using matplotlib.    Examples This example draws a histogram based on the length and width of some animals, displayed in three bins 
>>> df = pd.DataFrame({
...     'length': [1.5, 0.5, 1.2, 0.9, 3],
...     'width': [0.7, 0.2, 0.15, 0.2, 1.1]
...     }, index=['pig', 'rabbit', 'duck', 'chicken', 'horse'])
>>> hist = df.hist(bins=3)
pandas.DataFrame.iat   propertyDataFrame.iat
 
Access a single value for a row/column pair by integer position. Similar to iloc, in that both provide integer-based lookups. Use iat if you only need to get or set a single value in a DataFrame or Series.  Raises 
 IndexError

When integer position is out of bounds.      See also  DataFrame.at

Access a single value for a row/column label pair.  DataFrame.loc

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

Access a group of rows and columns by integer position(s).    Examples 
>>> df = pd.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]],
...                   columns=['A', 'B', 'C'])
>>> df
    A   B   C
0   0   2   3
1   0   4   1
2  10  20  30
  Get value at specified row/column pair 
>>> df.iat[1, 2]
1
  Set value at specified row/column pair 
>>> df.iat[1, 2] = 10
>>> df.iat[1, 2]
10
  Get value within a series 
>>> df.loc[0].iat[1]
2
pandas.DataFrame.idxmax   DataFrame.idxmax(axis=0, skipna=True)[source]
 
Return index of first occurrence of maximum over requested axis. NA/null values are excluded.  Parameters 
 
axis:{0 or ‘index’, 1 or ‘columns’}, default 0


The axis to use. 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise.  
skipna:bool, default True


Exclude NA/null values. If an entire row/column is NA, the result will be NA.    Returns 
 Series

Indexes of maxima along the specified axis.    Raises 
 ValueError

 If the row/column is empty       See also  Series.idxmax

Return index of the maximum element.    Notes This method is the DataFrame version of ndarray.argmax. Examples Consider a dataset containing food consumption in Argentina. 
>>> df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48],
...                    'co2_emissions': [37.2, 19.66, 1712]},
...                    index=['Pork', 'Wheat Products', 'Beef'])
  
>>> df
                consumption  co2_emissions
Pork                  10.51         37.20
Wheat Products       103.11         19.66
Beef                  55.48       1712.00
  By default, it returns the index for the maximum value in each column. 
>>> df.idxmax()
consumption     Wheat Products
co2_emissions             Beef
dtype: object
  To return the index for the maximum value in each row, use axis="columns". 
>>> df.idxmax(axis="columns")
Pork              co2_emissions
Wheat Products     consumption
Beef              co2_emissions
dtype: object
pandas.DataFrame.idxmin   DataFrame.idxmin(axis=0, skipna=True)[source]
 
Return index of first occurrence of minimum over requested axis. NA/null values are excluded.  Parameters 
 
axis:{0 or ‘index’, 1 or ‘columns’}, default 0


The axis to use. 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise.  
skipna:bool, default True


Exclude NA/null values. If an entire row/column is NA, the result will be NA.    Returns 
 Series

Indexes of minima along the specified axis.    Raises 
 ValueError

 If the row/column is empty       See also  Series.idxmin

Return index of the minimum element.    Notes This method is the DataFrame version of ndarray.argmin. Examples Consider a dataset containing food consumption in Argentina. 
>>> df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48],
...                    'co2_emissions': [37.2, 19.66, 1712]},
...                    index=['Pork', 'Wheat Products', 'Beef'])
  
>>> df
                consumption  co2_emissions
Pork                  10.51         37.20
Wheat Products       103.11         19.66
Beef                  55.48       1712.00
  By default, it returns the index for the minimum value in each column. 
>>> df.idxmin()
consumption                Pork
co2_emissions    Wheat Products
dtype: object
  To return the index for the minimum value in each row, use axis="columns". 
>>> df.idxmin(axis="columns")
Pork                consumption
Wheat Products    co2_emissions
Beef                consumption
dtype: object
pandas.DataFrame.iloc   propertyDataFrame.iloc
 
Purely integer-location based indexing for selection by position. .iloc[] is primarily integer position based (from 0 to length-1 of the axis), but may also be used with a boolean array. Allowed inputs are:  An integer, e.g. 5. A list or array of integers, e.g. [4, 3, 0]. A slice object with ints, e.g. 1:7. A boolean array. A callable function with one argument (the calling Series or DataFrame) and that returns valid output for indexing (one of the above). This is useful in method chains, when you don’t have a reference to the calling object, but would like to base your selection on some value.  .iloc will raise IndexError if a requested indexer is out-of-bounds, except slice indexers which allow out-of-bounds indexing (this conforms with python/numpy slice semantics). See more at Selection by Position.  See also  DataFrame.iat

Fast integer location scalar accessor.  DataFrame.loc

Purely label-location based indexer for selection by label.  Series.iloc

Purely integer-location based indexing for selection by position.    Examples 
>>> mydict = [{'a': 1, 'b': 2, 'c': 3, 'd': 4},
...           {'a': 100, 'b': 200, 'c': 300, 'd': 400},
...           {'a': 1000, 'b': 2000, 'c': 3000, 'd': 4000 }]
>>> df = pd.DataFrame(mydict)
>>> df
      a     b     c     d
0     1     2     3     4
1   100   200   300   400
2  1000  2000  3000  4000
  Indexing just the rows With a scalar integer. 
>>> type(df.iloc[0])
<class 'pandas.core.series.Series'>
>>> df.iloc[0]
a    1
b    2
c    3
d    4
Name: 0, dtype: int64
  With a list of integers. 
>>> df.iloc[[0]]
   a  b  c  d
0  1  2  3  4
>>> type(df.iloc[[0]])
<class 'pandas.core.frame.DataFrame'>
  
>>> df.iloc[[0, 1]]
     a    b    c    d
0    1    2    3    4
1  100  200  300  400
  With a slice object. 
>>> df.iloc[:3]
      a     b     c     d
0     1     2     3     4
1   100   200   300   400
2  1000  2000  3000  4000
  With a boolean mask the same length as the index. 
>>> df.iloc[[True, False, True]]
      a     b     c     d
0     1     2     3     4
2  1000  2000  3000  4000
  With a callable, useful in method chains. The x passed to the lambda is the DataFrame being sliced. This selects the rows whose index label even. 
>>> df.iloc[lambda x: x.index % 2 == 0]
      a     b     c     d
0     1     2     3     4
2  1000  2000  3000  4000
  Indexing both axes You can mix the indexer types for the index and columns. Use : to select the entire axis. With scalar integers. 
>>> df.iloc[0, 1]
2
  With lists of integers. 
>>> df.iloc[[0, 2], [1, 3]]
      b     d
0     2     4
2  2000  4000
  With slice objects. 
>>> df.iloc[1:3, 0:3]
      a     b     c
1   100   200   300
2  1000  2000  3000
  With a boolean array whose length matches the columns. 
>>> df.iloc[:, [True, False, True, False]]
      a     c
0     1     3
1   100   300
2  1000  3000
  With a callable function that expects the Series or DataFrame. 
>>> df.iloc[:, lambda df: [0, 2]]
      a     c
0     1     3
1   100   300
2  1000  3000
pandas.DataFrame.index   DataFrame.index
 
The index (row labels) of the DataFrame.
pandas.DataFrame.infer_objects   DataFrame.infer_objects()[source]
 
Attempt to infer better dtypes for object columns. Attempts soft conversion of object-dtyped columns, leaving non-object and unconvertible columns unchanged. The inference rules are the same as during normal Series/DataFrame construction.  Returns 
 
converted:same type as input object

    See also  to_datetime

Convert argument to datetime.  to_timedelta

Convert argument to timedelta.  to_numeric

Convert argument to numeric type.  convert_dtypes

Convert argument to best possible dtype.    Examples 
>>> df = pd.DataFrame({"A": ["a", 1, 2, 3]})
>>> df = df.iloc[1:]
>>> df
   A
1  1
2  2
3  3
  
>>> df.dtypes
A    object
dtype: object
  
>>> df.infer_objects().dtypes
A    int64
dtype: object
pandas.DataFrame.insert   DataFrame.insert(loc, column, value, allow_duplicates=False)[source]
 
Insert column into DataFrame at specified location. Raises a ValueError if column is already contained in the DataFrame, unless allow_duplicates is set to True.  Parameters 
 
loc:int


Insertion index. Must verify 0 <= loc <= len(columns).  
column:str, number, or hashable object


Label of the inserted column.  
value:Scalar, Series, or array-like


allow_duplicates:bool, optional default False

    See also  Index.insert

Insert new item by index.    Examples 
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
>>> df
   col1  col2
0     1     3
1     2     4
>>> df.insert(1, "newcol", [99, 99])
>>> df
   col1  newcol  col2
0     1      99     3
1     2      99     4
>>> df.insert(0, "col1", [100, 100], allow_duplicates=True)
>>> df
   col1  col1  newcol  col2
0   100     1      99     3
1   100     2      99     4
  Notice that pandas uses index alignment in case of value from type Series: 
>>> df.insert(0, "col0", pd.Series([5, 6], index=[1, 2]))
>>> df
   col0  col1  col1  newcol  col2
0   NaN   100     1      99     3
1   5.0   100     2      99     4