I know the title is not best if somebody has better idea of how to describe my problem, feel free to change it.
Code:
from collections import namedtuple
Point = namedtuple('Point', 'x y')
x1 = Point(1, 2)
x2 = Point(3, 4)
x3 = Point(6, 5)
PointWithData = namedtuple('PointWithData', 'Point1 Point2 Point3 weight description')
data = [
PointWithData(x1, x2, x3, 3.4, 'test1'),
PointWithData(x2, x3, x1, 2.1, 'test2'),
PointWithData(x3, x1, x2, 1.8, 'test3'),
]
df = pd.DataFrame(
data,
)
df
Output:
Point1 Point2 Point3 weight description
0 (1, 2) (3, 4) (6, 5) 3.4 test1
1 (3, 4) (6, 5) (1, 2) 2.1 test2
2 (6, 5) (1, 2) (3, 4) 1.8 test3
Each Point is as a tuple, but I want it as individual members.
Like this
p1_x p1_y p2_x p2_y p3_x p3_y weight description
0 1 2 3 4 6 5 3.4 test1
1 3 4 6 5 1 2 2.1 test2
2 6 5 1 2 3 4 1.8 test3