网站着陆页有多少个1688做网站难吗

当前位置: 首页 > news >正文

网站着陆页有多少个,1688做网站难吗,好的网站开发自学网站,网站分类标准目录 一、用法精讲 546、pandas.DataFrame.ffill方法 546-1、语法 546-2、参数 546-3、功能 546-4、返回值 546-5、说明 546-6、用法 546-6-1、数据准备 546-6-2、代码示例 546-6-3、结果输出 547、pandas.DataFrame.fillna方法 547-1、语法 547-2、参数 547-3、…目录 一、用法精讲 546、pandas.DataFrame.ffill方法 546-1、语法 546-2、参数 546-3、功能 546-4、返回值 546-5、说明 546-6、用法 546-6-1、数据准备 546-6-2、代码示例 546-6-3、结果输出 547、pandas.DataFrame.fillna方法 547-1、语法 547-2、参数 547-3、功能 547-4、返回值 547-5、说明 547-6、用法 547-6-1、数据准备 547-6-2、代码示例 547-6-3、结果输出 548、pandas.DataFrame.interpolate方法 548-1、语法 548-2、参数 548-3、功能 548-4、返回值 548-5、说明 548-6、用法 548-6-1、数据准备 548-6-2、代码示例 548-6-3、结果输出 549、pandas.DataFrame.isna方法 549-1、语法 549-2、参数 549-3、功能 549-4、返回值 549-5、说明 549-6、用法 549-6-1、数据准备 549-6-2、代码示例 549-6-3、结果输出 550、pandas.DataFrame.isnull方法 550-1、语法 550-2、参数 550-3、功能 550-4、返回值 550-5、说明 550-6、用法 550-6-1、数据准备 550-6-2、代码示例 550-6-3、结果输出 二、推荐阅读 1、Python筑基之旅 2、Python函数之旅 3、Python算法之旅 4、Python魔法之旅 5、博客个人主页 一、用法精讲 546、pandas.DataFrame.ffill方法 546-1、语法

546、pandas.DataFrame.ffill方法

pandas.DataFrame.ffill(*, axisNone, inplaceFalse, limitNone, limit_areaNone, downcast_NoDefault.no_default) Fill NA/NaN values by propagating the last valid observation to next valid.Parameters: axis{0 or ‘index’} for Series, {0 or ‘index’, 1 or ‘columns’} for DataFrame Axis along which to fill missing values. For Series this parameter is unused and defaults to 0.inplacebool, default False If True, fill in-place. Note: this will modify any other views on this object (e.g., a no-copy slice for a column in a DataFrame).limitint, default None If method is specified, this is the maximum number of consecutive NaN values to forward/backward fill. In other words, if there is a gap with more than this number of consecutive NaNs, it will only be partially filled. If method is not specified, this is the maximum number of entries along the entire axis where NaNs will be filled. Must be greater than 0 if not None.limit_area{None, ‘inside’, ‘outside’}, default None If limit is specified, consecutive NaNs will be filled with this restriction.None: No fill restriction.‘inside’: Only fill NaNs surrounded by valid values (interpolate).‘outside’: Only fill NaNs outside valid values (extrapolate).New in version 2.2.0.downcastdict, default is None A dict of item-dtype of what to downcast if possible, or the string ‘infer’ which will try to downcast to an appropriate equal type (e.g. float64 to int64 if possible).Deprecated since version 2.2.0.Returns: Series/DataFrame or None Object with missing values filled or None if inplaceTrue. 546-2、参数 546-2-1、axis(可选默认值为None){0或index1或columns}确定填充操作的方向0或index表示沿着行(向下填充)1或columns表示沿着列(向右填充)如果为None则会根据轴的方向自动选择。 546-2-2、inplace(可选默认值为False)布尔值是否在原地修改DataFrame如果为True操作将在原始DataFrame上进行而不会返回新的DataFrame如果为False则返回一个新的DataFrame原始DataFrame不变。 546-2-3、limit(可选默认值为None)整数指定最大填充数量填充过程将限制为最多填充limit个缺失值。 546-2-4、limit_area(可选默认值为None)None或类似于DataFrame的对象指定一个区域该区域内的缺失值才会被填充如果指定将仅在这个区域内执行前向填充。 546-2-5、downcast(可选){int, float, string, boolean}或None指定数据类型的向下转型若指定此参数则会尝试将数据转换为更小的数据类型前提是数据类型允许。 546-3、功能 用前一个有效值填充缺失值在许多数据处理和分析应用中缺失值是常见的问题前向填充可以帮助将数据完整化便于后续分析。 546-4、返回值 返回值是一个填充后的DataFrame如果inplaceTrue则返回值为None原始DataFrame被直接修改。 546-5、说明 无 546-6、用法 546-6-1、数据准备 无 546-6-2、代码示例

