Skip to content

Infinite Couch

Let's talk Product and AI

  • About Me
  • AI/ML Select Portfolio
  • Writing
  • Speaking
  • TIL Journal

Category: Python

Unnest (explode) a column of list in Pandas

8 Oct 20218 Oct 2021 ~ Harini Kannan ~ Leave a comment

In python, when you have a list of lists and convert it directly to a pandas dataframe, you get columns of lists. This may seem overwhelming, but fear not! Pandas comes to our rescue once again - use pandas.DataFrame.explode() import pandas as pd df = pd.DataFrame({'col1': [[0, 1, 2], 'foo', [], [3, 4]], 'col2': 1, … Continue reading Unnest (explode) a column of list in Pandas

Blog at WordPress.com.
  • Subscribe Subscribed
    • Infinite Couch
    • Already have a WordPress.com account? Log in now.
    • Infinite Couch
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...