如何修改定义的函数来计算想要的输出(Pandas)

2023-12-28

我试图通过在以下条件下对“name”、“val_id”和“fac_id”列进行三重循环来计算以下“new_field”列。

1.在每个“val_id”循环中,如果“product”==“CL”,则“val_against”和“our_val_amt”的最小值,例如min( val_against (134), our_val_amt (424)) 因此 'NEW FIELD' = 134。此外,如果 new_field 的总和超过“our_val_amt”,则从“our_val_amt”中减去它。例如对于 val_id“xx4”,(200 + 300 + 50) = 550 超过 our_val_amt = 510,因此 NEW FILED = 510 - 500(即此总和超过 our_val_amt 后的 200 + 300)= 10。

2.如果产品!='CL'并且位于同一'val_id'组中。从“our_val_amt”中减去的余数将插入“new_field”中。例如“our_val_amt”(424) - 来自步骤 1 (134) = 290。这插入到“新字段”上方。

如果 [product] 没有“CL”,则只需在每个 [val_id] 之间传播 [our_val_amt]。例如 val_id = 'xx7' our_val_amt =700 这分布在插入的第一行 (650) 中,然后将剩下的 700 - 650 = 50 插入到下一行中,根据示例,以下为 0。

3. 对 val_id xx2 重复步骤。 CL = 104 和 XL = 472 - 104 = 368 的新字段计算。

目前,'name' - compx(row 0 - 9) 的输出可以正常工作,并且开始无法正确计算。我也不确定这段代码是如何工作的,因为我是 Pandas 的新手,并且很感激是否有人可以解释程序如何思考定义的函数。

df = pd.DataFrame(data=[["compx","xx1","yy1",424,418,"XL"],["compx","xx1","yy2",424,134,"CL"],["compx","xx2","yy3",472,60,"DL"],["compx","xx2","yy4",472,104,"CL"], ["compx", "xx3", "yy5", 490, 50, "XL"], ["compx", "xx3", "yy6", 490, 500, "CL"], ["compx", "xx3", "yy7", 490, 200, "DL"], ["compx", "xx4", "yy8", 510, 200, "CL"], ["compx", "xx4", "yy9", 510, 300, "CL"], ["compx", "xx4", "yy10", 510, 50, "CL"], ["compy", "xx5", "yy11", 510, 200, "CL"], ["compy", "xx5", "yy12", 510, 300, "CL"], ["compy", "xx5", "yy12", 510, 50, "CL"], ["compy", "xx5", "yy13", 510, 30, "DL"], ["compz", "xx6", "yy14", 350, 200, "CL"], ["compz", "xx6", "yy15", 350, 100, "CL"], ["compz", "xx6", "yy16", 350, 50, "XL"], ["compz", "xx6", "yy17", 350, 50, "DL"], ["compz", "xx7", "yy18", 700, 650, "DL"], ["compz", "xx7", "yy19", 700, 200, "DL"], ["compz", "xx7", "yy20", 700, 400, "XL"] ], columns=["name","val_id","fac_id","our_val_amt","val_against","product"])
df


# Compute tuple of "our_val_amt", "val_against" and "product" for easy processing as one column. It is hard to process multiple columns with "transform()".
df["the_tuple"] = df[["our_val_amt", "val_against", "product"]].apply(tuple, axis=1)

def compute_new_field_for_cl(g):
  # df_g is a tuple ("our_val_amt", "val_against", "product") indexed as (0, 1, 2).
  df_g = g.apply(pd.Series)
  df_g["new_field"] = df_g.apply(lambda row: min(row[0], row[1]) if row[2] == "CL" else 0, axis=1)
  df_g["cumsum"] = df_g["new_field"].cumsum()
  df_g["new_field"] = df_g.apply(lambda row: 0 if row["cumsum"] > row[0] else row["new_field"], axis=1)
  df_g["max_cumsum"] = df_g["new_field"].cumsum()
  df_g["new_field"] = df_g.apply(lambda row: row[0] - row["max_cumsum"] if row["cumsum"] > row[0] else row["new_field"], axis=1)
  return df_g["new_field"]

# Apply above function and compute new field values for "CL".
df["new_field"] = df.groupby("val_id")[["the_tuple"]].transform(compute_new_field_for_cl)

# Re-compute tuple of "our_val_amt", "new_field" and "product".
df["the_tuple"] = df[["our_val_amt", "new_field", "product"]].apply(tuple, axis=1)