546、pandas.DataFrame.ffill方法

import pandas as pd import numpy as np

创建一个示例DataFrame

df pd.DataFrame({A: [1, np.nan, 3],B: [np.nan, 2, np.nan],C: [1, 2, 3] })

使用前向填充

filled_df df.ffill() print(filled_df) 546-6-3、结果输出

546、pandas.DataFrame.ffill方法

A B C

0 1.0 NaN 1

1 1.0 2.0 2

2 3.0 2.0 3

547、pandas.DataFrame.fillna方法 547-1、语法

547、pandas.DataFrame.fillna方法

pandas.DataFrame.fillna(valueNone, *, methodNone, axisNone, inplaceFalse, limitNone, downcast_NoDefault.no_default) Fill NA/NaN values using the specified method.Parameters: valuescalar, dict, Series, or DataFrame Value to use to fill holes (e.g. 0), alternately a dict/Series/DataFrame of values specifying which value to use for each index (for a Series) or column (for a DataFrame). Values not in the dict/Series/DataFrame will not be filled. This value cannot be a list.method{‘backfill’, ‘bfill’, ‘ffill’, None}, default None Method to use for filling holes in reindexed Series:ffill: propagate last valid observation forward to next valid.backfill / bfill: use next valid observation to fill gap.Deprecated since version 2.1.0: Use ffill or bfill instead.axis{0 or ‘index’} for Series, {0 or ‘index’, 1 or ‘columns’} for DataFrame Axis along which to fill missing values. For Series this parameter is unused and defaults to 0.inplacebool, default False If True, fill in-place. Note: this will modify any other views on this object (e.g., a no-copy slice for a column in a DataFrame).limitint, default None If method is specified, this is the maximum number of consecutive NaN values to forward/backward fill. In other words, if there is a gap with more than this number of consecutive NaNs, it will only be partially filled. If method is not specified, this is the maximum number of entries along the entire axis where NaNs will be filled. Must be greater than 0 if not None.downcastdict, default is None A dict of item-dtype of what to downcast if possible, or the string ‘infer’ which will try to downcast to an appropriate equal type (e.g. float64 to int64 if possible).Deprecated since version 2.2.0.Returns: Series/DataFrame or None Object with missing values filled or None if inplaceTrue. 547-2、参数 547-2-1、value(可选默认值为None)scalar, dict, Series或 DataFrame指定填充缺失值的值可以是单个值、一组值(字典或Series)或另一个DataFrame如果为None则需要同时指定method。 547-2-2、method(可选默认值为None){backfillbfillpadffill}用于指定填充缺失值的方法 pad或ffill前向填充使用前一个有效值填充。backfill或bfill后向填充使用后一个有效值填充。 547-2-3、axis(可选默认值为None){0或index1或columns}确定填充操作的方向0或index表示沿着行(纵向填充)1或columns表示沿着列(横向填充)如果为None则根据数据的形状自动选择。 547-2-4、inplace(可选默认值为False)布尔值是否在原地修改DataFrame如果为True填充将在原始DataFrame上完成并返回None如果为False则返回一个新的DataFrame原始DataFrame保持不变。 547-2-5、limit(可选默认值为None)整数指定在填充操作中最多填充的缺失值数量这适用于前向或后向填充方法。 547-2-6、downcast(可选){intfloatstringboolean}或None指定数据类型的向下转型若是否将填充后的数据转换为更小的数据类型前提是数据类型允许。 547-3、功能 用指定的值或方法替代缺失值在数据处理中缺失值常常需要被合理填充以便进一步分析和建模。 547-4、返回值 返回值是一个填充后的DataFrame如果inplaceTrue则返回值为None原始DataFrame会被直接修改。 547-5、说明 无 547-6、用法 547-6-1、数据准备 无 547-6-2、代码示例

547、pandas.DataFrame.fillna方法

import pandas as pd import numpy as np

创建一个示例DataFrame

df pd.DataFrame({A: [1, np.nan, 3],B: [np.nan, 2, np.nan],C: [1, 2, 3] })

使用填充指定值

filled_df1 df.fillna(value0)

使用前向填充

filled_df2 df.fillna(methodffill) print(使用指定值填充) print(filled_df1) print(\n使用前向填充) print(filled_df2) 547-6-3、结果输出

547、pandas.DataFrame.fillna方法

使用指定值填充

A B C

0 1.0 0.0 1

1 0.0 2.0 2

2 3.0 0.0 3

使用前向填充

A B C

0 1.0 NaN 1

1 1.0 2.0 2

2 3.0 2.0 3

548、pandas.DataFrame.interpolate方法 548-1、语法

548、pandas.DataFrame.interpolate方法

pandas.DataFrame.interpolate(methodlinear, *, axis0, limitNone, inplaceFalse, limit_directionNone, limit_areaNone, downcast_NoDefault.no_default, kwargs) Fill NaN values using an interpolation method.Please note that only methodlinear is supported for DataFrame/Series with a MultiIndex.Parameters: methodstr, default ‘linear’ Interpolation technique to use. One of:‘linear’: Ignore the index and treat the values as equally spaced. This is the only method supported on MultiIndexes.‘time’: Works on daily and higher resolution data to interpolate given length of interval.‘index’, ‘values’: use the actual numerical values of the index.‘pad’: Fill in NaNs using existing values.‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘barycentric’, ‘polynomial’: Passed to scipy.interpolate.interp1d, whereas ‘spline’ is passed to scipy.interpolate.UnivariateSpline. These methods use the numerical values of the index. Both ‘polynomial’ and ‘spline’ require that you also specify an order (int), e.g. df.interpolate(methodpolynomial, order5). Note that, slinear method in Pandas refers to the Scipy first order spline instead of Pandas first order spline.‘krogh’, ‘piecewise_polynomial’, ‘spline’, ‘pchip’, ‘akima’, ‘cubicspline’: Wrappers around the SciPy interpolation methods of similar names. See Notes.‘from_derivatives’: Refers to scipy.interpolate.BPoly.from_derivatives.axis{{0 or ‘index’, 1 or ‘columns’, None}}, default None Axis to interpolate along. For Series this parameter is unused and defaults to 0.limitint, optional Maximum number of consecutive NaNs to fill. Must be greater than 0.inplacebool, default False Update the data in place if possible.limit_direction{{‘forward’, ‘backward’, ‘both’}}, Optional Consecutive NaNs will be filled in this direction.If limit is specified: If ‘method’ is ‘pad’ or ‘ffill’, ‘limit_direction’ must be ‘forward’.If ‘method’ is ‘backfill’ or ‘bfill’, ‘limit_direction’ must be ‘backwards’.If ‘limit’ is not specified: If ‘method’ is ‘backfill’ or ‘bfill’, the default is ‘backward’else the default is ‘forward’raises ValueError if limit_direction is ‘forward’ or ‘both’ and method is ‘backfill’ or ‘bfill’.raises ValueError if limit_direction is ‘backward’ or ‘both’ and method is ‘pad’ or ‘ffill’.limit_area{{None, ‘inside’, ‘outside’}}, default None If limit is specified, consecutive NaNs will be filled with this restriction.None: No fill restriction.‘inside’: Only fill NaNs surrounded by valid values (interpolate).‘outside’: Only fill NaNs outside valid values (extrapolate).downcastoptional, ‘infer’ or None, defaults to None Downcast dtypes if possible.Deprecated since version 2.1.0.kwargsoptional Keyword arguments to pass on to the interpolating function.Returns: Series or DataFrame or None Returns the same object type as the caller, interpolated at some or all NaN values or None if inplaceTrue. 548-2、参数 548-2-1、method(可选默认值为linear)字符串指定插值的方法常用的方法包括 linear线性插值(默认)。time时间序列插值仅适用于索引为时间戳的情况下。index根据索引值进行插值。其他插值方法如nearest、polynomial、spline等。 548-2-2、axis(可选默认值为0){0或index1或columns}指定插值操作的方向0或index表示沿着行进行插值1或columns表示沿着列进行插值。 548-2-3、limit(可选默认值为None)整数指定在插值操作中最多插值的缺失值数量这可以限制插值的范围。 548-2-4、inplace(可选默认值为False)布尔值是否在原地修改DataFrame如果为True插值将在原始DataFrame上完成并返回None如果为False则返回一个新的DataFrame原始DataFrame保持不变。 548-2-5、limit_direction(可选默认值为None){None, forward, backward}指定插值的方向forward表示只执行向前填充backward表示只执行向后填充如果为None默认为两者都可。 548-2-6、limit_area(可选默认值为None){None, inside, outside, both}指定插值的区域inside表示仅在内侧插值outside表示仅在外侧插值both表示在两者范围内插值。 548-2-7、downcast(可选){intfloatstringboolean}或None指定数据类型的向下转型若是否将插值后的数据转换为更小的数据类型前提是数据类型允许。 548-2-8、**kwargs(可选)其他额外的关键字参数为后续扩展功能做预留。 548-3、功能 填充缺失值通过插值计算在已有数据点之间估算缺失值这在处理时间序列数据或一般情况下的数据填充时非常有用可以保持数据的连续性。 548-4、返回值 返回值是一个填充后的DataFrame如果inplaceTrue则返回值为None原始DataFrame会被直接修改。 548-5、说明 无 548-6、用法 548-6-1、数据准备 无 548-6-2、代码示例

