zoukankan      html  css  js  c++  java
  • pandas.DataFrame.sample

    DataFrame.sample(n=None, frac=None, replace=False, weights=None, random_state=None, axis=None)[source]

    n : int, optional
    Number of items from axis to return. Cannot be used with frac. Default = 1 if frac = None.
    frac : float, optional
    Fraction of axis items to return. Cannot be used with n.
    replace : boolean, optional
    Sample with or without replacement. Default = False.
    weights : str or ndarray-like, optional
    Default ‘None’ results in equal probability weighting. If passed a Series, will align with target object on index. Index values in weights not found in sampled object will be ignored and index values in sampled object not in weights will be assigned weights of zero. If called on a DataFrame, will accept the name of a column when axis = 0. Unless weights are a Series, weights must be same length as axis being sampled. If weights do not sum to 1, they will be normalized to sum to 1. Missing values in the weights column will be treated as zero. inf and -inf values not allowed.
    random_state : int or numpy.random.RandomState, optional
    Seed for the random number generator (if int), or numpy RandomState object.
    axis : int or string, optional
    Axis to sample. Accepts axis number or name. Default is stat axis for given data type (0 for Series and DataFrames, 1 for Panels).

    Axis参数的意思是,从哪个维度取样。如axis = 0,即从row中取样。

  • 相关阅读:
    POJ1251 Jungle Roads 【最小生成树Prim】
    聪明的kk
    日积月累:weightSum和layout_weight属性合用
    ubuntu 下舒畅的使用libreoffice
    maple 教程
    龙、虎、鲸书杂谈
    百度没出新算法之前这样的最好的的优化方案
    DWR入门实例(二)
    Android应用公布的准备——生成渠道包
    leetcode第一刷_Spiral Matrix II
  • 原文地址:https://www.cnblogs.com/yaos/p/14014279.html
Copyright © 2011-2022 走看看