对excel中的指定行的内容填充
#! /usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2018/9/1 16:11
# @File : qingxi
# @Software: PyCharm
import numpy as np
import pandas as pd
import datetime
start = datetime.datetime.now()
print(start)
name = pd.read_excel("D:\\ex2\\1\\titlename.xlsx")
title = list(name)
data1 = pd.read_excel("D:\\ex2\\1\\tar_2016.xlsx",header=None,skiprows=4,names = title)
#col = ['a','b','c','d']
col_to_fill = ["a","b"]
col_notto_fill = ["c","d"]
col_total = col_to_fill + col_notto_fill
data1[col_to_fill] = data1[col_to_fill].ffill()
data2 = data1[col_total]
# write_2 = pd.ExcelWriter('D:/ex2/tmp_maintance_2017.xlsx')
# data2.to_table(write_2,'2017')
data2.to_csv('d:/ex2/tmp_maintance_2016.csv',sep=',')
end = datetime.datetime.now()
print(end)
print(end-start)
print('OK')
网友评论