548、pandas.DataFrame.interpolate方法

import pandas as pd import numpy as np

创建一个示例DataFrame

df pd.DataFrame({A: [1, np.nan, 3, np.nan, 5],B: [np.nan, 2, 3, 4, 5] })

使用线性插值填充缺失值

interpolated_df1 df.interpolate(methodlinear) print(线性插值填充结果) print(interpolated_df1) 548-6-3、结果输出

548、pandas.DataFrame.interpolate方法

线性插值填充结果

A B

0 1.0 NaN

1 2.0 2.0

2 3.0 3.0

3 4.0 4.0

4 5.0 5.0

549、pandas.DataFrame.isna方法 549-1、语法

549、pandas.DataFrame.isna方法

pandas.DataFrame.isna() Detect missing values.Return a boolean same-sized object indicating if the values are NA. NA values, such as None or numpy.NaN, gets mapped to True values. Everything else gets mapped to False values. Characters such as empty strings or numpy.inf are not considered NA values (unless you set pandas.options.mode.use_inf_as_na True).Returns: DataFrame Mask of bool values for each element in DataFrame that indicates whether an element is an NA value. 549-2、参数 无 549-3、功能 返回一个布尔型的DataFrame与原始DataFrame具有相同的形状布尔值表示数据是否为缺失值缺失值(NaN)会被标记为True而非缺失值会被标记为False。 549-4、返回值 返回一个与原始DataFrame形状相同的布尔型DataFrame如果某个单元格的值为缺失(如NaN)对应的位置将为True否则为False。 549-5、说明 无 549-6、用法 549-6-1、数据准备 无 549-6-2、代码示例

549、pandas.DataFrame.isna方法

import pandas as pd import numpy as np

创建一个示例DataFrame

df pd.DataFrame({A: [1, np.nan, 3],B: [4, 5, np.nan],C: [np.nan, np.nan, 9] })

检测缺失值

na_df df.isna() print(缺失值检测结果) print(na_df) 549-6-3、结果输出

549、pandas.DataFrame.isna方法

缺失值检测结果

A B C

0 False False True

1 True False True

2 False True False

550、pandas.DataFrame.isnull方法 550-1、语法

550、pandas.DataFrame.isnull方法

pandas.DataFrame.isnull() DataFrame.isnull is an alias for DataFrame.isna.Detect missing values.Return a boolean same-sized object indicating if the values are NA. NA values, such as None or numpy.NaN, gets mapped to True values. Everything else gets mapped to False values. Characters such as empty strings or numpy.inf are not considered NA values (unless you set pandas.options.mode.use_inf_as_na True).Returns: DataFrame Mask of bool values for each element in DataFrame that indicates whether an element is an NA value. 550-2、参数 无 550-3、功能 返回一个与原始DataFrame同样形状的布尔型DataFrame其中每个单元格指示该位置的值是否为缺失值缺失值(NaN)将被标记为True非缺失值将被标记为 False。 550-4、返回值 返回一个布尔型DataFrame形状与原始DataFrame相同。 550-5、说明 无 550-6、用法 550-6-1、数据准备 无 550-6-2、代码示例

550、pandas.DataFrame.isnull方法

import pandas as pd import numpy as np

创建一个示例DataFrame

df pd.DataFrame({A: [1, np.nan, 3],B: [4, 5, np.nan],C: [np.nan, np.nan, 9] })

检测缺失值

null_df df.isnull() print(缺失值检测结果) print(null_df) 550-6-3、结果输出

550、pandas.DataFrame.isnull方法

缺失值检测结果

A B C

0 False False True

1 True False True

2 False True False

二、推荐阅读 1、Python筑基之旅 2、Python函数之旅 3、Python算法之旅 4、Python魔法之旅 5、博客个人主页