def compute_new_field_for_not_cl(g):
  # df_g is a tuple ("our_val_amt", "new_field", "product") indexed as (0, 1, 2).
  df_g = g.apply(pd.Series)
  result_sr = df_g.where(df_g[2] != "CL")[0] - df_g[df_g[2] == "CL"][1].sum()
  result_sr = result_sr.fillna(0) + df_g[1]
  return result_sr

# Apply above function and compute new field values for "CL".
df["new_field"] = df.groupby("val_id")[["the_tuple"]].transform(compute_new_field_for_not_cl)

df = df.drop("the_tuple", axis=1)
df

试图实现数据集和new_field输出。

name    |val_id |fac_id     |   our_val_amt |   val_against |   product |   new_field
compx   |   xx1 |   yy1     |   424         |   418         |   XL      |   290
compx   |   xx1 |   yy2     |   424         |   134         |   CL      |   134
compx   |   xx2 |   yy3     |   472         |   60          |   DL      |   368
compx   |   xx2 |   yy4     |   472         |   104         |   CL      |   104
compx   |   xx3 |   yy5     |   490         |   50          |   XL      |   0
compx   |   xx3 |   yy6     |   490         |   500         |   CL      |   490
compx   |   xx3 |   yy7     |   490         |   200         |   DL      |   0
compx   |   xx4 |   yy8     |   510         |   200         |   CL      |   200
compx   |   xx4 |   yy9     |   510         |   300         |   CL      |   300
compx   |   xx4 |   yy10    |   510         |   50          |   CL      |   10
compy   |   xx5 |   yy11    |   510         |   200         |   CL      |   200
compy   |   xx5 |   yy12    |   510         |   300         |   CL      |   300
compy   |   xx5 |   yy12    |   510         |   50          |   CL      |   10
compy   |   xx5 |   yy13    |   510         |   30          |   DL      |   0
compz   |   xx6 |   yy14    |   350         |   200         |   CL      |   200
compz   |   xx6 |   yy15    |   350         |   100         |   CL      |   100
compz   |   xx6 |   yy16    |   350         |   50          |   XL      |   50
compz   |   xx6 |   yy17    |   350         |   50          |   DL      |   0
compz   |   xx7 |   yy18    |   700         |   650         |   DL      |   650
compz   |   xx7 |   yy19    |   700         |   200         |   DL      |   50
compz   |   xx7 |   yy20    |   700         |   400         |   XL      |   0

我当前获得的数据集和 new_field 输出

name    |val_id |fac_id     |   our_val_amt |   val_against |   product |   new_field
compx   |   xx1 |   yy1     |   424         |   418         |   XL      |   290
compx   |   xx1 |   yy2     |   424         |   134         |   CL      |   134
compx   |   xx2 |   yy3     |   472         |   60          |   DL      |   368
compx   |   xx2 |   yy4     |   472         |   104         |   CL      |   104
compx   |   xx3 |   yy5     |   490         |   50          |   XL      |   0
compx   |   xx3 |   yy6     |   490         |   500         |   CL      |   490
compx   |   xx3 |   yy7     |   490         |   200         |   DL      |   0
compx   |   xx4 |   yy8     |   510         |   200         |   CL      |   200
compx   |   xx4 |   yy9     |   510         |   300         |   CL      |   300
compx   |   xx4 |   yy10    |   510         |   50          |   CL      |   10
compy   |   xx5 |   yy11    |   510         |   200         |   CL      |   200
compy   |   xx5 |   yy12    |   510         |   300         |   CL      |   300
compy   |   xx5 |   yy12    |   510         |   50          |   CL      |   10
compy   |   xx5 |   yy13    |   510         |   30          |   DL      |   10
compz   |   xx6 |   yy14    |   350         |   200         |   CL      |   200
compz   |   xx6 |   yy15    |   350         |   100         |   CL      |   100
compz   |   xx6 |   yy16    |   350         |   50          |   XL      |   50
compz   |   xx6 |   yy17    |   350         |   50          |   DL      |   50
compz   |   xx7 |   yy18    |   700         |   650         |   DL      |   700
compz   |   xx7 |   yy19    |   700         |   200         |   DL      |   700
compz   |   xx7 |   yy20    |   700         |   400         |   XL      |   700

该代码在存在多个非 CL 产品并且our_val_amt必须进行传播,以便最后几种产品可以得到0价值。我在上一个/上一个问题中询问了这个用例;但没有得到答复。您可能会遇到一些像这样的极端情况,需要执行全面的测试。

以下是更新后的逻辑。在每个处理行之前添加注释以解释其作用。

