Answers for "create empty dataframe with just column names"

R
2

pandas empty dataframe with column names

# Create empty dataframe with column names
df = pd.DataFrame(columns=['dog_name','dog_age']) 
# Create some Lists to populate df
dogNames = ['Blue','Atticus'] 
dogAges = [2,8] 
# loop through the lists
for n in range(0,1): 
	df.loc[n] = [dogNames[n], dogAges[n]]
Posted by: Guest on August-21-2021
-1

Create empty DataFrame with only column names in R

# created data frame with 5 variables, and no rows
columns= c("id","names","address","phone","aadhar no") 
myData = data.frame(matrix(nrow = 0, 
                           ncol = length(columns))) 
colnames(myData) = columns
Posted by: Guest on July-27-2021

Code answers related to "create empty dataframe with just column names"

Browse Popular Code Answers by Language