neulab/docprompting-conala huggingface dataset:
pandas.DataFrame.squeeze   DataFrame.squeeze(axis=None)[source]
 
Squeeze 1 dimensional axis objects into scalars. Series or DataFrames with a single element are squeezed to a scalar. DataFrames with a single column or a single row are squeezed to a Series. Otherwise the object is unchanged. This method is most useful when you don’t know if your object is a Series or DataFrame, but you do know it has just a single column. In that case you can safely call squeeze to ensure you have a Series.  Parameters 
 
axis:{0 or ‘index’, 1 or ‘columns’, None}, default None


A specific axis to squeeze. By default, all length-1 axes are squeezed.    Returns 
 DataFrame, Series, or scalar

The projection after squeezing axis or all the axes.      See also  Series.iloc

Integer-location based indexing for selecting scalars.  DataFrame.iloc

Integer-location based indexing for selecting Series.  Series.to_frame

Inverse of DataFrame.squeeze for a single-column DataFrame.    Examples 
>>> primes = pd.Series([2, 3, 5, 7])
  Slicing might produce a Series with a single value: 
>>> even_primes = primes[primes % 2 == 0]
>>> even_primes
0    2
dtype: int64
  
>>> even_primes.squeeze()
2
  Squeezing objects with more than one value in every axis does nothing: 
>>> odd_primes = primes[primes % 2 == 1]
>>> odd_primes
1    3
2    5
3    7
dtype: int64
  
>>> odd_primes.squeeze()
1    3
2    5
3    7
dtype: int64
  Squeezing is even more effective when used with DataFrames. 
>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['a', 'b'])
>>> df
   a  b
0  1  2
1  3  4
  Slicing a single column will produce a DataFrame with the columns having only one value: 
>>> df_a = df[['a']]
>>> df_a
   a
0  1
1  3
  So the columns can be squeezed down, resulting in a Series: 
>>> df_a.squeeze('columns')
0    1
1    3
Name: a, dtype: int64
  Slicing a single row from a single column will produce a single scalar DataFrame: 
>>> df_0a = df.loc[df.index < 1, ['a']]
>>> df_0a
   a
0  1
  Squeezing the rows produces a single scalar Series: 
>>> df_0a.squeeze('rows')
a    1
Name: 0, dtype: int64
  Squeezing all axes will project directly into a scalar: 
>>> df_0a.squeeze()
1
pandas.DataFrame.std   DataFrame.std(axis=None, skipna=True, level=None, ddof=1, numeric_only=None, **kwargs)[source]
 
Return sample standard deviation over requested axis. Normalized by N-1 by default. This can be changed using the ddof argument.  Parameters 
 
axis:{index (0), columns (1)}


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 Series.  
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 
 Series or DataFrame (if level specified)
   Notes To have the same behaviour as numpy.std, use ddof=0 (instead of the default ddof=1) 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
  The standard deviation of the columns can be found as follows: 
>>> df.std()
age       18.786076
height     0.237417
  Alternatively, ddof=0 can be set to normalize by N instead of N-1: 
>>> df.std(ddof=0)
age       16.269219
height     0.205609
pandas.DataFrame.style   propertyDataFrame.style
 
Returns a Styler object. Contains methods for building a styled HTML representation of the DataFrame.  See also  io.formats.style.Styler

Helps style a DataFrame or Series according to the data with HTML and CSS.
pandas.DataFrame.sum   DataFrame.sum(axis=None, skipna=True, level=None, numeric_only=None, min_count=0, **kwargs)[source]
 
Return the sum of the values over the requested axis. This is equivalent to the method numpy.sum.  Parameters 
 
axis:{index (0), columns (1)}


Axis for the function to be applied on.  
skipna:bool, default True


Exclude NA/null values when computing the result.  
level:int or level name, default None


If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a Series.  
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.  
min_count:int, default 0


The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.  **kwargs

Additional keyword arguments to be passed to the function.    Returns 
 Series or DataFrame (if level specified)
    See also  Series.sum

Return the sum.  Series.min

Return the minimum.  Series.max

Return the maximum.  Series.idxmin

Return the index of the minimum.  Series.idxmax

Return the index of the maximum.  DataFrame.sum

Return the sum over the requested axis.  DataFrame.min

Return the minimum over the requested axis.  DataFrame.max

Return the maximum over the requested axis.  DataFrame.idxmin

Return the index of the minimum over the requested axis.  DataFrame.idxmax