df = pd.DataFrame(data=[["compx","xx1","yy2",424,134,"CL",134],["compx","xx1","yy1",424,418,"XL",290],["compx","xx2","yy4",472,104,"CL",104],["compx","xx2","yy3",472,60,"DL",368],["compx","xx3","yy6",490,500,"CL",490],["compx","xx3","yy5",490,50,"XL",0],["compx","xx3","yy7",490,200,"DL",0],["compx","xx4","yy8",510,200,"CL",200],["compx","xx4","yy9",510,300,"CL",300],["compx","xx4","yy10",510,50,"CL",10],["compy","xx5","yy11",510,200,"CL",200],["compy","xx5","yy12",510,300,"CL",300],["compy","xx5","yy12",510,50,"CL",10],["compy","xx5","yy13",510,30,"DL",0],["compz","xx6","yy14",350,200,"CL",200],["compz","xx6","yy15",350,100,"CL",100],["compz","xx6","yy16",350,50,"XL",50],["compz","xx6","yy17",350,50,"DL",0],["compz","xx7","yy18",700,650,"DL",650],["compz","xx7","yy19",700,200,"DL",50],["compz","xx7","yy20",700,400,"XL",0]], columns=["name","val_id","fac_id","our_val_amt","val_against","product","new_field_expected"])


# Compute tuple of "our_val_amt", "val_against" and "product" for easy processing as one column. It is hard to process multiple columns with "transform()".
df["the_tuple"] = df[["our_val_amt", "val_against", "product"]].apply(tuple, axis=1)

def compute_new_field_for_cl(g):
  # df_g is a tuple ("our_val_amt", "val_against", "product") indexed as (0, 1, 2).
  df_g = g.apply(pd.Series)
  df_g["new_field"] = df_g.apply(lambda row: min(row[0], row[1]) if row[2] == "CL" else 0, axis=1)
  # Cumulative sum for comparison
  df_g["cumsum"] = df_g["new_field"].cumsum()
  # Previous row's sum for comparison
  df_g["cumsum_prev"] = df_g["cumsum"].shift(periods=1)
  # if our_val_amt >= sum then use min(our_val_amt, val_against)
  # else if our_val_amt < sum then take partial of first record such that our_val_amt == sum else take `0` for the rest records
  df_g["new_field"] = df_g.apply(lambda row: 0 if row["cumsum_prev"] > row[0] else row[0] - row["cumsum_prev"] if row["cumsum"] > row[0] else row["new_field"], axis=1)
  return df_g["new_field"]

# Apply above function and compute new field values for "CL".
df["new_field"] = df.groupby("val_id")[["the_tuple"]].transform(compute_new_field_for_cl)


# Re-compute tuple of "our_val_amt", "val_against", "new_field" and "product".
df["the_tuple"] = df[["our_val_amt", "val_against", "new_field", "product"]].apply(tuple, axis=1)

def compute_new_field_for_not_cl(g):
  # df_g is a tuple ("our_val_amt", "val_against", "new_field", "product") indexed as (0, 1, 2, 3).
  df_g = g.apply(pd.Series)
  # print(df_g)
  cl_sum = df_g[df_g[3] == "CL"][2].sum()
  if cl_sum > 0:
    df_g["new_field"] = df_g.where(df_g[3] != "CL")[0] - df_g[df_g[3] == "CL"][2].sum()
    df_g["new_field"] = df_g["new_field"].fillna(df_g[2])
    # Cumulative sum for comparison
    df_g["cumsum"] = df_g["new_field"].cumsum()
    # if our_val_amt < sum then take diff (our_val_amt - sum) else take `0` for the rest records
    df_g["new_field"] = df_g.apply(lambda row: 0 if row["cumsum"] > row[0] else row["new_field"], axis=1)
  else:
    df_g["new_field"] = df_g.apply(lambda row: min(row[0], row[1]) if row[3] != "CL" else row[2], axis=1)
    # Cumulative sum for comparison
    df_g["cumsum"] = df_g["new_field"].cumsum()
    # Previous row's sum for comparison
    df_g["cumsum_prev"] = df_g["cumsum"].shift(periods=1)
    # if our_val_amt >= sum then use min(our_val_amt, val_against)
    # else if our_val_amt < sum then take partial of first record such that our_val_amt == sum else take `0` for the rest records
    df_g["new_field"] = df_g.apply(lambda row: 0 if row["cumsum_prev"] > row[0] else row[0] - row["cumsum_prev"] if row["cumsum"] > row[0] else row["new_field"], axis=1)

  return df_g["new_field"]

