我有这样的脚本:
import pandas as pd
import os
import openpyxl
from datetime import datetime
import xlsxwriter
de_para = pd.read_csv('C:\\Users\\gabriel.brito\\Desktop\\Teste\\DE X PARA QIOM LINHAS.csv', sep=";")
tabela = pd.read_csv('C:\\Users\\gabriel.brito\\Desktop\\Teste\\ProcessoMonitoramentoDiarioEst.csv', sep=",")
dexpara = pd.read_csv('C:\\Users\\gabriel.brito\\Desktop\\Teste\\DE X PARA DATA.csv', sep=";")
df = tabela
df.drop(df[df['Empresa']=="1001"].index, inplace=True)
df.drop(df[df['Empresa']=="CATARINENSE"].index, inplace=True)
df.drop(df[df['Empresa']=="EXPRESSO"].index, inplace=True)
df.drop(df[~df['paradaOrigemSaneada'].str.contains("- SP")].index, inplace=True)
df.drop(df[~df['paradaDestinoSaneada1'].str.contains("- SP")].index, inplace=True)
tratamento = df.join(de_para.set_index('LINHA'), on='codlinha', lsuffix='_1', rsuffix='_1', how='inner')
tratamento2 = df.join(dexpara.set_index ('DIA'), on='dia', lsuffix='_2', rsuffix='_2', how='inner')
unificado = pd.concat([tratamento, tratamento2])
unificado.to_excel('C:\\Users\\gabriel.brito\\Desktop\\Teste\\teste2.xlsx')
os.system('C:\\Users\\gabriel.brito\\Desktop\\Teste\\teste2.xlsx')
语法“Unificado”是为了给我带来关于NUM_AUTOS和DATE的信息,我使用另一个基来合并这些信息,但它只给我显示“NUM_AUTOS”,我需要两者。
those are the columns that I need the information, but it only shows me one, and if I try to use the script related to DATE it shows me the DATE and NUM_AUTOS no
我尝试了所有方法,但未显示两个信息,仅显示一个
1条答案
按热度按时间bmp9r5qi1#
为了帮助你,我需要一个更好的描述。你创建的数据框架的样本将是一个很好的开始。但是,我会检查删除和连接步骤。确保列'日期'仍然包含值后,你删除行,以及检查你选择的键连接表是有效地提供你想要的。