niedakh niedakh - 1 year ago 223
Python Question

Creating a zero-filled pandas data frame

What is the best way to create a zero-filled pandas data frame of a given size?

I have used:

zero_data = np.zeros(shape=(len(data),len(feature_list)))
d = pd.DataFrame(zero_data, columns=feature_list)

Is there a better way to do it?

Answer Source

You can try this:

d = pd.DataFrame(0, index=np.arange(len(data)), columns=feature_list)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download