Great approach, @yanisleidi-rodriguez! Another way to achieve cbind in Python is by leveraging Python’s built-in zip function. This method is useful when working with lists before converting them into a DataFrame.
import pandas as pd
test1 = pd.DataFrame([1, 2, 3, 4, 5])
test2 = pd.DataFrame([4, 2, 1, 3, 7])
combined_data = list(zip(test1[0], test2[0]))
test3 = pd.DataFrame(combined_data, columns=['a', 'b'])
print(test3)
Using zip can be more efficient when handling lists or different data structures before bringing them into pandas. It’s a clean way to replicate cbind in Python.