我试图准确强调两个数据框之间的变化。
假设我有两个 Python Pandas 数据框:
"StudentRoster Jan-1":
id Name score isEnrolled Comment
111 Jack 2.17 True He was late to class
112 Nick 1.11 False Graduated
113 Zoe 4.12 True
"StudentRoster Jan-2":
id Name score isEnrolled Comment
111 Jack 2.17 True He was late to class
112 Nick 1.21 False Graduated
113 Zoe 4.12 False On vacation
我的目标是输出一个 HTML 表格:
- 标识已更改的行(可以是 int、float、boolean、string)
输出具有相同 OLD 和 NEW 值的行(理想情况下输出到 HTML 表中),因此消费者可以清楚地看到两个数据帧之间发生了什么变化:
"StudentRoster Difference Jan-1 - Jan-2": id Name score isEnrolled Comment 112 Nick was 1.11| now 1.21 False Graduated 113 Zoe 4.12 was True | now False was "" | now "On vacation"
我想我可以逐行逐列进行比较,但是有没有更简单的方法?