如何从该 Dataframe df中删除None值,并将列从a转换为f作为列表
emp_no a b c d e f id
0 11390 [1, 28.4] [7, 32.2] [7, 31.3] [28, 40.7] [28, 40.0] [28, 39.6] nhvm657mjhgmjhm
1 11395 [1, 31.4] [7, 32.8] [7, None] [28, 37.3] [28, 39.2] [28, None] hjgj6hgjgghjjh
2 11397 [1, 33.0] [7, 33.1] [7, 31.5] [28, None] [28, 40.4] [28, 41.0] fjyj676hjhjhg
3 11522 [1, 34.0] [7, 32.4] [7, 32.6] [28, 45.4] [28, 45.9] [28, 46.9] 65hjhgjghj766
4 11525 [1, 32.7] [7, 31.9] [7, 32.0] [28, None] [28, 44.4] [28, 46.1] ftghjy6757hjh
输出应为:
df[0] = [[1, 28.4],[7, 32.2],[7, 31.3],[28, 40.7],[28, 40.0],[28, 39.6]]
df[1] = [[1, 31.4],[7, 32.8],[28, 37.3],[28, 39.2]]
df[2] = [[1, 33.0],[7, 33.1],[7, 31.5],[28, 40.4],[28, 41.0]]
df[3] = [[1, 34.0],[7, 32.4],[7, 32.6],[28, 45.4],[28, 45.9],[28, 46.9]]
df[4] = [[1, 32.7] [7, 31.9],[7, 32.0],[28, 44.4],[28, 46.1]]
3条答案
按热度按时间v7pvogib1#
这其实不是Pandas的问题,这里只需要列表理解:
输出量:
cgfeq70w2#
Pandas
wrrgggsh3#