I want to subtract multiple column data from two text file. The text file contain 6 columns and these columns are not named.So I named it as No,X,Y,Z,Date,Time and seperated with comma. I want to perform X-X1, Y-Y1, Z-Z1. Date and Time are not important and they are only for reference. For this I have opened the files with different dataframe and I have used concat and then I produced another csv file which contains data from two text file in single CSV file. Now when I am subtracting the columns X-X1, Y-Y1, Z-Z1 I am getting the following error: "Name 'X' is not defined" also I am getting the following error: AttributeError: 'tuple' object has no attribute 'to_csv', when trying to produce file named "difference.csv". Please help me to solve this error. Below is my code.
import pandas as pd
import os
import numpy as np
df1 = pd.read_csv('D:\\Work\\Data1.txt', names=['No1','X1','Y1','Z1','Date1','Time1'], sep='\s+')
df2 = pd.read_csv('D:\\Work\\Data19.txt', names=['No','X','Y','Z','Date','Time'], sep='\s+')
total=pd.concat([df1,df2], axis=1)
total.to_csv("merge.csv")
cols = ['X','Y','Z','X1','Y1','Z1']
print(total)
df3 = pd.read_csv('C:\\Users\\Admin\\PycharmProjects\\project1\\merge.csv')
df4[X,Y,Z] = df3[X,Y,Z]-df3[X1,Y1,Z1]
print(df4)
df4.to_csv("difference.csv")