Pandas中文手册

Pandas中文手册概述
概述
输入输出
read_pickle - 读取pickle序列化的pandas对象 read_table - 读取分隔符文本文件 read_csv read_fwf read_msgpack read_clipboard read_excel ExcelFile.parse ExcelWriter read_json json_normalize build_table_schema read_html read_hdf HDFStore.put HDFStore.append HDFStore.get HDFStore.select HDFStore.info HDFStore.keys HDFStore.groups HDFStore.walk read_feather read_parquet read_sas read_sql_table read_sql_query read_sql read_gbq read_stata StataReader.data StataReader.data_label StataReader.value_labels StataReader.variable_labels StataWriter.write_file
通用函数
melt pivot pivot_table crosstab cut qcut merge merge_ordered merge_asof concat get_dummies factorize unique wide_to_long isna isnull notna notnull to_numeric to_datetime to_timedelta date_range bdate_range period_range timedelta_range infer_freq interval_range eval util.hash_array util.has_pandas_object test
序列
Series Series.index Seires.array Series.values Series.dtype Series.ftype Series.shape Series.nbytes Series.ndim Series.size Series.strides Series.itemsize Series.base Series.T Series.memory_usage Series.hasnans Series.flags Series.empty Series.dtypes Series.ftypes Series.data Series.is_copy Series.name Series.put Series.astype Series.infer_objects Series.copy Series.bool Series.to_numpy Series.to_period Series.to_timestamp Series.to_list Series.get_values Series.__array__ Series.get Series.at Series.iat Series.loc Series.iloc Series.__iter__ Series.items Series.iteritems Series.keys Series.pop Series.item Series.xs Series.add Series.sub Series.mul Series.div Series.truediv Series.floordiv Series.mod Series.pow Series.radd Series.rsub Series.rmul Series.rdiv Series.rtruediv Series.rfloordiv Series.rmod Series.rpow Series.combine Series.combine_first Series.round Series.lt Series.gt Series.le Series.ge Series.ne Series.eq Series.product Series.dot Series.apply Series.agg Series.aggregate Series.transform Series.map Series.groupby Series.rolling Series.expanding Series.ewm Series.pipe Series.abs Series.any Series.autocorr Series.between Series.clip Series.clip_lower Series.corr Series.count Series.cov Series.cummax Series.cummin Series.cumprod Series.cumsum Series.describe Series.diff Series.factorize Series.kurt Series.mad Series.max Series.mean Series.min Series.mode Series.nlargest Series.nsmallest Series.pct_change Series.prod Series.quantile Series.rank Series.sem Series.skew Series.std Series.sum Series.var Series.kurtosis Series.unique Series.nunique Series.is_unique Series.is_monotonic Series.is_monotonic_increasing Series.is_monotonic_decreasing Series.value_counts Series.compound Series.align Series.drop Series.droplevel Series.drop_duplicates Series.duplicated Series.equals Series.first Series.head Series.idxmax Series.idxmin Series.isin Series.last Series.reindex Series.reindex_like Series.rename_axis Series.reset_index Series.sample Series.set_axis Series.take Series.truncate Series.where Series.mask Series.add_prefix Series.add_suffix Series.filter Series.isna Series.notna Series.fillna Series.interpolate Series.argsort Series.argmin Series.argmax Series.reorder_levels Series.sort_values Series.sort_index Series.swaplevel Series.unstack Series.explode Series.searchsorted Series.ravel Series.repeat Series.squeeze Series.view Series.append Series.replace Series.update Series.asfreq Series.asof Series.shift Series.fisrt_valid_index Series.last_valid_index Series.resample Series.tz_convert Series.tz_localize Series.at_time Series.between_time Series.tshift Series.slice_shift Series.dt.date Series.dt.time Series.dt.timetz Series.dt.year Series.dt.month Series.dt.day Series.dt.hour Series.dt.minute Series.dt.second Series.dt.microsecond Series.dt.nanosecond Series.dt.week Series.dt.weekofyear Series.dt.dayofweek Series.dt.weekday Series.dt.dayofyear Series.dt.quarter Series.dt.is_month_start Series.dt.is_month_end Series.dt.is_quarter_start Series.dt.is_quarter_en Series.dt.is_year_start Series.dt.is_year_end Series.dt.is_leap_year Series.dt.daysinmonth Series.dt.tz Series.dt.freq Series.dt.to_period Series.dt.to_pydatetime Series.dt.tz_localize Series.dt.tz_convert Series.dt.normalize Series.dt.strftime Series.dt.round Series.dt.floor Series.dt.ceil Series.dt.month_name Series.dt.day_name Series.dt.qyear Series.dt.start_time Series.dt.end_time Series.dt.qyear Series.dt.start_time Series.dt.end_time Series.dt.days Series.dt.seconds Series.dt.microseconds Series.dt.nanoseconds Series.dt.components Series.dt.to_pytimedelta Series.dt.total_seconds Series.str.capitalize Series.str.casefold Series.str.cat Series.str.center Series.str.contains Series.str.count Series.str.decode Series.str.encode Series.str.endswith Series.str.extract Series.str.extractall Series.str.find Series.str.findall Series.str.get Series.str.index Series.str.join Series.str.len Series.str.ljust Series.str.lower Series.str.lstrip Series.str.match Series.str.normalize Series.str.pad Series.str.partition Series.tr.repeat Series.str.replace Series.str.rfind Series.str.rindex Series.str.rjust Series.str.rpartition Series.str.rstrip Series.str.slice Series.str.slice_replace Series.str.split Series.str.rsplit Series.str.startswith Series.str.strip Series.str.swapcase Series.str.title Series.str.translate Series.str.upper Series.str.wrap Series.str.zfill Series.str.isalnum Series.str.isalpha Series.str.isdigit Series.str.isspace Series.str.islower Series.str.isupper Series.str.istitle Series.str.isnumric Series.tr.isdecimal Series.str.get_dummies Series.cat.categories Series.cat.ordered Series.cat.codes Series.cat.rename_categories Series.cat.reorder_categories Series.cat.add_categories Series.cat.remove_categories Series.cat.remove_unused_categories Series.cat.set_categories Series.cat.as_ordered Series.cat.as_unordered Series.sparse.npoints Series.sparse.density Series.sparse.fill_value Series.sparse.sp_value Series.sparse.from_cool Series.sparse.to_coo Series.plot Series.plot.area Series.plot.bar Series.plot.barh Series.plot.box Series.plot.density Series.plot.hist Series.plot.kde Series.plot.line Series.plot.pie Series.hist Series.to_pickle Series.to_csv Series.to_dict Series.to_excel Series.to_frame Series.to_xarray Series.to_hdf Series.to_sql Series.to_msgpack Series.to_json Series.to_sparse Series.to_dense Series.to_string Series.to_clipboard Series.to_latex SparseSeries.to_coo SparseSeries.from_coo
数据帧
DataFrame - 数据帧构造函数 DataFrame.index - 数据帧行标签 DataFrame.columns - 数据帧列标签 DataFrame.dtypes - 数据帧数据类型 DataFrame.ftypes DataFrame.get_dtype_counts DataFrame.get_ftype_counts DataFrame.select_dtypes() - 返回数据帧指定类型的列 DataFrame.values - 数据帧的ndarray表示 DataFrame.get_values DataFrame.axes - 数据帧的轴列表 DataFrame.ndim - 数据帧的维度数量 DataFrame.size - 数据帧的成员数量 DataFrame.shape - 数据帧的维度元组 DataFrame.memory_usage - 数据帧各列内存使用 DataFrame.empty - 数据帧是否为空 DataFrame.is_copy DataFrame.astype - 数据帧类型强制转换 DataFrame.infer_objects - 推导数据帧的object字段类型 DataFrame.copy - 拷贝数据帧 DataFrame.isna - 检测数据帧中的无效值 DataFrame.notna - 检测数据帧中的有效值 DataFrame.bool - 单值数据帧转换为布尔值 DataFrame.head - 返回数据帧前N行 DataFrame.at - 使用标签访问数据帧的指定成员 DataFrame.iat - 使用索引访问数据帧的指定成员 DataFrame.loc - 使用标签访问数据帧的子集 DataFrame.iloc - 使用索引访问数据帧的子集 DataFrame.insert - 在数据帧指定位置插入列 DataFrame.__iter__ DataFrame.items - 数据帧按列迭代 DataFrame.iteritems - 数据帧按列迭代 DataFrame.keys DataFrame.iterrows - 数据帧按行迭代 DataFrame.itertuples - 数据帧按行迭代 DataFrame.lookup - 数据帧查找 DataFrame.pop - 弹出数据帧指定列 DataFrame.tail - 返回数据帧的尾部N行 DataFrame.xs DataFrame.get DataFrame.isin - 检测数据帧的包含性 DataFrame.where - 按条件替换数据帧成员 DataFrame.mask - 数据帧掩膜 DataFrame.query - 数据帧查询 DataFrame.add DataFrame.sub DataFrame.mul DataFrame.div DataFrame.truediv DataFrame.floordiv DataFrame.mod DataFrame.pow DataFrame.dot DataFrame.radd DataFrame.rsub DataFrame.rmul DataFrame.rdiv DataFrame.rtruediv DataFrame.rfloordiv DataFrame.rmod DataFrame.rpow DataFrame.lt DataFrame.gt DataFrame.le DataFrame.ge DataFrame.ne DataFrame.eq DataFrame.combine DataFrame.combine_first DataFrame.apply DataFrame.applymap DataFrame.pipe DataFrame.agg DataFrame.aggregate DataFrame.transform DataFrame.groupby DataFrame.rolling DataFrame.expanding DataFrame.ewm DataFrame.abs DataFrame.all DataFrame.any DataFrame.clip DataFrame.clip_lower DataFrame.clip_upper DataFrame.compound DataFrame.corr DataFrame.corrwith DataFrame.count DataFrame.cov DataFrame.cummax DataFrame.cummin DataFrame.cumprod DataFrame.cumsum DataFrame.describe DataFrame.diff DataFrame.eval DataFrame.kurt DataFrame.kurtosis DataFrame.mad DataFrame.macx DataFrame.mean DataFrame.median DataFrame.min DataFrame.mode DataFrame.pct_change DataFrame.prod DataFrame.product DataFrame.quantile DataFrame.rank DataFrame.round DataFrame.sem DataFrame.skew DataFrame.sum DataFrame.std DataFrame.var DataFrame.nunique DataFrame.add_prefix DataFrame.add_suffix DataFrame.align DataFrame.at_time DataFrame.between_time DataFrame.drop DataFrame.drop_duplicates DataFrame.duplicated DataFrame.equals DataFrame.filters DataFrame.first DataFrame.head DataFrame.idxmax DataFrame.idxmin DataFrame.last DataFrame.reindex DataFrame.reindex_like DataFrame.rename DataFrame.rename_axis DataFrame.reset_index DataFrame.sample DataFrame.set_axis DataFrame.set_index DataFrame.tail DataFrame.take DataFrame.truncate DataFrame.dropna DataFrame.fillna DataFrame.replace DataFrame.interpolate DataFrame.droplevel DataFrame.pivot DataFrame.pivot_table DataFrame.reorder_levels DataFrame.sort_values DataFrame.sort_index DataFrame.nlargest DataFrame.nsmallest DataFrame.swaplevel DataFrame.stack DataFrame.unstack DataFrame.swapaxes DataFrame.melt DataFrame.explode DataFrame.squeeze DataFrame.to_xarray DataFrame.T DataFrame.transpose DataFrame.append DataFrame.assign DataFrame.join DataFrame.merge DataFrame.update DataFrame.asfreq DataFrame.asof DataFrame.shift DataFrame.slice_shift DataFrame.tshift DataFrame.first_valid_index DataFrame.last_valid_index DataFrame.resample DataFrame.to_period DataFrame.to_timestamp DataFrame.tz_convert DataFrame.tz_localize DataFrame.plot DataFrame.plot.area DataFrame.plot.bar DataFrame.plot.barh DataFrame.plot.box DataFrame.plot.density DataFrame.plot.hexbin DataFrame.plot.hist DataFrame.plot.kde DataFrame.plot.line DataFrame.plot.pie DataFrame.plot.scatter DataFrame.boxplot DataFrame.hist DataFrame.sparse.density DataFrame.sparse.from_spmatrix DataFrame.sparse.to_coo DataFrame.sparse.to_dense DataFrame.from_dict DataFrame.from_items DataFrame.from_records DataFrame.info DataFrame.to_parquet DataFrame.to_pickle DataFrame.to_csv DataFrame.to_hdf DataFrame.to_sql DataFrame.to_dict DataFrame.to_excel DataFrame.to_json DataFrame.to_html DataFrame.to_feather DataFrame.to_latex DataFrame.to_stata DataFrame.to_msgpack DataFrame.to_gbq DataFrame.to_records DataFrame.to_sparse DataFrame.to_dense DataFrame.to_string DataFrame.to_clipboard DataFrame.style SparseDataFrame.to_coo
索引对象
Index Index.values Index.is_monotonic Index.is_monotonic_increasing Index.is_monotonic_decreasing Index.is_unique Index.has_duplicates Index.hasnans Index.dtype Index.dtype_str Index.inferred_type Index.is_all_dates Index.shape Index.name Index.names Index.nbytes Index.ndim Index.size Index.empty Index.strides Index.itemsize Index.base Index.T Index.memory_usage Index.all Index.any Index.argmin Index.argmax Index.copy Index.delete Index.drop Index.drop_duplicates Index.duplicated Index.equals Index.factorized Index.identical Index.insert Index.is_ Index.is_boolean Index.is_categorical Index.is_floating Index.is_integer Index.is_interval Index.is_mixed Index.is_numeric Index.is_object Index.min Index.max Index.reindex Index.rename Index.repeat Index.where Index.take Index.putmask Index.unique Index.nunique Index.value_counts Index.set_names Index.is_lexsorted Index.droplevel Index.fillna Index.dropna Index.isna Index.notna Index.astype Index.item Index.map Index.ravel Index.to_list Index.to_native_tyeps Index.to_series Index.to_frame Index.view Index.argsort Index.searchsorted Index.sort_values Index.shift Index.append Index.join Index.intersection Index.union Index.difference Index.symmetric_difference Index.asof Index.asof_locs Index.contains Index.get_duplicates Index.get_indexer Index.get_indexer_for Index.get_indexer_non_unique Index.get_level_values Index.get_loc Index.get_slice_bound Index.get_value Index.get_values Index.set_value Index.isin Index.slice_indexer Index.slice_locs RangeIndex Int64Index UInt64Index Float64Index RangeIndex.start RangeIndex.stop RangeIndex.step RangeIndex.from_range CategoricalIndex CategoricalIndex.codes CategoricalIndex.categories CategoricalIndex.ordered CategoricalIndex.rename_categories CategoricalIndex.reorder_categories CategoricalIndex.add_categories CategoricalIndex.remove_categories CategoricalIndex.remove_unused_categories CategoricalIndex.set_categories CategoricalIndex.as_ordered CategoricalIndex.as_unordered CategoricalIndex.map CategoricalIndex.equals IntervalIndex IntervalIndex.from_array IntervalIndex.from_tuples IntervalIndex.from_breaks IntervalIndex.left IntervalIndex.right IntervalIndex.mid IntervalIndex.closed IntervalIndex.length IntervalIndex.values IntervalIndex.is_empty IntervalIndex.is_non_overlapping_monotonic IntervalIndex.is_overlapping IntervalIndex.get_loc IntervalIndex.get_indexer IntervalIndex.set_closed IntervalIndex.contains IntervalIndex.overlaps IntervalIndex.to_tuples MultiIndex IndexSlice MultiIndex.from_arrays MultiIndex.from_tuples MultiIndex.from_product MultiIndex.from_frame MultiIndex.names MultiIndex.levels MultiIndex.codes MultiIndex.nlevels MultiIndex.levshape MultiIndex.set_levels MultiIndex.set_codes MultiIndex.to_hierarchical MultiIndex.to_flat_index MultiIndex.to_frame MultiIndex.is_lexsorted MultiIndex.sortlevel MultiIndex.droplevel MultiIndex.swaplevel MultiIndex.reorder_levels MultiIndex.remove_unused_levels MultiIndex.get_loc MultiIndex.get_loc_level MultiIndex.get_indexer MultiIndex.get_level_values DatetimeIndex DatetimeIndex.year DatetimeIndex.month DatetimeIndex.day DatetimeIndex.hour DatetimeIndex.minute DatetimeIndex.second DatetimeIndex.microsecond DatetimeIndex.nanosecond DatetimeIndex.date DatetimeIndex.time DatetimeIndex.timetz DatetimeIndex.dayofyear DatetimeIndex.weekofyear DatetimeIndex.week DatetimeIndex.dayofweek DatetimeIndex.weekday DatetimeIndex.quarter DatetimeIndex.tz DatetimeIndex.freq DatetimeIndex.freqstr DatetimeIndex.is_month_start DatetimeIndex.is_month_end DatetimeIndex.is_quarter_start DatetimeIndex.is_quarter_end DatetimeIndex.is_year_start DatetimeIndex.is_year_end DatetimeIndex.is_leap_year DatetimeIndex.inferred_freq DatetimeIndex.indexer_at_time DatetimeIndex.indexer_between_time DatetimeIndex.normalize DatetimeIndex.strftime DatetimeIndex.snap DatetimeIndex.tz_convert DatetimeIndex.tz_localize DatetimeIndex.round DatetimeIndex.floor DatetimeIndex.ceil DatetimeIndex.month_name DatetimeIndex.day_name DatetimeIndex.to_period DatetimeIndex.to_perioddelta DatetimeIndex.to_pydatetime Datetimeindex.to_series DatetimeIndex.to_frame DatetimeIndex.mean TimedeltaIndex TimedeltaIndex.days TimedeltaIndex.seconds TimedeltaIndex.microseconds TimedeltaIndex.nanoseconds TimedeltaIndex.components TimedeltaIndex.inferred_freq TimedeltaIndex.to_pytimedelta TimedeltaIndex.to_series TimedeltaIndex.round TimedeltaIndex.floor TimedeltaIndex.ceil TimedeltaIndex.to_frame TimedeltaIndex.mean PeriodIndex PeriodIndex.day PeriodIndex.dayofweek PeriodIndex.dayofyear PeriodIndex.days_in_month PeriodIndex.daysinmonth PeriodIndex.end_time PeriodIndex.freq PeriodIndex.freqstr PeriodIndex.hour PeriodIndex.is_leap_year PeriodIndex.minute PeriodIndex.month PeriodIndex.quarter PeriodIndex.qyear PeriodIndex.second PeriodIndex.start_time PeriodIndex.week PeriodIndex.weekday PeriodIndex.weekofyear PeriodIndex.year PeriodIndex.asfreq PeriodIndex.strftime PeriodIndex.to_timestamp
日期偏移
DateOffset DateOffset.freqstr DateOffset.kwds DateOffset.name DateOffset.nanos DateOffset.normalize DateOffset.rule_code DateOffset.apply DateOffset.copy DateOffset.isAnchored DateOffset.onOffset BusinessDay BusinessDay.freqstr BusinessDay.kwds BusinessDay.name BusinessDay.nanos BusinessDay.normalize BusinessDay.rule_code BusinessDay.apply BusinessDay.apply_index BusinessDay.copy BusinessDay.isAnchored BusinessDay.onOffset BusinessHour BusinessHour.freqstr BusinessHour.kwds BusinessHour.name BusinessHour.nanos BusinessHour.normalize BusinessHour.rule_code BusinessHour.apply BusinessHour.copy BusinessHour.isAnchored BusinessHour.onOffset CustomBusinessDay CustomBusinessDay.freqstr CustomBusinessDay.kwds CustomBusinessDay.name CustomBusinessDay.nanos CustomBusinessDay.normalize CustomBusinessDay.rule_code CustomBusinessDay.apply CustomBusinessDay.copy CustomBusinessDay.isAnchored CustomBusinessDay.onOffset CustomBusinessHour CustomBusinessHour.freqstr CustomBusinessHour.kwds CustomBusinessHour.name CustomBusinessHour.nanos CustomBusinessHour.normalize CustomBusinessHour.rule_code CustomBusinessHour.apply CustomBusinessHour.copy CustomBusinessHour.isAnchored CustomBusinessHour.onOffset MonthOffset MonthOffset.freqstr MonthOffset.kwds MonthOffset.name MonthOffset.nanos MonthOffset.normalize MonthOffset.rule_code MonthOffset.apply MonthOffset.apply_index MonthOffset.copy MonthOffset.isAnchored MonthOffset.onOffset MonthEnd MonthEnd.freqstr MonthEnd.kwds MonthEnd.name MonthEnd.nanos MonthEnd.normalize MonthEnd.rule_code MonthEnd.apply MonthEnd.apply_index MonthEnd.copy MonthEnd.isAnchored MonthEnd.onOffset MonthBegin MonthBegin.freqstr MonthBegin.kwds MonthBegin.name MonthBegin.nanos MonthBegin.normalize MonthBegin.rule_code MonthBegin.apply MonthBegin.apply_index MonthBegin.copy MonthBegin.isAnchored MonthBegin.onOffset BusinessMonthEnd BusinessMonthEnd.freqstr BusinessMonthEnd.kwds BusinessMonthEnd.name BusinessMonthEnd.nanos BusinessMonthEnd.normalize BusinessMonthEnd.rule_code BusinessMonthEnd.apply BusinessMonthEnd.apply_index BusinessMonthEnd.copy BusinessMonthEnd.isAnchored BusinessMonthEnd.onOffset BusinessMonthBegin BusinessMonthBegin.freqstr BusinessMonthBegin.kwds BusinessMonthBegin.name BusinessMonthBegin.nanos BusinessMonthBegin.normalize BusinessMonthBegin.rule_code BusinessMonthBegin.apply BusinessMonthBegin.apply_index BusinessMonthBegin.copy BusinessMonthBegin.isAnchored BusinessMonthBegin.onOffset CustomBusinessMonthEnd CustomBusinessMonthEnd.freqstr CustomBusinessMonthEnd.kwds CustomBusinessMonthEnd.m_offset CustomBusinessMonthEnd.name CustomBusinessMonthEnd.nanos CustomBusinessMonthEnd.normalize CustomBusinessMonthEnd.rule_code CustomBusinessMonthEnd.apply CustomBusinessMonthEnd.copy CustomBusinessMonthEnd.isAnchored CustomBusinessMonthEnd.onOffset CustomBusinessMonthBegin CustomBusinessMonthBegin.freqstr CustomBusinessMonthBegin.kwds CustomBusinessMonthBegin.m_offset CustomBusinessMonthBegin.name CustomBusinessMonthBegin.nanos CustomBusinessMonthBegin.normalize CustomBusinessMonthBegin.rule_code CustomBusinessMonthBegin.apply CustomBusinessMonthBegin.copy CustomBusinessMonthBegin.isAnchored CustomBusinessMonthBegin.onOffset SemiMonthOffset SemiMonthOffset.freqstr SemiMonthOffset.kwds SemiMonthOffset.name SemiMonthOffset.nanos SemiMonthOffset.normalize SemiMonthOffset.rule_code SemiMonthOffset.apply SemiMonthOffset.apply_index SemiMonthOffset.copy SemiMonthOffset.isAnchored SemiMonthOffset.onOffset SemiMonthEnd SemiMonthEnd.freqstr SemiMonthEnd.kwds SemiMonthEnd.name SemiMonthEnd.nanos SemiMonthEnd.normalize SemiMonthEnd.rule_code SemiMonthEnd.apply SemiMonthEnd.apply_index SemiMonthEnd.copy SemiMonthEnd.isAnchored SemiMonthEnd.onOffset SemiMonthBegin SemiMonthBegin.freqstr SemiMonthBegin.kwds SemiMonthBegin.name SemiMonthBegin.nanos SemiMonthBegin.normalize SemiMonthBegin.rule_code SemiMonthBegin.apply SemiMonthBegin.apply_index SemiMonthBegin.copy SemiMonthBegin.isAnchored SemiMonthBegin.onOffset Week
窗口
Rolling.count
分组
GroupBy.__iter__
重采样
Resampler.__iter__
样式
Styler
绘图
andrews_curves
辅助函数
describe_option
扩展
api.extensions.register_extension_dtype
在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

DataFrame.bool - 单值数据帧转换为布尔值

DataFrame的bool()方法将单值数据帧转换为布尔类型的值。如果 数据帧对象不止一个成员并且不是布尔类型,调用该方法将触发异常。

方法原型

DataFrame.bool(self)

参数:无

返回值:返回转换后的布尔值

示例代码

下面的代码创建一个单值布尔类型的数据帧,然后调用其bool()方法 返回布尔值:

>>> df = pd.DataFrame([True])
>>> df.bool()
True