![](/img/trans.png)
[英]What is the Python (numpy or scipy or Pandas) equivalent for R's adjboxStats function?
[英]What is the direct python/pandas equivalent of R/caret's str function, for factors?
我特別想要一個顯示因子/分類變量水平的函數,就像R / caret中的str()一樣。
例如,在R中,我們有:
data(iris)
str(iris)
## 'data.frame': 150 obs. of 5 variables:
## $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
## $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
## $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
## $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
## $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
我將如何在python / pandas中精確地做到這一點?
無論是dataFrame.describe()
還是dataFrame.info()
都無法滿足iris$Species
。
最簡單的是
df.Species.value_counts()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.