Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

create pandas dataframe with random numbers

#using numpy's randint
df = pd.DataFrame(np.random.randint(0,100,size=(15, 4)), columns=list('ABCD'))
Comment

How to Create a Pandas DataFrame of Random Integers

"In this quick guide, we're going to create a Pandas DataFrame of random integers with arbitrary length."
import numpy as np
import pandas as pd
import string

string.ascii_lowercase

n = 5
m = 7

cols = string.ascii_lowercase[:m]

df = pd.DataFrame(np.random.randint(0, n,size=(n , m)), columns=list(cols))

df
Comment

PREVIOUS NEXT
Code Example
Python :: python random date between range 
Python :: tf 1 compatible colab 
Python :: make y axis start at 0 python 
Python :: save and load catboost model 
Python :: python auto module installer 
Python :: 2 list difference python 
Python :: input spaces seperated integers in python 
Python :: how ot split a string every fourth eter 
Python :: tkinter entry default value 
Python :: numpy fill na with 0 
Python :: how to save a png seaborn pandas 
Python :: horizontal line for pyplot 
Python :: pandas change last row 
Python :: tkinter bind to window close 
Python :: convert mp3 to wav python 
Python :: write multiple df to excel pandas 
Python :: check string similarity python 
Python :: check if a list contains an item from another list python 
Python :: count none in list python 
Python :: pip vs anaconda venv 
Python :: complex phase python 
Python :: python current date and time 
Python :: getting dummies and input them to pandas dataframe 
Python :: check python version ubuntu 
Python :: grid in pygame 
Python :: multiple variable input in python 
Python :: bmi python 
Python :: csv to numpy array 
Python :: df from numpy array 
Python :: parse youtube video id from youtube link python 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =