Getting Dataframe Metadata

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 719742

    Comments posted to this topic are about the item Getting Dataframe Metadata

  • George Vobr

    SSCrazy Eights

    Points: 9195

    I'm sorry, but your explanation is incorrect., to which you refer, is a numpy-specific help function that does not give such an output about the data frame that is in your explanation. This informations are given by the Pandas DataFrame info() function.

    Here is a simple example:

    import pandas as pd
    data = [['Alex',10],['Bob',12],['Clarke',13]]
    df = pd.DataFrame(data,columns=['Name','Age'])
    print df
    #Import numpy for (df)
    import numpy as np
    print 'Output from'
    print'--------------------------------------------------------------------' = df)

    Name Age
    0 Alex 10
    1 Bob 12
    2 Clarke 13
    <class 'pandas.core.frame.DataFrame'>
    RangeIndex: 3 entries, 0 to 2
    Data columns (total 2 columns):
    Name 3 non-null object
    Age 3 non-null int64
    dtypes: int64(1), object(1)
    memory usage: 120.0+ bytes
    Output from
    Two-dimensional size-mutable, potentially heterogeneous tabular data
    structure with labeled axes (rows and columns). Arithmetic operations
    align on both row and column labels. Can be thought of as a dict-like
    container for Series objects. The primary pandas data structure

    data : numpy ndarray (structured or homogeneous), dict, or DataFrame
    Dict can contain Series, arrays, constants, or list-like objects
    index : Index or array-like
    Index to use for resulting frame. Will default to np.arange(n) if
    no indexing information part of input data and no index provided
    columns : Index or array-like
    Column labels to use for resulting frame. Will default to
    np.arange(n) if no column labels are provided
    dtype : dtype, default None
    Data type to force, otherwise infer
    copy : boolean, default False
    Copy data from inputs. Only affects DataFrame / 2d ndarray input

    >>> d = {'col1': ts1, 'col2': ts2}
    >>> df = DataFrame(data=d, index=index)
    >>> df2 = DataFrame(np.random.randn(10, 5))
    >>> df3 = DataFrame(np.random.randn(10, 5),
    ... columns=['a', 'b', 'c', 'd', 'e'])

    See also
    DataFrame.from_records : constructor from tuples, also record arrays
    DataFrame.from_dict : from dicts of Series, arrays, or dicts
    DataFrame.from_items : from sequence of (key, value) pairs
    pandas.read_csv, pandas.read_table, pandas.read_clipboard
  • Stewart "Arturius" Campbell

    SSC Guru

    Points: 71808

    Nice question, thanks  Steve

    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 719742

    Apologies, corrected the reference.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply