当前位置: 首页>>代码示例>>Python>>正文


Python DataFrame.from_csv方法代码示例

本文整理汇总了Python中pandas.core.frame.DataFrame.from_csv方法的典型用法代码示例。如果您正苦于以下问题:Python DataFrame.from_csv方法的具体用法?Python DataFrame.from_csv怎么用?Python DataFrame.from_csv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandas.core.frame.DataFrame的用法示例。


在下文中一共展示了DataFrame.from_csv方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: from_csv

# 需要导入模块: from pandas.core.frame import DataFrame [as 别名]
# 或者: from pandas.core.frame.DataFrame import from_csv [as 别名]
def from_csv(cls, path, sep=',', parse_dates=True, header=None,
                 index_col=0, encoding=None, infer_datetime_format=False):
        """
        Read delimited file into Series

        Parameters
        ----------
        path : string file path or file handle / StringIO
        sep : string, default ','
            Field delimiter
        parse_dates : boolean, default True
            Parse dates. Different default from read_table
        header : int, default 0
            Row to use at header (skip prior rows)
        index_col : int or sequence, default 0
            Column to use for index. If a sequence is given, a MultiIndex
            is used. Different default from read_table
        encoding : string, optional
            a string representing the encoding to use if the contents are
            non-ascii, for python versions prior to 3
        infer_datetime_format: boolean, default False
            If True and `parse_dates` is True for a column, try to infer the
            datetime format based on the first datetime string. If the format
            can be inferred, there often will be a large parsing speed-up.

        Returns
        -------
        y : Series
        """
        from pandas.core.frame import DataFrame
        df = DataFrame.from_csv(path, header=header, index_col=index_col,
                                sep=sep, parse_dates=parse_dates,
                                encoding=encoding,
                                infer_datetime_format=infer_datetime_format)
        result = df.icol(0)
        result.index.name = result.name = None
        return result 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:39,代码来源:series.py


注:本文中的pandas.core.frame.DataFrame.from_csv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。