Predictive Hacks

How to Convert a Pandas Series to Data Frame

Pandas has a method (.to_frame()) to convert a Series to Data Frame. We will create a sample Pandas Data Frame:

import pandas as pd
df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]})

Let’s call column B which is a Series.


We can easily convert it to Data Frame by running:


Another approach, not the most efficient though, is to run:


Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore


Image Captioning with HuggingFace

Image captioning with AI is a fascinating application of artificial intelligence (AI) that involves generating textual descriptions for images automatically.


Intro to Chatbots with HuggingFace

In this tutorial, we will show you how to use the Transformers library from HuggingFace to build chatbot pipelines. Let’s