Return the index of the maximum over the requested axis.    Examples 
>>> idx = pd.MultiIndex.from_arrays([
...     ['warm', 'warm', 'cold', 'cold'],
...     ['dog', 'falcon', 'fish', 'spider']],
...     names=['blooded', 'animal'])
>>> s = pd.Series([4, 2, 0, 8], name='legs', index=idx)
>>> s
blooded  animal
warm     dog       4
         falcon    2
cold     fish      0
         spider    8
Name: legs, dtype: int64
  
>>> s.sum()
14
  By default, the sum of an empty or all-NA Series is 0. 
>>> pd.Series([], dtype="float64").sum()  # min_count=0 is the default
0.0
  This can be controlled with the min_count parameter. For example, if you’d like the sum of an empty series to be NaN, pass min_count=1. 
>>> pd.Series([], dtype="float64").sum(min_count=1)
nan
  Thanks to the skipna parameter, min_count handles all-NA and empty series identically. 
>>> pd.Series([np.nan]).sum()
0.0
  
>>> pd.Series([np.nan]).sum(min_count=1)
nan
pandas.DataFrame.swapaxes   DataFrame.swapaxes(axis1, axis2, copy=True)[source]
 
Interchange axes and swap values axes appropriately.  Returns 
 
y:same as input
pandas.DataFrame.swaplevel   DataFrame.swaplevel(i=- 2, j=- 1, axis=0)[source]
 
Swap levels i and j in a MultiIndex. Default is to swap the two innermost levels of the index.  Parameters 
 
i, j:int or str


Levels of the indices to be swapped. Can pass level name as string.  
axis:{0 or ‘index’, 1 or ‘columns’}, default 0


The axis to swap levels on. 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise.    Returns 
 DataFrame

DataFrame with levels swapped in MultiIndex.     Examples 
>>> df = pd.DataFrame(
...     {"Grade": ["A", "B", "A", "C"]},
...     index=[
...         ["Final exam", "Final exam", "Coursework", "Coursework"],
...         ["History", "Geography", "History", "Geography"],
...         ["January", "February", "March", "April"],
...     ],
... )
>>> df
                                    Grade
Final exam  History     January      A
            Geography   February     B
Coursework  History     March        A
            Geography   April        C
  In the following example, we will swap the levels of the indices. Here, we will swap the levels column-wise, but levels can be swapped row-wise in a similar manner. Note that column-wise is the default behaviour. By not supplying any arguments for i and j, we swap the last and second to last indices. 
>>> df.swaplevel()
                                    Grade
Final exam  January     History         A
            February    Geography       B
Coursework  March       History         A
            April       Geography       C
  By supplying one argument, we can choose which index to swap the last index with. We can for example swap the first index with the last one as follows. 
>>> df.swaplevel(0)
                                    Grade
January     History     Final exam      A
February    Geography   Final exam      B
March       History     Coursework      A
April       Geography   Coursework      C
  We can also define explicitly which indices we want to swap by supplying values for both i and j. Here, we for example swap the first and second indices. 
>>> df.swaplevel(0, 1)
                                    Grade
History     Final exam  January         A
Geography   Final exam  February        B
History     Coursework  March           A
Geography   Coursework  April           C
pandas.DataFrame.tail   DataFrame.tail(n=5)[source]
 
Return the last n rows. This function returns last n rows from the object based on position. It is useful for quickly verifying data, for example, after sorting or appending rows. For negative values of n, this function returns all rows except the first n rows, equivalent to df[n:].  Parameters 
 
n:int, default 5


Number of rows to select.    Returns 
 type of caller

The last n rows of the caller object.      See also  DataFrame.head

The first n rows of the caller object.    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 last 5 lines 
>>> df.tail()
   animal
4  monkey
5  parrot
6   shark
7   whale
8   zebra
  Viewing the last n lines (three in this case) 
>>> df.tail(3)
  animal
6  shark
7  whale
8  zebra
  For negative values of n 
>>> df.tail(-3)
   animal
3    lion
4  monkey
5  parrot
6   shark
7   whale
8   zebra
pandas.DataFrame.take   DataFrame.take(indices, axis=0, is_copy=None, **kwargs)[source]
 
Return the elements in the given positional indices along an axis. This means that we are not indexing according to actual values in the index attribute of the object. We are indexing according to the actual position of the element in the object.  Parameters 
 
indices:array-like


An array of ints indicating which positions to take.  
axis:{0 or ‘index’, 1 or ‘columns’, None}, default 0


