I have a list of 5 ranges, that I want to create a DataFrame from. The resultant DataFrame should have 10 rows & 5 columns. The values of the columns will be random numbers in the given range.
The given ranges are a mix of integers and floats, i.e. [1,31]
represents a range of integers, [4, 172.583333]
represents a range of floats.
The code below works for outputs of either integers or floats only.
How can I have an output of a mix of integers and floats together? I.e. column A holds integers, column B holds floats, column C also holds floats, D and E hold integers.
Thank you.
import numpy as np
import pandas as pd
min_max = [
[1, 31],
[4, 172.583333],
[0, 88.50561],
[4, 297],
[3, 37]]
for a, b in min_max:
df = pd.DataFrame(np.random.randint(a,b,size=(10, 5)), columns=list('ABCDE')) # to generate intergers only
df = pd.DataFrame(np.random.uniform(a,b,size=(10, 5)), columns=list('ABCDE')) # to generate floats only