使用 pandas读取 excel 文件的数据

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/s1162276945/article/details/89422626

注意:运行代码的时候请关闭 excel 文件。

# read excel and filter the number with regular expression
import pandas as pd
import re

df = pd.read_excel('D:\\健康养生\\217种常见食物的嘌呤含量表.xlsx')
# print(df)
# print(df['foodName'])
for i in df['foodName']:
    new_str = re.sub('[0-9]', '', i)  # substitute 将数字替换为无字符
    print(new_str)

正则表达式请参考

http://www.runoob.com/python3/python3-reg-expressions.html

猜你喜欢

转载自blog.csdn.net/s1162276945/article/details/89422626