The axis on which to select elements. 0 means that we are selecting rows, 1 means that we are selecting columns.  
is_copy:bool


Before pandas 1.0, is_copy=False can be specified to ensure that the return value is an actual copy. Starting with pandas 1.0, take always returns a copy, and the keyword is therefore deprecated.  Deprecated since version 1.0.0.   **kwargs

For compatibility with numpy.take(). Has no effect on the output.    Returns 
 
taken:same type as caller


An array-like containing the elements taken from the object.      See also  DataFrame.loc

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

Select a subset of a DataFrame by positions.  numpy.take

Take elements from an array along an axis.    Examples 
>>> df = pd.DataFrame([('falcon', 'bird', 389.0),
...                    ('parrot', 'bird', 24.0),
...                    ('lion', 'mammal', 80.5),
...                    ('monkey', 'mammal', np.nan)],
...                   columns=['name', 'class', 'max_speed'],
...                   index=[0, 2, 3, 1])
>>> df
     name   class  max_speed
0  falcon    bird      389.0
2  parrot    bird       24.0
3    lion  mammal       80.5
1  monkey  mammal        NaN
  Take elements at positions 0 and 3 along the axis 0 (default). Note how the actual indices selected (0 and 1) do not correspond to our selected indices 0 and 3. That’s because we are selecting the 0th and 3rd rows, not rows whose indices equal 0 and 3. 
>>> df.take([0, 3])
     name   class  max_speed
0  falcon    bird      389.0
1  monkey  mammal        NaN
  Take elements at indices 1 and 2 along the axis 1 (column selection). 
>>> df.take([1, 2], axis=1)
    class  max_speed
0    bird      389.0
2    bird       24.0
3  mammal       80.5
1  mammal        NaN
  We may take elements using negative integers for positive indices, starting from the end of the object, just like with Python lists. 
>>> df.take([-1, -2])
     name   class  max_speed
1  monkey  mammal        NaN
3    lion  mammal       80.5
pandas.DataFrame.to_clipboard   DataFrame.to_clipboard(excel=True, sep=None, **kwargs)[source]
 
Copy object to the system clipboard. Write a text representation of object to the system clipboard. This can be pasted into Excel, for example.  Parameters 
 
excel:bool, default True


Produce output in a csv format for easy pasting into excel.  True, use the provided separator for csv pasting. False, write a string representation of the object to the clipboard.   
sep:str, default '\t'


Field delimiter.  **kwargs

These parameters will be passed to DataFrame.to_csv.      See also  DataFrame.to_csv

Write a DataFrame to a comma-separated values (csv) file.  read_clipboard

Read text from clipboard and pass to read_csv.    Notes Requirements for your platform.  
 Linux : xclip, or xsel (with PyQt4 modules) Windows : none macOS : none  
 Examples Copy the contents of a DataFrame to the clipboard. 
>>> df = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=['A', 'B', 'C'])
  
>>> df.to_clipboard(sep=',')  
... # Wrote the following to the system clipboard:
... # ,A,B,C
... # 0,1,2,3
... # 1,4,5,6
  We can omit the index by passing the keyword index and setting it to false. 
>>> df.to_clipboard(sep=',', index=False)  
... # Wrote the following to the system clipboard:
... # A,B,C
... # 1,2,3
... # 4,5,6
pandas.DataFrame.to_dict   DataFrame.to_dict(orient='dict', into=<class 'dict'>)[source]
 
Convert the DataFrame to a dictionary. The type of the key-value pairs can be customized with the parameters (see below).  Parameters 
 
orient:str {‘dict’, ‘list’, ‘series’, ‘split’, ‘records’, ‘index’}


Determines the type of the values of the dictionary.  ‘dict’ (default) : dict like {column -> {index -> value}} ‘list’ : dict like {column -> [values]} ‘series’ : dict like {column -> Series(values)} ‘split’ : dict like {‘index’ -> [index], ‘columns’ -> [columns], ‘data’ -> [values]} ‘tight’ : dict like {‘index’ -> [index], ‘columns’ -> [columns], ‘data’ -> [values], ‘index_names’ -> [index.names], ‘column_names’ -> [column.names]} ‘records’ : list like [{column -> value}, … , {column -> value}] ‘index’ : dict like {index -> {column -> value}}  Abbreviations are allowed. s indicates series and sp indicates split.  New in version 1.4.0: ‘tight’ as an allowed value for the orient argument   
into:class, default dict


