Mailing List Archive

How to store the result of df.count() as a new dataframe in Pandas?
Hello,

The result of df.count() appears to be a series object. How to store the
result of df.count() as a new dataframe in Pandas?

That is data anyhow.

Regards,

David
--
https://mail.python.org/mailman/listinfo/python-list
Re: How to store the result of df.count() as a new dataframe in Pandas? [ In reply to ]
On Tue, Oct 26, 2021 at 6:36 PM Shaozhong SHI <shishaozhong@gmail.com>
wrote:

> Hello,
>
> The result of df.count() appears to be a series object. How to store the
> result of df.count() as a new dataframe in Pandas?
>
> That is data anyhow.
>
> Regards,
>
> David
> --
> https://mail.python.org/mailman/listinfo/python-list




Have you tried something like

df_count = pd.DataFrame(df.count())
?
(Untested, but I've converted Series objects to DataFrames doing something
similar before.)
This is more of a pandas question. Why don't you ask this on stackoverflow?

https://stackoverflow.com/questions/tagged/pandas
--
https://mail.python.org/mailman/listinfo/python-list