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

一般网站建设需求有哪些方面怎么把做的网站优化到百度

一般网站建设需求有哪些方面,怎么把做的网站优化到百度,有关网站建设的书籍,网站设计开发网站目录 一、用法精讲 186、pandas.Series.is_monotonic_increasing属性 186-1、语法 186-2、参数 186-3、功能 186-4、返回值 186-5、说明 186-6、用法 186-6-1、数据准备 186-6-2、代码示例 186-6-3、结果输出 187、pandas.Series.is_monotonic_decreasing属性 187…目录 一、用法精讲 186、pandas.Series.is_monotonic_increasing属性 186-1、语法 186-2、参数 186-3、功能 186-4、返回值 186-5、说明 186-6、用法 186-6-1、数据准备 186-6-2、代码示例 186-6-3、结果输出 187、pandas.Series.is_monotonic_decreasing属性 187-1、语法 187-2、参数 187-3、功能 187-4、返回值 187-5、说明 187-6、用法 187-6-1、数据准备 187-6-2、代码示例 187-6-3、结果输出 188、pandas.Series.value_counts方法 188-1、语法 188-2、参数 188-3、功能 188-4、返回值 188-5、说明 188-6、用法 188-6-1、数据准备 188-6-2、代码示例 188-6-3、结果输出 189、pandas.Series.align方法 189-1、语法 189-2、参数 189-3、功能 189-4、返回值 189-5、说明 189-6、用法 189-6-1、数据准备 189-6-2、代码示例 189-6-3、结果输出 190、pandas.Series.case_when方法 190-1、语法 190-2、参数 190-3、功能 190-4、返回值 190-5、说明 190-6、用法 190-6-1、数据准备 190-6-2、代码示例 190-6-3、结果输出 二、推荐阅读 1、Python筑基之旅 2、Python函数之旅 3、Python算法之旅 4、Python魔法之旅 5、博客个人主页 一、用法精讲 186、pandas.Series.is_monotonic_increasing属性 186-1、语法 # 186、pandas.Series.is_monotonic_increasing属性 property pandas.Series.is_monotonic_increasing Return boolean if values in the object are monotonically increasing.Returns: bool 186-2、参数 无 186-3、功能 用于判断系列中的值是否按非递减顺序排列。 186-4、返回值 返回一个布尔值如果系列中的值是单调递增的(即每个值都大于或等于前一个值)返回True如果系列中的值不是单调递增的返回False。 186-5、说明 在数据分析过程中该属性可以用来快速检查数据的趋势例如时间序列数据是否按时间递增、价格数据是否持续上升等。 186-6、用法 186-6-1、数据准备 无 186-6-2、代码示例 # 186、pandas.Series.is_monotonic_increasing属性 import pandas as pd # 创建一个单调递增的系列 data_increasing pd.Series([1, 2, 3, 4, 5]) # 判断系列中的值是否单调递增 is_monotonic_increasing data_increasing.is_monotonic_increasing print(f系列值是否单调递增: {is_monotonic_increasing}) # 创建一个非单调递增的系列 data_not_increasing pd.Series([1, 3, 2, 4, 5]) # 判断系列中的值是否单调递增 is_monotonic_increasing data_not_increasing.is_monotonic_increasing print(f系列值是否单调递增: {is_monotonic_increasing}) 186-6-3、结果输出 # 186、pandas.Series.is_monotonic_increasing属性 # 系列值是否单调递增: True # 系列值是否单调递增: False 187、pandas.Series.is_monotonic_decreasing属性 187-1、语法 # 187、pandas.Series.is_monotonic_decreasing属性 property pandas.Series.is_monotonic_decreasing Return boolean if values in the object are monotonically decreasing.Returns: bool 187-2、参数 无 187-3、功能 用于判断系列中的值是否按递减顺序排列。 187-4、返回值 返回一个布尔值如果系列中的值是单调递减的(即每个值都小于或等于前一个值)返回True如果系列中的值不是单调递减的返回False。 187-5、说明 在数据分析过程中该属性可以用来快速检查数据的趋势例如库存数据是否持续减少、销售数据是否下降等。 187-6、用法 187-6-1、数据准备 无 187-6-2、代码示例 # 187、pandas.Series.is_monotonic_decreasing属性 import pandas as pd # 创建一个单调递减的系列 data_decreasing pd.Series([5, 4, 3, 2, 1]) # 判断系列中的值是否单调递减 is_monotonic_decreasing data_decreasing.is_monotonic_decreasing print(f系列值是否单调递减: {is_monotonic_decreasing}) # 创建一个非单调递减的系列 data_not_decreasing pd.Series([5, 3, 4, 2, 1]) # 判断系列中的值是否单调递减 is_monotonic_decreasing data_not_decreasing.is_monotonic_decreasing print(f系列值是否单调递减: {is_monotonic_decreasing})187-6-3、结果输出 # 187、pandas.Series.is_monotonic_decreasing属性 # 系列值是否单调递减: True # 系列值是否单调递减: False 188、pandas.Series.value_counts方法 188-1、语法 # 188、pandas.Series.value_counts方法 pandas.Series.value_counts(normalizeFalse, sortTrue, ascendingFalse, binsNone, dropnaTrue) Return a Series containing counts of unique values.The resulting object will be in descending order so that the first element is the most frequently-occurring element. Excludes NA values by default.Parameters: normalize bool, default False If True then the object returned will contain the relative frequencies of the unique values.sort bool, default True Sort by frequencies when True. Preserve the order of the data when False.ascending bool, default False Sort in ascending order.bins int, optional Rather than count values, group them into half-open bins, a convenience for pd.cut, only works with numeric data.dropna bool, default True Don’t include counts of NaN.Returns: Series 188-2、参数 188-2-1、normalize(可选默认值为False)如果设置为True返回每个唯一值的相对频率否则返回绝对值的计数。 188-2-2、sort(可选默认值为True)如果设置为True结果按计数值排序如果设置为False则按唯一值本身排序。 188-2-3、ascending(可选默认值为False)如果设置为True结果按升序排序如果设置为False(默认值)则按降序排序。 188-2-4、bins(可选默认值为None)如果设置为整数则会将数据分成相应数量的区间并返回每个区间的计数。 188-2-5、dropna(可选默认值为True)如果设置为True(默认值)则不计算NaN值如果设置为False则包括NaN值的计数。 188-3、功能 188-3-1、计数每个唯一值的出现次数默认情况下返回每个唯一值的绝对频率。 188-3-2、排序默认按计数值降序排列但可以通过参数设置为升序或按唯一值本身排序。 188-3-3、相对频率通过设置normalizeTrue可以返回每个唯一值的相对频率(比例)。 188-3-4、分箱通过设置bins参数可以将数据分成若干区间并返回每个区间的计数。 188-3-5、处理缺失值默认情况下NaN值不包括在计数中但可以通过设置dropnaFalse包括NaN值的计数。 188-4、返回值 返回一个pandas.Series对象索引是原始Series中的唯一值(或区间)值是每个唯一值(或区间)的计数。 188-5、说明 使用场景 188-5-1、探索性数据分析(EDA)在数据分析的初始阶段使用value_counts()可以快速了解数据的分布情况。例如分析客户年龄分布、产品销售量分布等。 188-5-2、数据清洗在处理缺失值和重复值时可以使用value_counts()找出异常值或频次较低的值从而帮助清洗数据。 188-5-3、分类数据分析对于分类变量(如性别、地区、职业等)可以使用value_counts()计算每个类别的频次以便进一步的统计分析或可视化。 188-5-4、数据验证在数据验证过程中使用value_counts()可以检查数据是否符合预期分布例如检查试验组和对照组的样本量是否均衡。 188-5-5、异常检测通过value_counts()计算频次识别出频次异常的值有助于发现数据中的潜在问题或异常情况。 188-5-6、特征工程在特征工程中可以使用value_counts()生成新的特征例如计算某个特征的出现次数并将其作为新的特征添加到数据集中。 188-5-7、文本数据分析在自然语言处理任务中可以使用value_counts()统计词频分析文本数据的关键词或常用词。 188-5-8、时间序列分析对于时间序列数据可以使用value_counts()统计不同时间段内事件的发生频次例如统计每月的销售订单数量。 188-5-9、用户行为分析在用户行为分析中使用value_counts()可以统计用户的操作频次例如统计用户登录、点击、购买等行为的次数。 188-6、用法 188-6-1、数据准备 无 188-6-2、代码示例 # 188、pandas.Series.value_counts方法 # 188-1、基本用法 import pandas as pd data pd.Series([1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) counts data.value_counts() print(counts, end\n\n)# 188-2、返回相对频率 import pandas as pd data pd.Series([1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) counts_normalized data.value_counts(normalizeTrue) print(counts_normalized, end\n\n)# 188-3、按升序排列 import pandas as pd data pd.Series([1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) counts_ascending data.value_counts(ascendingTrue) print(counts_ascending, end\n\n)# 188-4、分箱计数 import pandas as pd data pd.Series([1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) counts_bins data.value_counts(bins3) print(counts_bins, end\n\n)# 188-5、包括NaN值的计数 import pandas as pd data_with_nan pd.Series([1, 2, 2, 3, 3, 3, 4, 4, 4, 4, None]) counts_with_nan data_with_nan.value_counts(dropnaFalse) print(counts_with_nan) 188-6-3、结果输出 # 188、pandas.Series.value_counts方法 # 188-1、基本用法 # 4 4 # 3 3 # 2 2 # 1 1 # Name: count, dtype: int64# 188-2、返回相对频率 # 4 0.4 # 3 0.3 # 2 0.2 # 1 0.1 # Name: proportion, dtype: float64# 188-3、按升序排列 # 1 1 # 2 2 # 3 3 # 4 4 # Name: count, dtype: int64# 188-4、分箱计数 # (3.0, 4.0] 4 # (0.996, 2.0] 3 # (2.0, 3.0] 3 # Name: count, dtype: int64# 188-5、包括NaN值的计数 # 4.0 4 # 3.0 3 # 2.0 2 # 1.0 1 # NaN 1 # Name: count, dtype: int64 189、pandas.Series.align方法 189-1、语法 # 189、pandas.Series.align方法 pandas.Series.align(other, joinouter, axisNone, levelNone, copyNone, fill_valueNone, method_NoDefault.no_default, limit_NoDefault.no_default, fill_axis_NoDefault.no_default, broadcast_axis_NoDefault.no_default) Align two objects on their axes with the specified join method.Join method is specified for each axis Index.Parameters: otherDataFrame or Series join{‘outer’, ‘inner’, ‘left’, ‘right’}, default ‘outer’ Type of alignment to be performed.left: use only keys from left frame, preserve key order.right: use only keys from right frame, preserve key order.outer: use union of keys from both frames, sort keys lexicographically.inner: use intersection of keys from both frames, preserve the order of the left keys.axisallowed axis of the other object, default None Align on index (0), columns (1), or both (None).levelint or level name, default None Broadcast across a level, matching Index values on the passed MultiIndex level.copybool, default True Always returns new objects. If copyFalse and no reindexing is required then original objects are returned.NoteThe copy keyword will change behavior in pandas 3.0. Copy-on-Write will be enabled by default, which means that all methods with a copy keyword will use a lazy copy mechanism to defer the copy and ignore the copy keyword. The copy keyword will be removed in a future version of pandas.You can already get the future behavior and improvements through enabling copy on write pd.options.mode.copy_on_write Truefill_valuescalar, default np.nan Value to use for missing values. Defaults to NaN, but can be any “compatible” value.method{‘backfill’, ‘bfill’, ‘pad’, ‘ffill’, None}, default None Method to use for filling holes in reindexed Series:pad / ffill: propagate last valid observation forward to next valid.backfill / bfill: use NEXT valid observation to fill gap.Deprecated since version 2.1.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.Deprecated since version 2.1.fill_axis{0 or ‘index’} for Series, {0 or ‘index’, 1 or ‘columns’} for DataFrame, default 0 Filling axis, method and limit.Deprecated since version 2.1.broadcast_axis{0 or ‘index’} for Series, {0 or ‘index’, 1 or ‘columns’} for DataFrame, default None Broadcast values along this axis, if aligning two objects of different dimensions.Deprecated since version 2.1.Returns: tuple of (Series/DataFrame, type of other) Aligned objects. 189-2、参数 189-2-1、other(必须)Series或DataFrame表示需要与调用该方法的对象对齐的另一个对象。 189-2-2、join(可选默认值为outer){outer, inner, left, right}指定对齐方式。 189-2-2-1、outer: 返回两个对象的并集包含所有索引。 189-2-2-2、inner: 返回两个对象的交集仅包含共同的索引。 189-2-2-3、left: 返回左侧对象的所有索引缺失的右侧对象的索引用NaN填充。 189-2-2-4、right: 返回右侧对象的所有索引缺失的左侧对象的索引用NaN填充。 189-2-3、axis(可选默认值为None)整数或字符串仅在DataFrame中有效指明对齐的轴0表示行1表示列。 189-2-4、level(可选默认值为None)整数或字符串如果对象是多层索引可以使用此参数指定对齐的层次。 189-2-5、copy(可选默认值为None)如果为True则返回的对象会复制如果为False则返回的对象可能共享数据如果为None则根据数据的情况决定是否复制。 189-2-6、fill_value(可选默认值为None)标量值如果需要填充缺失的值可以指定一个填充值。 189-2-7、method(可选)字符串指定用于填充缺失数据的方法如pad(前向填充)或者backfill(后向填充)如果不提供默认不填充。 189-2-8、limit(可选)整数用于限制填充的最大数量。 189-2-9、fill_axis(可选)整数或字符串指定用于填充缺失值的轴仅在DataFrame中有效。 189-2-10、broadcast_axis(可选)整数或字符串指定用于广播操作的轴。 189-3、功能 对齐两个对象使它们的索引对齐并允许用户选择如何处理缺失的值。 189-4、返回值 返回一个元组包含对齐后的两个对象形如(left, right) left是对齐后的左侧对象。right是对齐后的右侧对象。 如果fill_value被指定而某些索引无法对齐则缺失的部分将被填充为指定的值。 189-5、说明 使用场景 189-5-1、数据合并与连接在处理来自不同数据源的数据时可能需要将它们合并成一个统一的格式使用align可以确保所有数据都以相同的索引对齐从而方便后续处理。 189-5-2、时间序列分析在时间序列数据中不同的时间序列可能会有不同的时间索引使用align方法可以对齐它们使得每个时间点的值能够方便地进行比较和计算。 189-5-3、数据补齐与填充当某些数据缺失时可以使用align方法结合fill_value进行补齐确保后续分析时不会因为缺失值而出现错误。 189-5-4、计算与比较在进行计算(如差异计算、比例计算等)时需要对齐各个数据列的索引使用align方法可以保证参与计算的数据都是对齐的从而得到合理的结果。 189-5-5、处理多层索引对于具有多层索引的Series或DataFrame可以利用level参数对特定层次进行对齐便于复杂数据结构的操作。 189-5-6、数据清理在清理数据时需要处理不一致的索引在删减或重塑数据时使用align可以确保所有列都有相同的索引结构。 189-6、用法 189-6-1、数据准备 无 189-6-2、代码示例 # 189、pandas.Series.align方法 # 189-1、合并不同客户的销售数据 import pandas as pd # 创建两个不同的销售数据 Series sales_jan pd.Series([200, 300], index[Alice, Bob]) sales_feb pd.Series([150, 400, 250], index[Alice, Charlie, Bob]) # 使用align方法对齐两个Series aligned_jan, aligned_feb sales_jan.align(sales_feb, joinouter, fill_value0) print(对齐后的1月销售数据) print(aligned_jan) print(\n对齐后的2月销售数据) print(aligned_feb) # 计算每个客户在1月和2月的销售总额 total_sales aligned_jan aligned_feb print(\n客户总销售额) print(total_sales, end\n\n)# 189-2、时间序列对比 import pandas as pd # 创建两个时间序列数据Series temperature pd.Series([22, 24, 23], indexpd.date_range(2023-01-01, periods3)) humidity pd.Series([30, 32], indexpd.date_range(2023-01-01, periods2)) # 使用align方法对齐两个时间序列 aligned_temp, aligned_hum temperature.align(humidity, joininner) print(对齐后的温度数据) print(aligned_temp) print(\n对齐后的湿度数据) print(aligned_hum) # 计算温度与湿度的关系 correlation aligned_temp.corr(aligned_hum) print(f\n温度与湿度的相关性{correlation}, end\n\n)# 189-3、处理多层索引 import pandas as pd # 创建多层索引的Series index pd.MultiIndex.from_tuples([(A, 1), (A, 2), (B, 1), (B, 2)]) data1 pd.Series([10, 20, 30, 40], indexindex) index2 pd.MultiIndex.from_tuples([(A, 1), (B, 1), (B, 3)]) data2 pd.Series([5, 25, 15], indexindex2) # 对齐多层索引的Series aligned_data1, aligned_data2 data1.align(data2, joinouter, fill_value0) print(对齐后的第一组数据) print(aligned_data1) print(\n对齐后的第二组数据) print(aligned_data2) # 计算对齐后数据的和 sum_data aligned_data1 aligned_data2 print(\n对齐后数据的和) print(sum_data, end\n\n)# 189-4、数据清理与补齐 import pandas as pd # 创建带有缺失值的Series data1 pd.Series([1, 2, None, 4], index[A, B, C, D]) data2 pd.Series([None, 2, 3, None], index[A, B, C, E]) # 对齐两个Series使用fill_value填充缺失值 aligned_data1, aligned_data2 data1.align(data2, joinouter, fill_value0) print(对齐后的数据1) print(aligned_data1) print(\n对齐后的数据2) print(aligned_data2) # 计算补齐后的总和 total aligned_data1 aligned_data2 print(\n补齐后的数据总和) print(total, end\n\n)# 189-5、数据比较 import pandas as pd # 创建两个带有不同客户的销售数据Series sales_last_month pd.Series([300, 500, 200], index[Alice, Bob, Charlie]) sales_this_month pd.Series([350, 450, 300, 100], index[Alice, Bob, David, Charlie]) # 对齐两个Series aligned_last_month, aligned_this_month sales_last_month.align(sales_this_month, joinouter, fill_value0) print(上个月的销售数据) print(aligned_last_month) print(\n这个月的销售数据) print(aligned_this_month) # 计算销售增长 sales_growth aligned_this_month - aligned_last_month print(\n销售增长(这个月 - 上个月)) print(sales_growth, end\n\n)# 189-6、索引重命名与对齐 import pandas as pd # 创建两个带有不同索引的Series data_a pd.Series([5, 10, 15], index[x, y, z]) data_b pd.Series([1, 2, 3], index[y, z, w]) # 重命名索引以便于理解 data_a.index [Item_A1, Item_A2, Item_A3] data_b.index [Item_B1, Item_B2, Item_B3] # 使用align方法对齐 aligned_a, aligned_b data_a.align(data_b, joinouter, fill_value0) print(对齐后的数据A) print(aligned_a) print(\n对齐后的数据B) print(aligned_b) # 计算A和B的和 total_data aligned_a aligned_b print(\n对齐后数据A和B的和) print(total_data, end\n\n)# 189-7、填补缺失数据 import pandas as pd # 创建一个带有缺失值的Series series_a pd.Series([1, 2, 3, None], index[A, B, C, D]) series_b pd.Series([None, 2, None, 4, 5], index[A, B, C, E, F]) # 对齐两个Series使用fill_value填充缺失值 aligned_a, aligned_b series_a.align(series_b, joinouter, fill_value0) print(对齐后的数据A) print(aligned_a) print(\n对齐后的数据B) print(aligned_b) # 计算合并后的序列总和 filled_data aligned_a aligned_b print(\n填补缺失值后的数据总和) print(filled_data, end\n\n)# 189-8、在数据科学项目中的应用 import pandas as pd # 创建Product价格数据和销量数据 prices pd.Series([100, 150, 200], index[Product_A, Product_B, Product_C]) sales pd.Series([10, 5, 8, 3], index[Product_A, Product_B, Product_D, Product_C]) # 对齐价格和销量数据 aligned_prices, aligned_sales prices.align(sales, joinouter, fill_value0) print(对齐后的价格数据) print(aligned_prices) print(\n对齐后的销量数据) print(aligned_sales) # 计算每个产品的销售收入 revenue aligned_prices * aligned_sales print(\n每个产品的销售收入) print(revenue, end\n\n) 189-6-3、结果输出 # 189、pandas.Series.align方法 # 189-1、合并不同客户的销售数据 # 对齐后的1月销售数据 # Alice 200.0 # Bob 300.0 # Charlie 0.0 # dtype: float64 # # 对齐后的2月销售数据 # Alice 150 # Bob 250 # Charlie 400 # dtype: int64 # # 客户总销售额 # Alice 350.0 # Bob 550.0 # Charlie 400.0 # dtype: float64# 189-2、时间序列对比 # 对齐后的温度数据 # 2023-01-01 22 # 2023-01-02 24 # Freq: D, dtype: int64 # # 对齐后的湿度数据 # 2023-01-01 30 # 2023-01-02 32 # Freq: D, dtype: int64 # # 温度与湿度的相关性0.9999999999999999# 189-3、处理多层索引 # 对齐后的第一组数据 # A 1 10.0 # 2 20.0 # B 1 30.0 # 2 40.0 # 3 0.0 # dtype: float64 # # 对齐后的第二组数据 # A 1 5.0 # 2 0.0 # B 1 25.0 # 2 0.0 # 3 15.0 # dtype: float64 # # 对齐后数据的和 # A 1 15.0 # 2 20.0 # B 1 55.0 # 2 40.0 # 3 15.0 # dtype: float64# 189-4、数据清理与补齐 # 对齐后的数据1 # A 1.0 # B 2.0 # C 0.0 # D 4.0 # E 0.0 # dtype: float64 # # 对齐后的数据2 # A 0.0 # B 2.0 # C 3.0 # D 0.0 # E 0.0 # dtype: float64 # # 补齐后的数据总和 # A 1.0 # B 4.0 # C 3.0 # D 4.0 # E 0.0 # dtype: float64# 189-5、数据比较 # 上个月的销售数据 # Alice 300.0 # Bob 500.0 # Charlie 200.0 # David 0.0 # dtype: float64 # # 这个月的销售数据 # Alice 350 # Bob 450 # Charlie 100 # David 300 # dtype: int64 # # 销售增长(这个月 - 上个月) # Alice 50.0 # Bob -50.0 # Charlie -100.0 # David 300.0 # dtype: float64# 189-6、索引重命名与对齐 # 对齐后的数据A # Item_A1 5.0 # Item_A2 10.0 # Item_A3 15.0 # Item_B1 0.0 # Item_B2 0.0 # Item_B3 0.0 # dtype: float64 # # 对齐后的数据B # Item_A1 0.0 # Item_A2 0.0 # Item_A3 0.0 # Item_B1 1.0 # Item_B2 2.0 # Item_B3 3.0 # dtype: float64 # # 对齐后数据A和B的和 # Item_A1 5.0 # Item_A2 10.0 # Item_A3 15.0 # Item_B1 1.0 # Item_B2 2.0 # Item_B3 3.0 # dtype: float64# 189-7、填补缺失数据 # 对齐后的数据A # A 1.0 # B 2.0 # C 3.0 # D 0.0 # E 0.0 # F 0.0 # dtype: float64 # # 对齐后的数据B # A 0.0 # B 2.0 # C 0.0 # D 0.0 # E 4.0 # F 5.0 # dtype: float64 # # 填补缺失值后的数据总和 # A 1.0 # B 4.0 # C 3.0 # D 0.0 # E 4.0 # F 5.0 # dtype: float64# 189-8、在数据科学项目中的应用 # 对齐后的价格数据 # Product_A 100.0 # Product_B 150.0 # Product_C 200.0 # Product_D 0.0 # dtype: float64 # # 对齐后的销量数据 # Product_A 10 # Product_B 5 # Product_C 3 # Product_D 8 # dtype: int64 # # 每个产品的销售收入 # Product_A 1000.0 # Product_B 750.0 # Product_C 600.0 # Product_D 0.0 # dtype: float64 190、pandas.Series.case_when方法 190-1、语法 # 190、pandas.Series.case_when方法 pandas.Series.case_when(caselist) Replace values where the conditions are True.Parameters: caselistA list of tuples of conditions and expected replacements Takes the form: (condition0, replacement0), (condition1, replacement1), … . condition should be a 1-D boolean array-like object or a callable. If condition is a callable, it is computed on the Series and should return a boolean Series or array. The callable must not change the input Series (though pandas doesnt check it). replacement should be a 1-D array-like object, a scalar or a callable. If replacement is a callable, it is computed on the Series and should return a scalar or Series. The callable must not change the input Series (though pandas doesnt check it).New in version 2.2.0.Returns: Series 190-2、参数 190-2-1、caselist(必须)一个包含条件和值的列表每个元素都是一个元组(condition, value)其中condition是一个返回布尔值的表达式或函数用于判断条件是否满足value是当条件满足时返回的值。 190-3、功能 根据一系列条件来设置Series中每个元素的值并返回一个新的Series。 190-4、返回值 返回一个新的Series对象。 190-5、说明 无 190-6、用法 190-6-1、数据准备 无 190-6-2、代码示例 # 190、pandas.Series.case_when方法 import pandas as pd c pd.Series([6, 7, 8, 9], namec) a pd.Series([0, 0, 1, 2]) b pd.Series([0, 3, 4, 5]) c.case_when(caselist[(a.gt(0), a), (b.gt(0), b)]) print(c) 190-6-3、结果输出 # 190、pandas.Series.case_when方法 # 0 6 # 1 7 # 2 8 # 3 9 # Name: c, dtype: int64 二、推荐阅读 1、Python筑基之旅 2、Python函数之旅 3、Python算法之旅 4、Python魔法之旅 5、博客个人主页
http://www.w-s-a.com/news/124776/

相关文章:

  • 建设银行总行网站alexa排名与什么有关系
  • 阿里云服务器发布网站收款网站怎么建设
  • 开发东莞网站制作公司做网站优化步骤
  • 网站版权信息的正确写法如何制作网络游戏
  • 郑州移动端网站建设如何在网上推广自己的公司
  • 企业建站源码系统破解网站后台
  • 石家庄网站开发报价企业注册资本代表什么
  • 招商平台公司宁波seo教程推广平台
  • 哪些网站可以做房产推广垂直门户网站都有什么
  • 不得不知道的网站金石项目管理软件
  • 怎么恢复网站数据库网站开发作业代做
  • 哪里建设网站最好用中国第五冶金建设公司医院网站
  • 雄安网建 网站建设订餐网站建设
  • 广州视频网站建站公司网站 体系
  • 青浦门户网站网站推广烟台公司电话
  • 湖北荆门建设银行网站wordpress购物模板下载
  • 学ui+wordpress模板北京推广优化
  • 建分类网站得花多少钱深圳设计网站开发
  • 网站集群建设和网站集约化百度商桥怎么绑定网站
  • 青岛模板网站建设价格网络品牌网站建设
  • 网站建设的几大要素网站的做网站的公司
  • 怎么登陆自己的公司网站垂直电商网站建设
  • 温州微网站制作哪里有许昌网站建设哪家最好
  • 中国中小企业网站官网网页制作工具按其制作方式分 可以分为
  • 做资源下载网站违法吗河南企业做网站
  • 网站开发总体功能设计网站建设 北京昌平
  • 辽宁省高等级公路建设局网站书画院网站建设方案
  • 本地生活网站 源码重庆本地网站有哪些
  • 企业网站域名服务器国外html响应式网站
  • 东莞网站建设策划企业网站推广策划方法