应用一些计算后得出的巨大而怪异的值

时间:2019-12-11 13:14:12

标签: python excel pandas format

我为某些列获取的值太大,而其他的则以日/月格式显示(请参阅excel图片),我想知道为什么。任何帮助,将不胜感激。

在这里您可以看到excelİmage excel output

和大熊猫İmage pandas output

这是我的代码,文件是here

import pandas as pd

# Read the file
data = pd.read_csv('/your_location/for_test.csv', sep = ';')

# Set the index
data = data.set_index('Date_Time') 

# Drop the duplicated rows
data = data.drop_duplicates(keep = "first")


# Create new columns using Addition and Multiplication
data['a1'] = data['x1'] * data['y1']
data['a2'] = data['x2'] * data['y2']
data['a3'] = data['x3'] * data['y3']

data['b1'] = data['x1'] * data['z1']
data['b2'] = data['x2'] * data['z2']
data['b3'] = data['x3'] * data['z3']

data['A'] = (data['a1'] + data['a2'] + data['a3']) * 0.01 
data['B'] = (data['b1'] + data['b2'] + data['b3']) * 0.01 
data['A+B'] = data['A'] + data['B'] 

# Final dataframe
data = data[['A+B', 'A']]

save_data = data.to_csv('/your_location/output.csv', sep = ';')

data

0 个答案:

没有答案