Adding something for the first commit

This commit is contained in:
Tom Reincke 2026-04-20 22:27:34 +02:00
commit 739e5fb775

78
test.py Normal file
View File

@ -0,0 +1,78 @@
#!/usr/bin/python3
# https://www.datacamp.com/tutorial/joining-dataframes-pandas
# Simples would be to simply join the dataframes coming from the loop, by the
# timestamp chris
import pandas as pd
a = [(1, 2), (2,3)]
b = [(1, 2), (2,3) ]
a = pd.DataFrame.from_records(a,columns=["attr1", "attr2"])
b = pd.DataFrame.from_records(b,columns=["attr3", "attr4"])
c = pd.concat([a,b], axis=1)
print(c)
## Example 2
print("###############################################")
print("###############################################")
print("###############################################")
print("###############################################")
print("###############################################")
print("###############################################")
print("###############################################")
# Merge on attribute names, I would recommend this one
a = [(1, 2), (2,3)]
b = [(1, 2, 1), (2,3, 1) ]
a = pd.DataFrame.from_records(a,columns=["attr1", "attr2"])
b = pd.DataFrame.from_records(b,columns=["attr3", "attr4", "attr1"])
c = pd.merge(a,b, on="attr1")
print(c)
print("###############################################")
print("###############################################")
print("###############################################")
print("###############################################")
print("###############################################")
print("###############################################")
print("###############################################")
a = [(1, 2), (2,3)]
b = [1 , 1]
a = pd.DataFrame.from_records(a,columns=["attr1", "attr2"])
a["something"] = b
print(a)
print("###############################################")
print("###############################################")
print("###############################################")
print("###############################################")
print("###############################################")
print("###############################################")
print("###############################################")
# This works too, but only if you have the same row size
a = [(1, 2), (2,3)]
b = [(1, 2), (2,3) ]
a = pd.DataFrame.from_records(a,columns=["attr1", "attr2"])
b = pd.DataFrame.from_records(b,columns=["attr3", "attr4"] )
a["attr3"] = b["attr3"]
print(c)