大家好,我需要你们的帮助来获得熊猫数据帧中的预期输出/结果。我有一个包含如下所示数据的文件:
Time/Location Value
Location1
Today 3
Next day 0
Weekend -6
Next week 1
Location2
Today 2
Next day -1
Weekend 3
Next week 2
Location3
Today 1
Next day 3
Weekend 1
Next week -1
Location4
Today 3
Next day 2
Weekend 5
Next week 4
Location5
Today 4
Next day 2
Weekend 3
Next week 1
Location6
Today -1
Next day 3
Weekend 3
Next week 2
并期望输出如下,这将为“位置”创建新列
Location Time Value
Location1 Today 3
Location1 Next day 0
Location1 Weekend -6
Location1 Next week 1
Location2 Today 2
Location2 Next day -1
Location2 Weekend 3
Location2 Next week 2
Location3 Today 1
Location3 Next day 3
Location3 Weekend 1
Location3 Next week -1
Location4 Today 3
Location4 Next day 2
Location4 Weekend 5
Location4 Next week 4
Location5 Today 4
Location5 Next day 2
Location5 Weekend 3
Location5 Next week 1
Location6 Today -1
Location6 Next day 3
Location6 Weekend 3
Location6 Next week 2
谢谢你的帮助/建议……请
谢谢大家!
如果} 替换第一列中缺少的值,并通过} 和
Value
中不存在缺少的值,请使用^{ffill
向前填充,最后通过^{rename
列删除行:另一个想法是通过^{} 测试第一列中的值,并通过^{} 过滤:
相关问题 更多 >
编程相关推荐