The collections.abc.Mapping subclass used for all Mappings in the return value. Can be the actual class or an empty instance of the mapping type you want. If you want a collections.defaultdict, you must pass it initialized.    Returns 
 dict, list or collections.abc.Mapping

Return a collections.abc.Mapping object representing the DataFrame. The resulting transformation depends on the orient parameter.      See also  DataFrame.from_dict

Create a DataFrame from a dictionary.  DataFrame.to_json

Convert a DataFrame to JSON format.    Examples 
>>> df = pd.DataFrame({'col1': [1, 2],
...                    'col2': [0.5, 0.75]},
...                   index=['row1', 'row2'])
>>> df
      col1  col2
row1     1  0.50
row2     2  0.75
>>> df.to_dict()
{'col1': {'row1': 1, 'row2': 2}, 'col2': {'row1': 0.5, 'row2': 0.75}}
  You can specify the return orientation. 
>>> df.to_dict('series')
{'col1': row1    1
         row2    2
Name: col1, dtype: int64,
'col2': row1    0.50
        row2    0.75
Name: col2, dtype: float64}
  
>>> df.to_dict('split')
{'index': ['row1', 'row2'], 'columns': ['col1', 'col2'],
 'data': [[1, 0.5], [2, 0.75]]}
  
>>> df.to_dict('records')
[{'col1': 1, 'col2': 0.5}, {'col1': 2, 'col2': 0.75}]
  
>>> df.to_dict('index')
{'row1': {'col1': 1, 'col2': 0.5}, 'row2': {'col1': 2, 'col2': 0.75}}
  
>>> df.to_dict('tight')
{'index': ['row1', 'row2'], 'columns': ['col1', 'col2'],
 'data': [[1, 0.5], [2, 0.75]], 'index_names': [None], 'column_names': [None]}
  You can also specify the mapping type. 
>>> from collections import OrderedDict, defaultdict
>>> df.to_dict(into=OrderedDict)
OrderedDict([('col1', OrderedDict([('row1', 1), ('row2', 2)])),
             ('col2', OrderedDict([('row1', 0.5), ('row2', 0.75)]))])
  If you want a defaultdict, you need to initialize it: 
>>> dd = defaultdict(list)
>>> df.to_dict('records', into=dd)
[defaultdict(<class 'list'>, {'col1': 1, 'col2': 0.5}),
 defaultdict(<class 'list'>, {'col1': 2, 'col2': 0.75})]
pandas.DataFrame.to_feather   DataFrame.to_feather(path, **kwargs)[source]
 
Write a DataFrame to the binary Feather format.  Parameters 
 
path:str, path object, file-like object


String, path object (implementing os.PathLike[str]), or file-like object implementing a binary write() function. If a string or a path, it will be used as Root Directory path when writing a partitioned dataset.  **kwargs :

Additional keywords passed to pyarrow.feather.write_feather(). Starting with pyarrow 0.17, this includes the compression, compression_level, chunksize and version keywords.  New in version 1.1.0.      Notes This function writes the dataframe as a feather file. Requires a default index. For saving the DataFrame with your custom index use a method that supports custom indices e.g. to_parquet.
pandas.DataFrame.to_gbq   DataFrame.to_gbq(destination_table, project_id=None, chunksize=None, reauth=False, if_exists='fail', auth_local_webserver=False, table_schema=None, location=None, progress_bar=True, credentials=None)[source]
 
Write a DataFrame to a Google BigQuery table. This function requires the pandas-gbq package. See the How to authenticate with Google BigQuery guide for authentication instructions.  Parameters 
 
destination_table:str


Name of table to be written, in the form dataset.tablename.  
project_id:str, optional


Google BigQuery Account project ID. Optional when available from the environment.  
chunksize:int, optional


Number of rows to be inserted in each chunk from the dataframe. Set to None to load the whole dataframe at once.  
reauth:bool, default False


Force Google BigQuery to re-authenticate the user. This is useful if multiple accounts are used.  
if_exists:str, default ‘fail’


Behavior when the destination table exists. Value can be one of:  'fail'

If table exists raise pandas_gbq.gbq.TableCreationError.  'replace'

If table exists, drop it, recreate it, and insert data.  'append'

If table exists, insert data. Create if does not exist.    
auth_local_webserver:bool, default False


Use the local webserver flow instead of the console flow when getting user credentials. New in version 0.2.0 of pandas-gbq.  
table_schema:list of dicts, optional


