Question
Asked By – niedakh
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?
Now we will see solution for issue: Creating a zero-filled pandas data frame
Answer
You can try this:
d = pd.DataFrame(0, index=np.arange(len(data)), columns=feature_list)
This question is answered By – Shravan
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0