我有一个 Pandas 交易数据框:
transactions.head():
Amount Date of Transaction Description \
0 39.95 2017-03-30 Fake_Transaction_One
1 2.39 2017-04-01 Fake_Transaction_Two
2 8.03 2017-04-01 Fake_Transaction_Three
3 34.31 2017-04-01 Fake_Transaction_Four
4 10.56 2017-04-03 Fake_Transaction_Five
Purchase_Type year_month
0 Miscellaneous 2017-03
1 tool_expense 2017-04
2 food_and_domestic 2017-04
3 food_and_domestic 2017-04
4 food_and_domestic 2017-04
Run Code Online (Sandbox Code Playgroud)
我在此 DataFrame 上运行 groupby 命令:
grouped_transactions = transactions.groupby(['Purchase_Type','year_month'])['Amount'].sum()
Run Code Online (Sandbox Code Playgroud)
这会产生一个 groupby 对象:
Purchase_Type year_month
tool_expense 2017-04 72.49
Calendar_Event 2017-08 3.94
2017-12 23.92
2018-02 42.91
2018-03 10.91
Run Code Online (Sandbox Code Playgroud)
我想对此运行 groupby 命令,例如
grouped_transactions.groups.keys()
Run Code Online (Sandbox Code Playgroud)
但是我无法这样做,因为该对象不是 groupby 对象,而是一个 Series: …
EFS 文件系统临时设置为与不同可用区中的两个 EC2 实例一起使用。为启动 EFS 的区域内的每个子网自动创建安全组。该区域具有三个可用区、三个子网和三个安全组。查看安全组描述,详细了解 SG 的创建:
EFS 和 EFS 所连接的 EC2 现已全部终止/删除。但是,当尝试删除安全组时,我会收到以下每个安全组的通知:
点击“关联1个安全组”链接查看安全组sg-053f4a90837fda586无法删除的详细原因,显示关联的安全组为sg-0f481995d4e99ac12。在尝试删除 sg-0f481995d4e99ac12 时,相同的信息表明它无法删除,因为它与 sg-053f4a90837fda586 关联。因此,无法删除 sg-053f4a90837fda586,因为 sg-0f481995d4e99ac12 存在,反之亦然。
尝试同时删除两者会出现相同的问题:
我的方法有什么错误?
我有一个数据框 myDF,我希望使用其他列的条件组合将其中的一列设置为零,并使用第二个数据框 CriteriaDF 进行索引。
myDF.head():
DateTime GrossPowerMW USDateTime_string DateTime_timestamp \
0 01/01/1998 00:00 17.804 01/01/1998 00:00 1998-01-01 00:00:00
1 01/01/1998 01:00 18.751 01/01/1998 01:00 1998-01-01 01:00:00
2 01/01/1998 02:00 20.501 01/01/1998 02:00 1998-01-01 02:00:00
3 01/01/1998 03:00 22.222 01/01/1998 03:00 1998-01-01 03:00:00
4 01/01/1998 04:00 24.437 01/01/1998 04:00 1998-01-01 04:00:00
Month Day Hour GrossPowerMW_Shutdown
0 1 3 0 17.804
1 1 3 1 18.751
2 1 3 2 20.501
3 1 3 3 22.222
4 1 3 4 24.437
Run Code Online (Sandbox Code Playgroud)
标准DF: …