List of BigQuery table fields to which according DataFrame columns conform to, e.g. [{'name': 'col1', 'type':
'STRING'},...]. If schema is not provided, it will be generated according to dtypes of DataFrame columns. See BigQuery API documentation on available names of a field. New in version 0.3.1 of pandas-gbq.  
location:str, optional


Location where the load job should run. See the BigQuery locations documentation for a list of available locations. The location must match that of the target dataset. New in version 0.5.0 of pandas-gbq.  
progress_bar:bool, default True


Use the library tqdm to show the progress bar for the upload, chunk by chunk. New in version 0.5.0 of pandas-gbq.  
credentials:google.auth.credentials.Credentials, optional


Credentials for accessing Google APIs. Use this parameter to override default credentials, such as to use Compute Engine google.auth.compute_engine.Credentials or Service Account google.oauth2.service_account.Credentials directly. New in version 0.8.0 of pandas-gbq.      See also  pandas_gbq.to_gbq

This function in the pandas-gbq library.  read_gbq

Read a DataFrame from Google BigQuery.
pandas.DataFrame.to_markdown   DataFrame.to_markdown(buf=None, mode='wt', index=True, storage_options=None, **kwargs)[source]
 
Print DataFrame in Markdown-friendly format.  New in version 1.0.0.   Parameters 
 
buf:str, Path or StringIO-like, optional, default None


Buffer to write to. If None, the output is returned as a string.  
mode:str, optional


Mode in which file is opened, “wt” by default.  
index:bool, optional, default True


Add index (row) labels.  New in version 1.1.0.   
storage_options:dict, optional


Extra options that make sense for a particular storage connection, e.g. host, port, username, password, etc. For HTTP(S) URLs the key-value pairs are forwarded to urllib as header options. For other URLs (e.g. starting with “s3://”, and “gcs://”) the key-value pairs are forwarded to fsspec. Please see fsspec and urllib for more details.  New in version 1.2.0.   **kwargs

These parameters will be passed to tabulate.    Returns 
 str

DataFrame in Markdown-friendly format.     Notes Requires the tabulate package. Examples 
>>> df = pd.DataFrame(
...     data={"animal_1": ["elk", "pig"], "animal_2": ["dog", "quetzal"]}
... )
>>> print(df.to_markdown())
|    | animal_1   | animal_2   |
|---:|:-----------|:-----------|
|  0 | elk        | dog        |
|  1 | pig        | quetzal    |
  Output markdown with a tabulate option. 
>>> print(df.to_markdown(tablefmt="grid"))
+----+------------+------------+
|    | animal_1   | animal_2   |
+====+============+============+
|  0 | elk        | dog        |
+----+------------+------------+
|  1 | pig        | quetzal    |
+----+------------+------------+
pandas.DataFrame.to_numpy   DataFrame.to_numpy(dtype=None, copy=False, na_value=NoDefault.no_default)[source]
 
Convert the DataFrame to a NumPy array. By default, the dtype of the returned array will be the common NumPy dtype of all types in the DataFrame. For example, if the dtypes are float16 and float32, the results dtype will be float32. This may require copying data and coercing values, which may be expensive.  Parameters 
 
dtype:str or numpy.dtype, optional


The dtype to pass to numpy.asarray().  
copy:bool, default False


Whether to ensure that the returned value is not a view on another array. Note that copy=False does not ensure that to_numpy() is no-copy. Rather, copy=True ensure that a copy is made, even if not strictly necessary.  
na_value:Any, optional


The value to use for missing values. The default value depends on dtype and the dtypes of the DataFrame columns.  New in version 1.1.0.     Returns 
 numpy.ndarray
    See also  Series.to_numpy

Similar method for Series.    Examples 
>>> pd.DataFrame({"A": [1, 2], "B": [3, 4]}).to_numpy()
array([[1, 3],
       [2, 4]])
  With heterogeneous data, the lowest common type will have to be used. 
>>> df = pd.DataFrame({"A": [1, 2], "B": [3.0, 4.5]})
>>> df.to_numpy()
array([[1. , 3. ],
       [2. , 4.5]])
  For a mix of numeric and non-numeric types, the output array will have object dtype. 
>>> df['C'] = pd.date_range('2000', periods=2)
>>> df.to_numpy()
array([[1, 3.0, Timestamp('2000-01-01 00:00:00')],
       [2, 4.5, Timestamp('2000-01-02 00:00:00')]], dtype=object)