Skip to content
Advertisement

How to create a pandas dataframe where columns are filled with random strings?

I want to create a Pandas dataframe with 2 columns and x number rows that contain random strings.

I have found code to generate a pandas dataframe with random ints and a random stringer generator. I still don’t see a clear path to create a pandas data frame with random strings.

Code for random int dataframe

JavaScript

Code for random strings

JavaScript

I would like destiredDataframe.head() to output two columns of random text and x number of rows.

Advertisement

Answer

Try this:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement