[Pandas-dev] Series.value_counts and length of series

Vicki Brown vlb at cfcl.com
Sun Sep 8 16:16:48 EDT 2019


Hi -

I have a dataset:

	<class 'pandas.core.frame.DataFrame'>
	RangeIndex: 237061 entries, 0 to 237060
	Data columns (total 23 columns):
	Date                                 237061 non-null datetime64[ns]
	Station Number                       237061 non-null object
	Depth                                237061 non-null float64
	...

For three of the columns, I have calculated value_counts. 
For two of those, the result includes the length of the set; for the third, it does not.

Why not?

	In [1]: dt = wq_df['Date']
	dt_counts = dt.value_counts()

	In [2]: st = wq_df['Station Number']
	st_counts = st.value_counts()

	In [3]: dp = wq_df['Depth']
	dp_counts = dp.value_counts()

	In [4]: dt_counts

	Out[4]: 1969-04-10     21
		...
		Name: Date, Length: 1172, dtype: int64

	In [5]: st_counts
	Out[5]: 18      16622
        	...
       		Name: Station Number, dtype: int64

	In [6]: dp_counts
	Out[6]: 0.5      1962
       		...
       		Name: Depth, Length: 99, dtype: int64



-- Vicki

Vicki Brown
cfcl.com/vlb





More information about the Pandas-dev mailing list