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


Python DataFrame.append方法代码示例

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


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

示例1: _concat_indexes

# 需要导入模块: from pandas import DataFrame [as 别名]
# 或者: from pandas.DataFrame import append [as 别名]
def _concat_indexes(indexes):
    return indexes[0].append(indexes[1:]) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:4,代码来源:concat.py

示例2: get_result

# 需要导入模块: from pandas import DataFrame [as 别名]
# 或者: from pandas.DataFrame import append [as 别名]
def get_result(self):

        # series only
        if self._is_series:

            # stack blocks
            if self.axis == 0:
                name = com.consensus_name_attr(self.objs)

                mgr = self.objs[0]._data.concat([x._data for x in self.objs],
                                                self.new_axes)
                cons = _concat._get_series_result_type(mgr, self.objs)
                return cons(mgr, name=name).__finalize__(self, method='concat')

            # combine as columns in a frame
            else:
                data = dict(zip(range(len(self.objs)), self.objs))
                cons = _concat._get_series_result_type(data)

                index, columns = self.new_axes
                df = cons(data, index=index)
                df.columns = columns
                return df.__finalize__(self, method='concat')

        # combine block managers
        else:
            mgrs_indexers = []
            for obj in self.objs:
                mgr = obj._data
                indexers = {}
                for ax, new_labels in enumerate(self.new_axes):
                    if ax == self.axis:
                        # Suppress reindexing on concat axis
                        continue

                    obj_labels = mgr.axes[ax]
                    if not new_labels.equals(obj_labels):
                        indexers[ax] = obj_labels.reindex(new_labels)[1]

                mgrs_indexers.append((obj._data, indexers))

            new_data = concatenate_block_managers(
                mgrs_indexers, self.new_axes, concat_axis=self.axis,
                copy=self.copy)
            if not self.copy:
                new_data._consolidate_inplace()

            cons = _concat._get_frame_result_type(new_data, self.objs)
            return (cons._from_axes(new_data, self.new_axes)
                    .__finalize__(self, method='concat')) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:52,代码来源:concat.py

示例3: get_result

# 需要导入模块: from pandas import DataFrame [as 别名]
# 或者: from pandas.DataFrame import append [as 别名]
def get_result(self):

        # series only
        if self._is_series:

            # stack blocks
            if self.axis == 0:
                name = com._consensus_name_attr(self.objs)

                mgr = self.objs[0]._data.concat([x._data for x in self.objs],
                                                self.new_axes)
                cons = _concat._get_series_result_type(mgr, self.objs)
                return cons(mgr, name=name).__finalize__(self, method='concat')

            # combine as columns in a frame
            else:
                data = dict(zip(range(len(self.objs)), self.objs))
                cons = _concat._get_series_result_type(data)

                index, columns = self.new_axes
                df = cons(data, index=index)
                df.columns = columns
                return df.__finalize__(self, method='concat')

        # combine block managers
        else:
            mgrs_indexers = []
            for obj in self.objs:
                mgr = obj._data
                indexers = {}
                for ax, new_labels in enumerate(self.new_axes):
                    if ax == self.axis:
                        # Suppress reindexing on concat axis
                        continue

                    obj_labels = mgr.axes[ax]
                    if not new_labels.equals(obj_labels):
                        indexers[ax] = obj_labels.reindex(new_labels)[1]

                mgrs_indexers.append((obj._data, indexers))

            new_data = concatenate_block_managers(
                mgrs_indexers, self.new_axes, concat_axis=self.axis,
                copy=self.copy)
            if not self.copy:
                new_data._consolidate_inplace()

            cons = _concat._get_frame_result_type(new_data, self.objs)
            return (cons._from_axes(new_data, self.new_axes)
                    .__finalize__(self, method='concat')) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:52,代码来源:concat.py


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