【发布时间】:2020-09-21 11:34:59
【问题描述】:
| 1st Most Common Value | 2nd Most Common Value | 3rd Most Common Value | 4th Most Common Value | 5th Most Common Value |
|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------|
| Grocery Store | Pub | Coffee Shop | Clothing Store | Park |
| Pub | Grocery Store | Clothing Store | Park | Coffee Shop |
| Hotel | Theatre | Bookstore | Plaza | Park |
| Supermarket | Coffee Shop | Pub | Park | Cafe |
| Pub | Supermarket | Coffee Shop | Cafe | Park |
数据框的名称是 df0。如您所见,所有列中有许多重复的值。所以我想创建一个数据框,其中包含所有列中的所有唯一值及其频率。由于我想创建它的条形图,有人可以帮忙处理代码吗?
输出应该如下:
| Venues | Count |
|----------------|-------|
| Bookstore | 1 |
| Cafe | 2 |
| Coffee Shop | 4 |
| Clothing Store | 2 |
| Grocery Store | 2 |
| Hotel | 1 |
| Park | 5 |
| Plaza | 1 |
| Pub | 4 |
| Supermarket | 2 |
| Theatre | 1 |
【问题讨论】:
-
您的预期输出是什么?如果您可以不将数据粘贴为图像,那也很好
-
首先运行 fd0.describe()
-
所以基本上每列都需要
.value_counts()? -
@NYCCoder 我已经修改了我的代码,请检查并告诉我。谢谢。
-
@CeliusStingher 我已经修改了我的代码,请检查并告诉我。谢谢。
标签: python pandas numpy dataframe data-science