有一个dicts d列表,其中x是一个嵌入式列表,例如, d = [{"name":"Python", "x":[0,1,2,3,4,5]}, # x has 300 elements
{"name":"C++", "x":[0,1,0,3,4,4]},
{"name":"Java","x":[0,4,5,6,1]}]我希望将d转换为Dataframe,并为添加的列名前缀为"abc“的x中的每个元素自动添加列,e,g., df.columns = ["name", "abc0", "abc1", ..., "abc300"]我正在寻找一种有效的方法,因为d有很多缺点。当我手动添加列时,Python说 PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
|