# Apply above function and compute new field values for "CL".
df["new_field"] = df.groupby("val_id")[["the_tuple"]].transform(compute_new_field_for_not_cl)


df = df.drop("the_tuple", axis=1)

print(df)

Output:

     name val_id fac_id  our_val_amt  val_against product  new_field_expected  new_field
0   compx    xx1    yy2          424          134      CL                 134     134.00
1   compx    xx1    yy1          424          418      XL                 290     290.00
2   compx    xx2    yy4          472          104      CL                 104     104.00
3   compx    xx2    yy3          472           60      DL                 368     368.00
4   compx    xx3    yy6          490          500      CL                 490     490.00
5   compx    xx3    yy5          490           50      XL                   0       0.00
6   compx    xx3    yy7          490          200      DL                   0       0.00
7   compx    xx4    yy8          510          200      CL                 200     200.00
8   compx    xx4    yy9          510          300      CL                 300     300.00
9   compx    xx4   yy10          510           50      CL                  10      10.00
10  compy    xx5   yy11          510          200      CL                 200     200.00
11  compy    xx5   yy12          510          300      CL                 300     300.00
12  compy    xx5   yy12          510           50      CL                  10      10.00
13  compy    xx5   yy13          510           30      DL                   0       0.00
14  compz    xx6   yy14          350          200      CL                 200     200.00
15  compz    xx6   yy15          350          100      CL                 100     100.00
16  compz    xx6   yy16          350           50      XL                  50      50.00
17  compz    xx6   yy17          350           50      DL                   0       0.00
18  compz    xx7   yy18          700          650      DL                 650     650.00
19  compz    xx7   yy19          700          200      DL                  50      50.00
20  compz    xx7   yy20          700          400      XL                   0       0.00
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何修改定义的函数来计算想要的输出(Pandas) 的相关文章

  • 安装了 32 位的 Python,显示为 64 位

    我需要运行 32 位版本的 Python 我认为这就是我在我的机器上运行的 因为这是我下载的安装程序 当我重新运行安装程序时 它会将当前安装的 Python 版本称为 Python 3 5 32 位 然而当我跑步时platform arch
  • 需要在python中找到print或printf的源代码[关闭]

    很难说出这里问的是什么 这个问题是含糊的 模糊的 不完整的 过于宽泛的或修辞性的 无法以目前的形式得到合理的回答 如需帮助澄清此问题以便重新打开 访问帮助中心 help reopen questions 我正在做一些我不能完全谈论的事情 我
  • Pandas 日期时间格式

    是否可以用零后缀表示 pd to datetime 似乎零被删除了 print pd to datetime 2000 07 26 14 21 00 00000 format Y m d H M S f 结果是 2000 07 26 14
  • 使用字典映射数据帧索引

    为什么不df index map dict 工作就像df column name map dict 这是尝试使用index map的一个小例子 import pandas as pd df pd DataFrame one A 10 B 2
  • 立体太阳图 matplotlib 极坐标图 python

    我正在尝试创建一个与以下类似的简单的立体太阳路径图 http wiki naturalfrequent com wiki Sun Path Diagram http wiki naturalfrequency com wiki Sun Pa
  • 如何使用 Pandas、Numpy 加速 Python 中的嵌套 for 循环逻辑?

    我想检查一下表的字段是否TestProject包含了Client端传入的参数 嵌套for循环很丑陋 有什么高效简单的方法来实现吗 非常感谢您的任何建议 def test parameter a list parameter b list g
  • 在Python中连接反斜杠

    我是 python 新手 所以如果这听起来很简单 请原谅我 我想加入一些变量来生成一条路径 像这样 AAAABBBBCCCC 2 2014 04 2014 04 01 csv Id TypeOfMachine year month year
  • Python beautifulsoup 仅限 1 级文本

    我看过其他 beautifulsoup 得到相同级别类型的问题 看来我的有点不同 这是网站 我正试图拿到右边那张桌子 请注意表的第一行如何展开为该数据的详细细分 我不想要那个数据 我只想要最顶层的数据 您还可以看到其他行也可以展开 但在本例
  • 从Python中的字典列表中查找特定值

    我的字典列表中有以下数据 data I versicolor 0 Sepal Length 7 9 I setosa 0 I virginica 1 I versicolor 0 I setosa 1 I virginica 0 Sepal
  • 如何在不丢失注释和格式的情况下更新 YAML 文件 / Python 中的 YAML 自动重构

    我想在 Python 中更新 YAML 文件值 而不丢失 Python 中的格式和注释 例如我想改造 YAML 文件 value 456 nice value to value 6 nice value 界面类似于 y yaml load
  • pyspark 将 twitter json 流式传输到 DF

    我正在从事集成工作spark streaming with twitter using pythonAPI 我看到的大多数示例或代码片段和博客是他们从Twitter JSON文件进行最终处理 但根据我的用例 我需要所有字段twitter J
  • 加快网络抓取速度

    我正在使用一个非常简单的网络抓取工具抓取 23770 个网页scrapy 我对 scrapy 甚至 python 都很陌生 但设法编写了一个可以完成这项工作的蜘蛛 然而 它确实很慢 爬行 23770 个页面大约需要 28 小时 我看过scr
  • Jupyter Notebook 找不到 Python 模块

    不知道发生了什么 但每当我使用 ipython 氢 原子 或 jupyter 笔记本时都找不到任何已安装的模块 我知道我安装了 pandas 但笔记本说找不到 我应该补充一点 当我正常运行脚本时 python script py 它确实导入
  • import matplotlib.pyplot 给出 AttributeError: 'NoneType' 对象没有属性 'is_interactive'

    我尝试在 Pycharm 控制台中导入 matplotlib pyplt import matplotlib pyplot as plt 然后作为回报我得到 Traceback most recent call last File D Pr
  • 仅第一个加载的 Django 站点有效

    我最近向 stackoverflow 提交了一个问题 标题为使用mod wsgi在apache上多次请求后Django无限加载 https stackoverflow com questions 71705909 django infini
  • 如何断言 Unittest 上的可迭代对象不为空?

    向服务提交查询后 我会收到一本字典或一个列表 我想确保它不为空 我使用Python 2 7 我很惊讶没有任何assertEmpty方法为unittest TestCase类实例 现有的替代方案看起来并不正确 self assertTrue
  • 在本地网络上运行 Bokeh 服务器

    我有一个简单的 Bokeh 应用程序 名为app py如下 contents of app py from bokeh client import push session from bokeh embed import server do
  • Python ImportError:无法导入名称 __init__.py

    我收到此错误 ImportError cannot import name life table from cdc life tables C Users tony OneDrive Documents Retirement retirem
  • 如何计算Python中字典中最常见的前10个值

    我对 python 和一般编程都很陌生 所以请友善 我正在尝试分析包含音乐信息的 csv 文件并返回最常听的前 n 个乐队 从下面的代码中 每听一首歌曲都是一个列表中的字典条目 格式如下 album Exile on Main Street
  • Pandas 每周计算重复值

    我有一个Dataframe包含按周分组的日期和 ID df date id 2022 02 07 1 3 5 4 2022 02 14 2 1 3 2022 02 21 9 10 1 2022 05 16 我想计算每周有多少 id 与上周重

