Skip to content

Instantly share code, notes, and snippets.

View andaoba's full-sized avatar
💭
Learning Analytics

Andrés Mauricio Obando Acevedo andaoba

💭
Learning Analytics
  • Bogotá, Colombia
View GitHub Profile
@sammatuba
sammatuba / splitPandasSeriesOfTuplesIntoPandasDataframe.py
Last active November 12, 2023 14:52
quickHow: how to split a column of tuples into a pandas dataframe
# Given a pandas dataframe containing a pandas series/column of tuples B,
# we want to extract B into B1 and B2 and assign them into separate pandas series
# Method 1: (faster)
# use pd.Series.tolist() method to return a list of tuples
# use pd.DataFrame on the resulting list to turn it into a new pd.DataFrame object, while specifying the original df index
# add to the original df
import pandas as pd
import time