excel标签计数python
时间: 2023-10-01 18:08:42 浏览: 61
可以使用 Python 中的 pandas 库来实现 Excel 标签计数。具体实现步骤如下:
1. 导入 pandas 库
```python
import pandas as pd
```
2. 读取 Excel 文件
```python
df = pd.read_excel('your_excel_file.xlsx')
```
3. 获取所有标签
```python
all_tags = df.columns.tolist()
```
4. 统计标签出现次数
```python
tag_count = {}
for tag in all_tags:
if tag not in tag_count:
tag_count[tag] = 1
else:
tag_count[tag] += 1
```
5. 输出标签和出现次数
```python
for tag, count in tag_count.items():
print(tag, count)
```
完整代码如下:
```python
import pandas as pd
df = pd.read_excel('your_excel_file.xlsx')
all_tags = df.columns.tolist()
tag_count = {}
for tag in all_tags:
if tag not in tag_count:
tag_count[tag] = 1
else:
tag_count[tag] += 1
for tag, count in tag_count.items():
print(tag, count)
```
其中,`your_excel_file.xlsx` 是你的 Excel 文件名。