Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

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?

1 Answer

0 votes
by (41.4k points)

A better way to create a zero-filled pandas data frame of a given size:

d = pd.DataFrame(0, index=np.arange(len(data)), columns=feature_list)

Browse Categories

...