How to use the swat.cas.datamsghandlers.PandasDataFrame function in swat

To help you get started, we’ve selected a few swat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sassoftware / python-swat / swat / cas / datamsghandlers.py View on Github external
--------
    :func:`pandas.read_html`
    :class:`PandasDataFrame`

    Returns
    -------
    :class:`HTML` data message handler object

    '''

    def __init__(self, path, index=0, nrecs=1000, transformers=None, **kwargs):
        super(HTML, self).__init__(pd.read_html(path, **kwargs)[index],
                                   nrecs=nrecs, transformers=transformers)


class SQLTable(PandasDataFrame):
    '''
    Create an SQLTable data message handler

    Parameters
    ----------
    table : string
        Name of table in database to fetch.
    engine : sqlalchemy engine
        sqlalchemy engine.
    nrecs : int, optional
        Number of records to send at a time.
    **kwargs : keyword arguments, optional
        Arguments sent to :class:`pandas.io.read_sql_table`.

    Returns
    -------
github sassoftware / python-swat / swat / cas / datamsghandlers.py View on Github external
--------
    :func:`pandas.read_json`
    :class:`PandasDataFrame`

    Returns
    -------
    :func:`JSON` data message handler object

    '''

    def __init__(self, path, nrecs=1000, transformers=None, **kwargs):
        super(JSON, self).__init__(pd.read_json(path, **kwargs),
                                   nrecs=nrecs, transformers=transformers)


class HTML(PandasDataFrame):
    '''
    Create an HTML data message handler

    Parameters
    ----------
    path : string
        Path or URL to HTML file.
    index : int, optional
        Index of table in the file.
    nrecs : int, optional
        Number of records to send at a time.
    **kwargs : keyword arguments, optional
        Arguments sent to :func:`pandas.read_html`.

    See Also
    --------
github sassoftware / python-swat / swat / cas / datamsghandlers.py View on Github external
--------
    :func:`pandas.read_excel`
    :class:`PandasDataFrame`

    Returns
    -------
    :class:`Excel` data message handler object

    '''

    def __init__(self, path, sheet=0, nrecs=1000, transformers=None, **kwargs):
        super(Excel, self).__init__(pd.read_excel(path, sheet, **kwargs),
                                    nrecs=nrecs, transformers=transformers)


class Clipboard(PandasDataFrame):
    '''
    Create a Clipboard data message handler

    Parameters
    ----------
    nrecs : int, optional
        Number of recods to send at a time.
    **kwargs : keyword arguments, optional
        Arguments sent to :func:`pandas.read_clipboard`.

    See Also
    --------
    :func:`pandas.read_clipboard`
    :class:`PandasDataFrame`

    Returns
github sassoftware / python-swat / swat / cas / datamsghandlers.py View on Github external
Keyword arguments to :func:`sqlalchemy.create_engine`.

        See Also
        --------
        :func:`sqlalchemy.create_engine`

        Returns
        -------
        :class:`SQLAlchemy` engine

        '''
        from sqlalchemy import create_engine
        return create_engine(*args, **kwargs)


class SQLQuery(PandasDataFrame):
    '''
    Create an SQLQuery data message handler

    Parameters
    ----------
    query : string
        SQL query.
    engine : sqlalchemy engine
        sqlalchemy engine.
    nrecs : int or long, optional
        Number of records to send at a time.
    **kwargs : any, optional
        Arguments sent to :func:`pandas.io.sql.read_sql_query`.

    See Also
    --------
github sassoftware / python-swat / swat / cas / datamsghandlers.py View on Github external
if fmt and wid:
                    variables[-1]['formattedlength'] = wid

            if formats and name in formats:
                variables[-1]['format'] = formats[name]

            if labels and name in labels:
                variables[-1]['label'] = labels[name]

            reclen = reclen + length

        self.data = data

        self.chunksize = len(self.data)

        super(PandasDataFrame, self).__init__(
            variables, nrecs=nrecs, reclen=reclen, transformers=transformers)
github sassoftware / python-swat / swat / cas / datamsghandlers.py View on Github external
:class:`FWF` data message handler object

    '''

    def __init__(self, path, nrecs=1000, transformers=None, **kwargs):
        kwargs.setdefault('chunksize', nrecs)
        try:
            super(FWF, self).__init__(pd.io.parsers.read_fwf(path, **kwargs),
                                      nrecs=nrecs, transformers=transformers)
        except StopIteration:
            del kwargs['chunksize']
            super(FWF, self).__init__(pd.io.parsers.read_fwf(path, **kwargs),
                                      nrecs=nrecs, transformers=transformers)


class JSON(PandasDataFrame):
    '''
    Create a JSON data message handler

    Parameters
    ----------
    path : string
        Path to JSON file.
    nrecs : int, optional
        Number of records to send at a time
    **kwargs : keyword arguments, optional
        Arguments sent to :func:`pandas.read_json`.

    See Also
    --------
    :func:`pandas.read_json`
    :class:`PandasDataFrame`
github sassoftware / python-swat / swat / cas / datamsghandlers.py View on Github external
:class:`PandasDataFrame`

    Returns
    -------
    :class:`SAS7BDAT` data message handler object

    '''

    def __init__(self, path, nrecs=1000, transformers=None, **kwargs):
        import sas7bdat
        super(SAS7BDAT, self).__init__(
            sas7bdat.SAS7BDAT(path, **kwargs).to_data_frame(), nrecs=nrecs,
            transformers=transformers)


class CSV(PandasDataFrame):
    '''
    Create a CSV data messsage handler

    Parameters
    ----------
    path : string
        Path to CSV file.
    nrecs : int, optional
        Number of records to send at a time.
    **kwargs : keyword arguments, optional
        Arguments sent to :func:`pandas.read_csv`.

    See Also
    --------
    :func:`pandas.read_csv`
    :class:`PandasDataFrame`
github sassoftware / python-swat / swat / cas / datamsghandlers.py View on Github external
:class:`CSV` data message handler object

    '''

    def __init__(self, path, nrecs=1000, transformers=None, **kwargs):
        kwargs.setdefault('chunksize', nrecs)
        try:
            super(CSV, self).__init__(pd.io.parsers.read_csv(path, **kwargs),
                                      nrecs=nrecs, transformers=transformers)
        except StopIteration:
            del kwargs['chunksize']
            super(CSV, self).__init__(pd.io.parsers.read_csv(path, **kwargs),
                                      nrecs=nrecs, transformers=transformers)


class Text(PandasDataFrame):
    '''
    Create a Text data message handler

    Parameters
    ----------
    path : string
        Path to text file.
    nrecs : int, optional
        Number of records to send at a time.
    **kwargs : keyword arguments, optional
        Arguments sent to :func:`pandas.io.parsers.read_table`.

    See Also
    --------
    :func:`pandas.io.parsers.read_table`
    :class:`PandasDataFrame`
github sassoftware / python-dlpy / dlpy / timeseries.py View on Github external
if isinstance(pandas_df, pd.Series):
            pandas_df = pandas_df.reset_index()

        if casout is None:
            casout_params = {}
        elif isinstance(casout, CASTable):
            casout_params = casout.to_outtable_params()
        elif isinstance(casout, dict):
            casout_params = casout

        if 'name' not in casout_params:
            casout_params['name'] = random_name('ts', 4)

        output_tbl_name = casout_params['name']

        handler = datamsghandlers.PandasDataFrame(pandas_df)

        conn.addtable(table=output_tbl_name, replace=True, **handler.args.addtable)

        tbl = conn.CASTable(name=output_tbl_name)

        return cls.from_table(tbl, columns=None, casout=casout_params)
github sassoftware / python-swat / swat / cas / datamsghandlers.py View on Github external
:class:`Text` data message handler object

    '''

    def __init__(self, path, nrecs=1000, transformers=None, **kwargs):
        kwargs.setdefault('chunksize', nrecs)
        try:
            super(Text, self).__init__(pd.io.parsers.read_table(path, **kwargs),
                                       nrecs=nrecs, transformers=transformers)
        except StopIteration:
            del kwargs['chunksize']
            super(Text, self).__init__(pd.io.parsers.read_table(path, **kwargs),
                                       nrecs=nrecs, transformers=transformers)


class FWF(PandasDataFrame):
    '''
    Create an FWF data message handler

    Parameters
    ----------
    path : string
       Path to text file.
    nrecs : int, optional
       Number of records to send at a time.
    **kwargs : keyword arguments, optional
       Arguments sent to :func:`pandas.io.parsers.read_table`.

    See Also
    --------
    :func:`pandas.io.parsers.read_table`
    :class:`PandasDataFrame`