I know it’s been a while since this question was asked, but there is (at least now there is) a one-liner that is supported by the documentation:
In [4]: df
Out[4]:
label
0 (a, c, e)
1 (a, d)
2 (b,)
3 (d, e)
In [5]: df['label'].str.join(sep='*').str.get_dummies(sep='*')
Out[5]:
a b c d e
0 1 0 1 0 1
1 1 0 0 1 0
2 0 1 0 0 0
3 0 0 0 1 1
Related Contents:
- Pandas: convert categories to numbers
- Factorize a column of strings in pandas
- Convert Pandas Column to DateTime
- How are iloc and loc different?
- cartesian product in pandas
- Fast punctuation removal with pandas
- Remove duplicates by columns A, keeping the row with the highest value in column B
- Create Pandas DataFrame from txt file with specific pattern
- How to reset index in a pandas dataframe? [duplicate]
- What are the ‘levels’, ‘keys’, and names arguments for in Pandas’ concat function?
- How to convert string to datetime format in pandas python?
- Compare two DataFrames and output their differences side-by-side
- Pandas: rolling mean by time interval
- Python: get a frequency count based on two columns (variables) in pandas dataframe some row appers
- Find the max of two or more columns with pandas
- How to plot and annotate a grouped bar chart
- Large, persistent DataFrame in pandas
- Pandas: peculiar performance drop for inplace rename after dropna
- Pandas column access w/column names containing spaces
- How do I find numeric columns in Pandas?
- How to select all columns whose names start with X in a pandas DataFrame
- Concatenate a list of pandas dataframes together
- Remove reverse duplicates from dataframe
- Drop rows with all zeros in pandas data frame
- How to flatten a nested JSON recursively, with flatten_json
- Normalize columns of a dataframe
- Coalesce values from 2 columns into a single column in a pandas dataframe
- Add x and y labels to a pandas plot
- Pandas read csv file with float values results in weird rounding and decimal digits
- Convert categorical data in pandas dataframe
- Pandas Latitude-Longitude to distance between successive rows [duplicate]
- How to implement sql coalesce in pandas
- Pandas convert string to int
- How to read a .xlsx file using the pandas Library in iPython?
- Drop columns whose name contains a specific string from pandas DataFrame
- Is there a way to auto-adjust Excel column widths with pandas.ExcelWriter?
- Converting time zone pandas dataframe
- Seaborn: countplot() with frequencies
- Pandas – write Multiindex rows with to_csv
- Apply fuzzy matching across a dataframe column and save results in a new column
- Efficiently replace values from a column to another column Pandas DataFrame
- Turn Pandas Multi-Index into column
- What are Python pandas equivalents for R functions like str(), summary(), and head()?
- Convert dataframe index to datetime
- Replace value for a selected cell in pandas DataFrame without using index
- Datetime conversion – How to extract the inferred format?
- Pandas Passing Variable Names into Column Name
- Pandas Split Dataframe into two Dataframes at a specific row
- How to remove numbers from string terms in a pandas dataframe
- How to format IPython html display of Pandas dataframe?