随机推荐

  • 如何使用简单的安装后脚本扩展 distutils?

    安装模块和程序后 我需要运行一个简单的脚本 我在寻找有关如何执行此操作的直接文档时遇到了一些麻烦 看来我需要继承 distutils command install 重写一些方法并将此对象添加到安装脚本中 但具体细节有点模糊 对于这样一个简
  • 更改 Python Matplotlib 中颜色条的颜色

    我有一个代码 可以为我提供预测值与实际值作为浓度函数的散点图 数据是从 Excel csv 电子表格中提取的 这是代码 import matplotlib pyplot as plt from numpy import loadtxt da
  • TSQL 解析带有 4 个分隔符的字符串

    我正在尝试解析这个字符串 200 50 电子邮件受保护 cdn cgi l email protection 09 23 2016 07 00 00 分为 5 栏 我感到很沮丧 分隔符是管道 这些字段不固定 所以我需要使用 charinde
  • Android 2.1 以编程方式卸载 SDCard

    我有一个应用程序 它将重要数据写入 SDCard 并使用 AES 对其进行加密 稍后将由桌面应用程序使用 我注意到 如果我不从 设置 菜单中卸载 SDCard 有时文件根本不会写入 或者已损坏 在 Android 2 1 中是否可以通过编程
  • window.location.href 在 IE 11 中不起作用

    我正在使用 Jquery Ajax 作为登录表单 ajax 成功后 我使用重定向页面window location href test php 这在 Chrome firefox 和 IE9 中工作正常 但在 IE 11 中 它不起作用 我
  • Jetpack compose NavHost 防止重组屏幕

    正如你所看到的 这就是我使用 MaterialBottomNavigation 实现 NavHost 的方式 我在两者上都有很多项目Messages and Feeds屏幕 当我在两个屏幕之间导航时 它们会自动重新组合 但我不想因为那里有太
  • Bootstrap 跨度和列之间有什么区别

    我使用引导程序 但试图理解跨度和列之间的区别 example div class span4 div or div class col md 4 div 他们之间有什么区别或者他们做同样的事情 div class span4 div 是旧的
  • session_start() 有关非法字符、空会话 ID 和失败会话的问题

    所以 我意识到这是一个重复的问题然而 这显然是一个错误 而这篇文章的原始帖子已经有 5 年历史了 但也有人说这是一次恶意攻击 会话 ID 太长或包含非法字符 有效字符为 a z A Z 0 9 和 https stackoverflow c
  • DotNet 核心设置失败

    在我的 Windows 10 笔记本电脑上安装 DotNet Core 时 DotNetCore 1 0 0 RC2 VS2015Tools Preview1 运行时包安装失败 我从安装日志文件中发现了一些错误信息 网络开发工具信息 037
  • 为什么kafka集群中的单节点多broker不是首选?

    我正在尝试将卡夫卡实施到生产中 想知道为什么单节点 多代理的 kafka 实例不是首选 很少有人建议 如果在单个节点上使用多个代理 则应该为它们分配单独的磁盘空间 但这样做的原因尚不清楚 有人可以解释一下单个代理与多个代理 kafka 实例
  • libjpeg 和 .Net jpeg 编解码器在单色数据上真的有很大差异吗?

    我处理大量单色图像数据 今天早上我注意到 libjpeg 和 Net jpeg 编解码器处理单色数据的方式似乎存在显着差异 看起来使用 libjpeg 以任何质量设置保存并使用默认 Net jpeg 编解码器打开的单色图像实际上仅加载 16
  • 两个相同的字符串可以是 C# 中的两个单独的实例吗?

    在 C 中 字符串是驻留的 也就是说 如果我创建字符串foobar当第二次使用它时 C 在内存中只会有一个字符串实例 虽然我有两个引用 但它们都将指向同一个字符串实例 这就是 C 中字符串必须不可变的原因之一 现在 我的问题是 是否有可能以
  • 是否有与 System.Windows.Forms.Screen 等效的 WPF?

    我正在尝试创建一个包含整个桌面工作区域的 WPF 窗口 在 WinForms 中 我将通过获取所有边界的并集来做到这一点System Windows Forms Screen AllScreens 是否有等效类型或其他机制来获取 WPF 中
  • 如何立即取消卷曲操作?

    我在用着libcurl http curl haxx se libcurl 在 C 中 我正在调用curl easy perform在与我的用户界面分开的线程中使用增强线程 http www boost org doc libs 1 43
  • 如何打印矩阵的所有列

    我有一个Matrix总共包含 5 列 我想要做的是打印所有列Matrix不仅仅是前 2 个 如下所示 val V Matrix svd V The V factor is a local dense matrix println V 给出以
  • iOS 为什么将工具栏间隙移至键盘

    我想出了如何使用出现的键盘移动带有按钮和文本字段的工具栏 void liftMainViewWhenKeybordAppears NSNotification aNotification NSDictionary userInfo aNot
  • 分布式源代码控制 - 推送单个变更集

    正在解决一个棘手的问题 希望得到社区的一些帮助 基本上 我们的开发团队分为两个团队 比如说 红色 和 蓝色 3 repos 1 大师2 红色 gt gt 大师的克隆3 蓝色 gt gt 大师的克隆 每个开发人员都在他们工作的本地计算机上克隆
  • 获取 GNU makefile 中最后一个单词之前的单词

    我需要从最后一个之前提取单词 MAKEFILE LIST 到目前为止 我想不出比这种怪物更好的东西了 LIST a b c LAST WORD INDEX words LIST BEFORE LAST word shell echo LAS
  • 删除部分文本文件 C++

    我有一个名为 copynumbers txt 的文本文件 我需要在使用时删除数字后面的一些数字示例将是一个包含以下内容的文本文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 每个整数应占用 4 个字节空间 我想删
  • 如何修改定义的函数来计算想要的输出(Pandas)

    我试图通过在以下条件下对 name val id 和 fac id 列进行三重循环来计算以下 new field 列 1 在每个 val id 循环中 如果 product CL 则 val against 和 our val amt 的最