美文网首页
求两个dataframe时间序列不同的项

求两个dataframe时间序列不同的项

作者: Aerosols | 来源:发表于2022-08-29 15:09 被阅读0次
## 1.导入
import numpy as np
import pandas as pd
import matplotlib as mpl

import os
import math
import glob
import datetime
from matplotlib import pyplot as plt
import matplotlib.dates as mdates
from datetime import datetime,timedelta
from matplotlib.ticker import MultipleLocator, FormatStrFormatter,FixedFormatter
from pathlib import Path
## 2.读取数据
p1 = Path(r"D:\python\fluxcal\data\particle\分组浓度")
FileList_bc = list(p1.glob("*.csv"))

p2 = Path(r"D:\python\fluxcal\data\particle\原始数据\output_particle_index")
FileList_index = list(p2.glob("*.csv"))

bc_ = []
index_1 = []

for subdf in FileList_bc[:]:
    BC = pd.read_csv(subdf,sep=',',na_values=["NaN","NAN"],
                     usecols = ["DateTimewave_tmp"],
                     index_col=0,header=0,parse_dates=[0])
    bc_.append(BC)
    
for subdf in FileList_index[:]:
    index1 = pd.read_csv(subdf,sep=',',na_values=["NaN","NAN"],
                        usecols = ["DateTimewave_tmp"],
                       index_col=0,header=0,parse_dates=[0])
    index_1.append(index1) 
#### 3. 求差集
bcindex = pd.DataFrame(pd.concat(bc_))
bcindex["time_"] =  bcindex.index

index_ = pd.DataFrame(pd.concat(index_1))
index_["time_"] = index_.index

diff = index_.index.difference(bcindex.index)

## 4.导出
pd.DataFrame(diff).to_csv("diff_time.csv")

相关文章

网友评论

      本文标题:求两个dataframe时间序列不同的项

      本文链接:https://www.haomeiwen.com/subject/yytdvrtx.html