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 program to convert unit 
Python :: circumference of circle 
Python :: pandas fill nan methods 
Python :: python delete dict key if exists 
Python :: python delete text in text file 
Python :: pandas change to first day 
Python :: python do nothing 
Python :: pandas pad method 
Python :: random number pythob 
Python :: how to iterate over object in python 
Python :: find the most similar rows in two dataframes 
Python :: pygame key pressed once 
Python :: delete n from textpython 
Python :: how to append list to list in python 
Python :: how to change the console background color in python 
Python :: convert a column to int pandas 
Python :: pip tensorflow 
Python :: isdigit in python 
Python :: numpy arrauy to df 
Python :: python logging basicconfig stdout 
Python :: sort a list numbers in python 
Python :: color name to hex python 
Python :: python classes 
Python :: selenium get parent element 
Python :: python color input 
Python :: python convert to percentage 
Python :: how to change plot size in matplotlib 
Python :: django clear all sessions 
Python :: Get all the numerical column from the dataframe using python 
Python :: remove empty space from string python 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =