利用Python对Excel数据进行处理
通过本文,记录分享我利用Python对已存在的excel表格进行数据处理。
因为是没学可视化之前做的,所以都展示在后台上。
1. 功能分析
1.1加载文件夹内所有的Excel数据;
1.2 生产贡献度分析图表(以柱状图显示表格数据);
1.3提起Excel表格中指定列数据;
1.4定向筛选所需数据;
1.5多表数据统计排行;
1.6多表数据合并新excel文件。
2. 系统开发必备
2.1 系统开发环境
本系统的软件开发及运行环境具体如下:
- 操作系统:Windows7、Windows10;
- Python版本:Python3.9
- 开发工具:Pycharm
2.2 文件夹组织结构
3.导库
import os
import xlrd2 #xlrd: 对Excel进行读相关操作
import xlwt #xlwt: 对Excel进行写相关操作,且只能创建一个全新的Excel然后进行写入和保存。
import numpy
import matplotlib
from prettytable import PrettyTable #PrettyTable 是python中的一个第三方库,可用来生成美观的ASCII格式的表格
from matplotlib import pyplot as plt
4. 主函数设计
Excel数据分析师的主函数main(),主要用于实现系统的主界面。在主函数main()中,首先调用get_files_name()函数获取文件名。
get_files_name()函数代码如下:
#导入文件
def get_files_name():"""用于获取文件名:return: 返回值为文件名组成的列表"""file_list = os.listdir('./data')return file_list
然后调用load_data()函数来读取excel文件并字典方式保存。
#保存生产excel表
def load_data(file_list):"""用于读取指定的文件并保存至字典数据结构中:param file_list: 需要加载的文件列表:return: 保存了文件内容的字典"""dictory = {}for file in file_list:# 获取表格文件book = xlrd2.open_workbook('./data/'+file)# 获取表格中的所有sheetnames = book.sheet_names()# 获取第一个sheetsheet = book.sheet_by_index(0)# 获取当前表格的行数rows = sheet.nrows# 获取当前表格的列数cols = sheet.ncols# 获取表头文件,即表格第一行head = sheet.row_values(0)for row in range(rows-1):# 如果当前字典中没有该城市则创建一个if not sheet.cell_value(row+1, 0) in dictory.keys():dictory[sheet.cell_value(row+1, 0)] = {}for col in range(cols-1):dictory[sheet.cell_value(row+1, 0)][head[col+1]] = float(sheet.cell_value(row+1, col+1))return dictory
接着调用menu()函数生成功能选择菜单。
menu()函数代码如下:
# 打印菜单
def menu():print(" ----------Excel 数据分析师----------")print("{:<30}".format(" ==============功能菜单============== "))print("{:<30}".format(" 1. 显示当前数据 "))print("{:<30}".format(" 2. 以柱状图展示当前数据 "))print("{:<30}".format(" 3. 提起指定列 "))print("{:<30}".format(" 4. 定向筛选指定元素 "))print("{:<30}".format(" 5. 数据排行 "))print("{:<30}".format(" 6. 重新加载数据 "))print("{:<30}".format(" 7. 保存当前数据 "))print("{:<30}".format(" 0. 退出程序 "))print("{:<30}".format(" ==================================== "))print("{:<30}".format(" 说明:输入相应数字后按下回车选择指定功能 "))print('\n')
并且应用if语句控制各个子函数的调用,从而实现对Excel文件的选择,Excel数据的加载,选择、筛选、合并、排序和统计等功能。
主函数完整代码如下:
if __name__ == "__main__":# 导入文件files = get_files_name()data = {}print("当前data文件夹下的文件如下:")num = 1for file in files:print(num, file)num += 1while(1):index_str = input("请选择需要导入的文件序号(多个文件导入时用空格分开, 输入0则导入所有文件,输入多文件则自动合并):")index_list = index_str.split(' ')try:index_list.remove('')except:passchoice_file_list = []if index_list[0] == '0':choice_file_list = filesbreakelse:try:for item in index_list:choice_file_list.append(files[int(item)-1])except:print("输入序号有误")continueif choice_file_list:breakelse:print("输入序号有误")data = load_data(choice_file_list)print("导入数据成功\n")# 调用函数,打印菜单menu()while 1:choice = input("请选择指定功能:")if choice == '0':print("\n退出程序\n")exit()elif choice == '1':print("当前功能:显示当前数据")show_data(data)input('\n按下回车返回菜单')menu()elif choice == '2':print("当前功能:以柱状图显示数据")draw_plot(data)input('\n按下回车返回菜单')menu()elif choice == '3':print("当前功能:筛选指定列")keys = list(data[list(data.keys())[0]].keys())print("当前表格中的列如下:")num = 1for key in keys:print(num, key)num += 1choice_col_list = []while (1):index_str = input("请选择需要筛选出的列序号(多列之间用空格分开,0代表所有列):")index_list = index_str.split(' ')try:index_list.remove('')except:passchoice_file_list = []if index_list[0] == '0':choice_col_list = keysbreakelse:try:for item in index_list:choice_col_list.append(keys[int(item) - 1])except:print("输入序号有误")continueif choice_col_list:breakelse:print("输入序号有误")data = get_specified_cols(data, choice_col_list)print("筛选成功")input('\n按下回车返回菜单')menu()elif choice == '4':print("当前功能:筛选指定行")keys = list(data[list(data.keys())[0]].keys())print("当前表格中的列如下:")num = 1print(num, "城市")num += 1for key in keys:print(num, key)num += 1col = int(input("请输入需要进行筛选的数据所在的列:"))-2if col == -1:col = '城市'else:col = keys[col]op_list = ['<', '<=', '=', '>=', '>']print("比较操作符如下:")num = 1for op in op_list:print(num, op)num += 1operation = int(input("请输入比较操作符前的序号:"))-1operation = op_list[operation]value = input("请输入需要筛选的值:")data = get_specified_data(data, operation, col, value)print("筛选成功")input('\n按下回车返回菜单')menu()elif choice == '5':print("当前功能:数据排序")keys = list(data[list(data.keys())[0]].keys())print("当前表格中的列如下:")num = 1for key in keys:print(num, key) #显示当前表格中的所有的列num += 1col = int(input("请输入需要进行排序的数据所在的列:")) - 1col = keys[col]reverse = input("排序方式:\n1 从大到小排序\n2 从小到大排序\n")if reverse == '1':data = sort_data(data, col, True)elif reverse == '2':data = sort_data(data, col, False)else:print("输入有误")input('\n按下回车返回菜单')menu()elif choice == '6':# 导入文件files = get_files_name()data = {}print("当前文件夹下的文件如下:")num = 1for file in files:print(num, file)num += 1while (1):index_str = input("请选择需要导入的文件序号(多个文件导入时用空格分开, 输入0则导入所有文件,输入多文件则自动合并):")index_list = index_str.split(' ')try:index_list.remove('')except:passchoice_file_list = []if index_list[0] == '0':choice_file_list = filesbreakelse:try:for item in index_list:choice_file_list.append(files[int(item) - 1])except:print("输入序号有误")continueif choice_file_list:breakelse:print("输入序号有误")data = load_data(choice_file_list)print("导入数据成功\n")# 打印菜单menu()elif choice == '7':print("当前功能:保存数据")save(data)input('\n按下回车返回菜单')menu()else:print("请输入正确的数字")input('\n按下回车返回菜单')menu()
5.模块设计
5.1 加载文件夹内所有的Excel数据
show_data()函数通过PrettyTable 库(PrettyTable 库是python中的一个第三方库,可用来生成美观的ASCII格式的表格)将之前保存的字典数据生成表格。
#加载显示数据
def show_data(dictory):try:keys = list(dictory[list(dictory.keys())[0]].keys())except:print("当前数据为空")returnhead = ['城市']head.extend(keys)table = PrettyTable(head)for key in dictory.keys():line = [key]for key_2 in keys:line.append(dictory[key][key_2])table.add_row(line)print(table)
效果图如下:
5.2生产贡献度分析图表(以柱状图显示表格数据)
draw_plot( )函数使用了matplotlib库。通过atplotlib.rc( )来设置字体,通过plt.bar( )函数来绘制柱状图,通过plt.legend( )函数来给图添加图例。
#制作图表
def draw_plot(dictory):font = {'family': 'MicroSoft Yahei', 'weight': 'bold', 'size': 7}matplotlib.rc('font', **font) #设置中文字体# 定义三个颜色index = numpy.arange(len(dictory.keys()))color = [(256 / 256, 0 / 256, 0 / 256, 1),(0 / 256, 0 / 256, 256 / 256, 1),(0 / 256, 256 / 256, 0 / 256, 1),(0 / 256, 0 / 256, 0 / 256, 1)]first_key = list(dictory.keys())first_key = first_key[0]cols = list(dictory[first_key].keys())data = []for i in range(len(cols)):data.append([])for key in dictory.keys():for col in range(len(cols)):data[col].append(dictory[key][cols[col]])offset = -1/4for i in range(len(cols)):plt.bar(index+offset, data[i], color=color[i], width=1 / 5) #通过bar函数可以用柱状图来表达一些变量的统计分布offset += 1/4plt.xticks(index, dictory.keys())#表示刻度plt.legend(cols)#给图像加上图例plt.show()
效果图如下:
5.3提起Excel表格中指定列数据
get_specified_cols()函数根据用户在菜单输入的列名,通过字典的索引筛选出列名,加载指定列的所有数据。
#提起指定列
def get_specified_cols(dictory, col_name_list):"""筛选出指定的列:param dictory:原始字典:param col_name_list: 需要筛选出的列名,城市名默认出现:return: 筛选之后的字典"""new_dict = {}for key in dictory.keys():new_dict[key] = {}for col_name in col_name_list:new_dict[key][col_name] = dictory[key][col_name]return new_dict
效果图如下:
5.4定向筛选所需数据
get_specified_data()函数根据输入的操作符、列名以及指定的value进行筛选,比如筛选出人均GDP大于5000的,则operation = ‘>’ ;col_name = ‘人均GDP’ ; value = 500。
def get_specified_data(dictory, operation, col_name, value):"""根据输入的操作符、列名以及指定的value进行筛选,比如筛选出人均GDP大于5000的,则operation = '>', col_name = '人均GDP', value = 5000:param dictory: 原始数据:param operation: 操作符:param col_name: 需要比较的列:param value: 需要比较的值:return: 筛选之后的字典"""new_dict = {}if col_name != "城市":for key in dictory.keys():# flag用于标记是否需要添加该行value = float(value)flag = 0if operation == '>':if dictory[key][col_name] > value:flag = 1elif operation == '>=':if dictory[key][col_name] >= value:flag = 1elif operation == '=':if dictory[key][col_name] == value:flag = 1elif operation == '<=':if dictory[key][col_name] <= value:flag = 1elif operation == '<':if dictory[key][col_name] < value:flag = 1else:flag = 0if flag == 1:new_dict[key] = {}new_dict[key] = dictory[key]else:for key in dictory.keys():# flag用于标记是否需要添加该行flag = 0if operation == '>':if key > value:flag = 1elif operation == '>=':if key >= value:flag = 1elif operation == '=':if key == value:flag = 1elif operation == '<=':if key <= value:flag = 1elif operation == '<':if key < value:flag = 1else:flag = 0if flag == 1:new_dict[key] = {}new_dict[key] = dictory[key]return new_dict
效果图如下:
5.5多表数据统计排行
sort_data()函数根据key和reverse对数据进行排序。dictory: 传入的字典对象。
key: 需要排序的关键字,即哪一列。reverse: 是否从大到小排序,false即为从小到大排序,最后return 返回数据。
#数据排行
def sort_data(dictory, key, reverse):"""根据key和reverse对数据进行排序:param dictory: 传入的字典对象:param key: 需要排序的关键字,即那一列:param reverse: 是否从大到小排序,false即为从小到大排序:return:"""data = dictoryif not reverse:data = dict(sorted(data.items(), key=lambda d: d[1][key], reverse=False)) #字典的升序else:data = dict(sorted(data.items(), key=lambda d: d[1][key], reverse=True)) #字典的降序return data
效果图如下:
5.6多表数据合并生成新excel文件
该功能在主函数中实现并调用save()函数保存合并后的数据并生成新的excel文件。
while(1):index_str = input("请选择需要导入的文件序号(多个文件导入时用空格分开, 输入0则导入所有文件,输入多文件则自动合并):")index_list = index_str.split(' ')try:index_list.remove('')except:passchoice_file_list = []if index_list[0] == '0':choice_file_list = filesbreakelse:try:for item in index_list:choice_file_list.append(files[int(item)-1])except:print("输入序号有误")continueif choice_file_list:breakelse:print("输入序号有误")data = load_data(choice_file_list)print("导入数据成功\n")def save(dictory):name = input("请输入文件名(无需加后缀):")book = xlwt.Workbook()sheet = book.add_sheet('Sheet1', cell_overwrite_ok=True)keys = list(data[list(data.keys())[0]].keys())head = ["城市"]head.extend(keys)for h in range(len(head)):sheet.write(0, h, head[h])cities = list(dictory.keys())for city in range(len(cities)):sheet.write(city+1, 0, cities[city])for key in range(len(keys)):sheet.write(city+1, key+1, dictory[cities[city]][keys[key]])book.save('./data/'+name+'.xls')print("保存成功")
效果图如下:
6.总结
这个程序是我将课本上的纯理论应用到实践中,进一步加深了我对知识的理解。最后将完整代码奉上:
import os
import xlrd2 #xlrd: 对Excel进行读相关操作
import xlwt #xlwt: 对Excel进行写相关操作,且只能创建一个全新的Excel然后进行写入和保存。
import numpy
import matplotlib
from prettytable import PrettyTable #PrettyTable 是python中的一个第三方库,可用来生成美观的ASCII格式的表格
from matplotlib import pyplot as pltdef get_files_name():"""用于获取文件名:return: 返回值为文件名组成的列表"""file_list = os.listdir('./data')return file_list#保存生产excel表
def load_data(file_list):"""用于读取指定的文件并保存至字典数据结构中:param file_list: 需要加载的文件列表:return: 保存了文件内容的字典"""dictory = {}for file in file_list:# 获取表格文件book = xlrd2.open_workbook('./data/'+file)# 获取表格中的所有sheetnames = book.sheet_names()# 获取第一个sheetsheet = book.sheet_by_index(0)# 获取当前表格的行数rows = sheet.nrows# 获取当前表格的列数cols = sheet.ncols# 获取表头文件,即表格第一行head = sheet.row_values(0)for row in range(rows-1):# 如果当前字典中没有该城市则创建一个if not sheet.cell_value(row+1, 0) in dictory.keys():dictory[sheet.cell_value(row+1, 0)] = {}for col in range(cols-1):dictory[sheet.cell_value(row+1, 0)][head[col+1]] = float(sheet.cell_value(row+1, col+1))return dictory#数据排行
def sort_data(dictory, key, reverse):"""根据key和reverse对数据进行排序:param dictory: 传入的字典对象:param key: 需要排序的关键字,即那一列:param reverse: 是否从大到小排序,false即为从小到大排序:return:"""data = dictoryif not reverse:data = dict(sorted(data.items(), key=lambda d: d[1][key], reverse=False)) #字典的升序else:data = dict(sorted(data.items(), key=lambda d: d[1][key], reverse=True)) #字典的降序return datadef get_specified_cols(dictory, col_name_list):"""筛选出指定的列:param dictory:原始字典:param col_name_list: 需要筛选出的列名,城市名默认出现:return: 筛选之后的字典"""new_dict = {}for key in dictory.keys():new_dict[key] = {}for col_name in col_name_list:new_dict[key][col_name] = dictory[key][col_name]return new_dictdef get_specified_data(dictory, operation, col_name, value):"""根据输入的操作符、列名以及指定的value进行筛选,比如筛选出人均GDP大于5000的,则operation = '>', col_name = '人均GDP', value = 5000:param dictory: 原始数据:param operation: 操作符:param col_name: 需要比较的列:param value: 需要比较的值:return: 筛选之后的字典"""new_dict = {}if col_name != "城市":for key in dictory.keys():# flag用于标记是否需要添加该行value = float(value)flag = 0if operation == '>':if dictory[key][col_name] > value:flag = 1elif operation == '>=':if dictory[key][col_name] >= value:flag = 1elif operation == '=':if dictory[key][col_name] == value:flag = 1elif operation == '<=':if dictory[key][col_name] <= value:flag = 1elif operation == '<':if dictory[key][col_name] < value:flag = 1else:flag = 0if flag == 1:new_dict[key] = {}new_dict[key] = dictory[key]else:for key in dictory.keys():# flag用于标记是否需要添加该行flag = 0if operation == '>':if key > value:flag = 1elif operation == '>=':if key >= value:flag = 1elif operation == '=':if key == value:flag = 1elif operation == '<=':if key <= value:flag = 1elif operation == '<':if key < value:flag = 1else:flag = 0if flag == 1:new_dict[key] = {}new_dict[key] = dictory[key]return new_dict#制作图表
def draw_plot(dictory):font = {'family': 'MicroSoft Yahei', 'weight': 'bold', 'size': 7}matplotlib.rc('font', **font) #设置中文字体# 定义三个颜色index = numpy.arange(len(dictory.keys()))color = [(256 / 256, 0 / 256, 0 / 256, 1),(0 / 256, 0 / 256, 256 / 256, 1),(0 / 256, 256 / 256, 0 / 256, 1),(0 / 256, 0 / 256, 0 / 256, 1)]first_key = list(dictory.keys())first_key = first_key[0]cols = list(dictory[first_key].keys())data = []for i in range(len(cols)):data.append([])for key in dictory.keys():for col in range(len(cols)):data[col].append(dictory[key][cols[col]])offset = -1/4for i in range(len(cols)):plt.bar(index+offset, data[i], color=color[i], width=1 / 5) #通过bar函数可以用柱状图来表达一些变量的统计分布offset += 1/4plt.xticks(index, dictory.keys())#表示刻度plt.legend(cols)#给图像加上图例plt.show()def show_data(dictory):try:keys = list(dictory[list(dictory.keys())[0]].keys())except:print("当前数据为空")returnhead = ['城市']head.extend(keys)table = PrettyTable(head)for key in dictory.keys():line = [key]for key_2 in keys:line.append(dictory[key][key_2])table.add_row(line)print(table)def save(dictory):name = input("请输入文件名(无需加后缀):")book = xlwt.Workbook()sheet = book.add_sheet('Sheet1', cell_overwrite_ok=True)keys = list(data[list(data.keys())[0]].keys())head = ["城市"]head.extend(keys)for h in range(len(head)):sheet.write(0, h, head[h])cities = list(dictory.keys())for city in range(len(cities)):sheet.write(city+1, 0, cities[city])for key in range(len(keys)):sheet.write(city+1, key+1, dictory[cities[city]][keys[key]])book.save('./data/'+name+'.xls')print("保存成功")# 打印菜单
def menu():print(" ----------Excel 数据分析师----------")print("{:<30}".format(" ==============功能菜单============== "))print("{:<30}".format(" 1. 显示当前数据 "))print("{:<30}".format(" 2. 以柱状图展示当前数据 "))print("{:<30}".format(" 3. 提起指定列 "))print("{:<30}".format(" 4. 定向筛选指定元素 "))print("{:<30}".format(" 5. 数据排行 "))print("{:<30}".format(" 6. 重新加载数据 "))print("{:<30}".format(" 7. 保存当前数据 "))print("{:<30}".format(" 0. 退出程序 "))print("{:<30}".format(" ==================================== "))print("{:<30}".format(" 说明:输入相应数字后按下回车选择指定功能 "))print('\n')if __name__ == "__main__":# 导入文件files = get_files_name()data = {}print("当前data文件夹下的文件如下:")num = 1for file in files:print(num, file)num += 1while(1):index_str = input("请选择需要导入的文件序号(多个文件导入时用空格分开, 输入0则导入所有文件,输入多文件则自动合并):")index_list = index_str.split(' ')try:index_list.remove('')except:passchoice_file_list = []if index_list[0] == '0':choice_file_list = filesbreakelse:try:for item in index_list:choice_file_list.append(files[int(item)-1])except:print("输入序号有误")continueif choice_file_list:breakelse:print("输入序号有误")data = load_data(choice_file_list)print("导入数据成功\n")# 调用函数,打印菜单menu()while 1:choice = input("请选择指定功能:")if choice == '0':print("\n退出程序\n")exit()elif choice == '1':print("当前功能:显示当前数据")show_data(data)input('\n按下回车返回菜单')menu()elif choice == '2':print("当前功能:以柱状图显示数据")draw_plot(data)input('\n按下回车返回菜单')menu()elif choice == '3':print("当前功能:筛选指定列")keys = list(data[list(data.keys())[0]].keys())print("当前表格中的列如下:")num = 1for key in keys:print(num, key)num += 1choice_col_list = []while (1):index_str = input("请选择需要筛选出的列序号(多列之间用空格分开,0代表所有列):")index_list = index_str.split(' ')try:index_list.remove('')except:passchoice_file_list = []if index_list[0] == '0':choice_col_list = keysbreakelse:try:for item in index_list:choice_col_list.append(keys[int(item) - 1])except:print("输入序号有误")continueif choice_col_list:breakelse:print("输入序号有误")data = get_specified_cols(data, choice_col_list)print("筛选成功")input('\n按下回车返回菜单')menu()elif choice == '4':print("当前功能:筛选指定行")keys = list(data[list(data.keys())[0]].keys())print("当前表格中的列如下:")num = 1print(num, "城市")num += 1for key in keys:print(num, key)num += 1col = int(input("请输入需要进行筛选的数据所在的列:"))-2if col == -1:col = '城市'else:col = keys[col]op_list = ['<', '<=', '=', '>=', '>']print("比较操作符如下:")num = 1for op in op_list:print(num, op)num += 1operation = int(input("请输入比较操作符前的序号:"))-1operation = op_list[operation]value = input("请输入需要筛选的值:")data = get_specified_data(data, operation, col, value)print("筛选成功")input('\n按下回车返回菜单')menu()elif choice == '5':print("当前功能:数据排序")keys = list(data[list(data.keys())[0]].keys())print("当前表格中的列如下:")num = 1for key in keys:print(num, key) #显示当前表格中的所有的列num += 1col = int(input("请输入需要进行排序的数据所在的列:")) - 1col = keys[col]reverse = input("排序方式:\n1 从大到小排序\n2 从小到大排序\n")if reverse == '1':data = sort_data(data, col, True)elif reverse == '2':data = sort_data(data, col, False)else:print("输入有误")input('\n按下回车返回菜单')menu()elif choice == '6':# 导入文件files = get_files_name()data = {}print("当前文件夹下的文件如下:")num = 1for file in files:print(num, file)num += 1while (1):index_str = input("请选择需要导入的文件序号(多个文件导入时用空格分开, 输入0则导入所有文件,输入多文件则自动合并):")index_list = index_str.split(' ')try:index_list.remove('')except:passchoice_file_list = []if index_list[0] == '0':choice_file_list = filesbreakelse:try:for item in index_list:choice_file_list.append(files[int(item) - 1])except:print("输入序号有误")continueif choice_file_list:breakelse:print("输入序号有误")data = load_data(choice_file_list)print("导入数据成功\n")# 打印菜单menu()elif choice == '7':print("当前功能:保存数据")save(data)input('\n按下回车返回菜单')menu()else:print("请输入正确的数字")input('\n按下回车返回菜单')menu()
利用Python对Excel数据进行处理相关推荐
- 利用Python取出excel数据并生成统计图
取出excel数据生成图表 帮朋友写的一个小脚本 从excel中取出数据,然后生成一个统计图表 借助了Python的第三方模块xlrd和pyecharts xlrd Python中用来读取excel数 ...
- python处理word表格excel_利用Python将excel数据读取到word表格
在工作中可能需要两者对excel和word进行转化,今天介绍例如Python 将excel转word表格 看图,我需要将这份excel文档转word表格: 思路: 1.创建需要的表格: 2.读取exc ...
- python处理表格数据教程_利用Python处理Excel数据
本文的数据源是朝阳医院2016的销售数据,课程是使用R语言来进行数据处理的,这里尝试采用Python来处理. 要求的业务指标是:1)月均消费次数:2)月均消费金额:3)客单价:4)消费趋势 这几个指标 ...
- 利用python将excel数据导入mySQL
主要用到的库有 xlrd 和 pymysql , 注意pymysql不支持python3 篇幅有限,只针对主要操作进行说明 连接数据库 首先pymysql需要连接数据库,我这里连接的是本地数据库(数据 ...
- python做excel数据条件_懂点EXCEL就行!教你利用Python做数据筛选(上)
前言 Python的数据清洗功能有多厉害,相信不用我说大家都知道了,寥寥几行代码便可以把一份杂乱无章的表格给处理的干干净净.但是python也是不容易入门的,毕竟编程语言要理解和精通也是要花不少功夫的 ...
- 如何利用python处理excel
利用Python处理Excel数据可以帮助我们更高效地进行数据分析和处理.以下是一些常用的Python库和工具: Pandas:Pandas是一个用于数据处理和分析的Python库,它提供了丰富的数据 ...
- python 表格格式输出_利用python对excel中一列的时间数据更改格式操作
问题场景:需要将下列的交期一列的数据格式更改成2019/05/10 存货编码 尺寸 数量 交期 0 K10Y0190000X B140 200 2019-05-10 00:00:00 1 K10Y01 ...
- python对excel数据更改_利用python对excel中一列的时间数据更改格式代码示例
本篇文章小编给大家分享一下利用python对excel中一列的时间数据更改格式代码示例,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看. 问题场景:需要将 ...
- 如何利用python将excel表格中筛选出来的每一份数据各自另存为新的excel文件?
如何利用python将excel表格中筛选出来的每一份数据各自另存为新的excel文件? 1.问题描述 2.解决过程 2.1 问题分析: 2.2 解决思路 3.运行结果 1.问题描述 最近在处理一堆工 ...
- 【Python数据分析】利用Python删除EXCEL表格中指定的列数据或行数据
如何利用Python删除EXCEL表格中指定的列数据?今天与大家一起分享一下DataFrame对象的drop()函数,drop()函数可根据标签删除EXCEL表格中的列数据或行数据,其语法格式如下: ...
最新文章
- ADAS摄像头20个技术挑战
- C语言中的弱符号与强符号介绍
- 敲诈英伟达的竟然是一群未成年???
- Maven搭建springMVC+spring+hibernate环境
- 全球隔夜主要金融市场回顾
- sqlserver垮库查询_Oracle和SQLServer中实现跨库查询
- python实训名片管理程序_python3学生名片管理v2.0版
- freebsd 同步工具unison
- 主板开启网络唤醒(Wake on lan)
- 使用注解方式搭建SpringMVC
- 关于js执行机制的理解
- 网易易盾最新一代Java2c加固究竟有什么厉害之处?
- 《大师谈游戏设计——创意与节奏》【笔记二】
- LaTex中各种文本框
- 微信文章搜索工具, 推荐使用它,简单好用
- UE编辑器格式化java代码
- python猜年龄代码_Python实现猜年龄游戏代码实例
- js 对日期的计算,加减天数
- 2017.11-上海商泰汽车有限公司面试
- Django——Ajax
热门文章
- 沧小海笔记之PCIE协议解析——第二章 详述PCIE事务层
- Linux x86-64 IOMMU详解(六)——Intel IOMMU参与下的DMA Coherent Mapping流程
- NB-SVM strong linear baseline
- java整人的代码_「vbs代码」vbs表白代码+整人代码,抖音vbscript表白代码 - seo实验室...
- SQL注入(SQL注入(SQLi)攻击)攻击-脱库
- caffee 安装教程
- 写一手好字:硬笔书法轻松自学指南(知乎周刊 Plus)-读书笔记
- WP10回滚WP8.1详细教程,变砖也可修复
- 大学计算机与应用软件,深圳大学
- windows 修改MySQL默认3306端口