写一段python代码,使用pandas库,提取excel表格里面“移动电话”列中电话号码为座机的行,并删除该行数据
时间: 2024-04-29 18:25:07 浏览: 85
提取EXCEL ACCESS 手机电话号码
Sure, I can help you with that. Here's an example Python code that uses pandas to extract rows from an Excel spreadsheet where the phone number in the "移动电话" column is a landline number, and then deletes those rows:
```python
import pandas as pd
# Load the Excel spreadsheet into a pandas dataframe
df = pd.read_excel('example.xlsx')
# Filter the rows where the phone number is a landline number
landline_mask = df['移动电话'].str.startswith(('021', '010', '0755'))
df = df.loc[~landline_mask]
# Save the filtered dataframe back to the Excel file
df.to_excel('example_filtered.xlsx', index=False)
```
This code assumes that the phone numbers for landlines start with the area codes '021', '010', or '0755', but you can adjust this to match your specific requirements. Please let me know if you have any other questions!
阅读全文