Reputation: 557
I am trying to convert df
to just get the length of it in a new dataframe.
Which is what I do, but then this dataframe does not have a header.
How do I add a header to this length?
df = df.append(df_temp, ignore_index=True, sort=True)
df = len(df)
when I print df
i get the # of records but no header. How can I add a header to this?
Upvotes: 0
Views: 477
Reputation: 36
If you want to your df
have the column name and the lenght then you shuld try something like:
labels = {}
for column in temp_df.columns:
labels[column] = len(temp_df[column].dropna())
print(labels)
Here labels
would be a dictionary with the column name as a key and the number of rows as a value.
Upvotes: 1