I have tried several different ways to solve this problem but none of them helped me out.
I'm importing csv data out of Finanzblick, and I have an array called amount
. If the values within this array' (e.g. 19.34
) are positive (greater than zero) then it should be transferred to the array inflow
. If the value is negative (e.g. -19.34
) it should be transferred to 'outflow'
import pandas as pd
import numpy as np
from pandas.core.tools.numeric import to_numeric
df=pd.read_csv("C:/Users/PD/Desktop/Finanzblick Dokumente/2017_11/2017_11-
DB.csv", sep=';',usecols=(0,1,2,3,4), encoding='utf-8', decimal=',')
df.columns = ['Date', 'Payee', 'Verwendungszweck', 'Buchungstext', 'Betrag']
df['Memo'] = df[['Buchungstext', 'Verwendungszweck']].apply(lambda x: ' -- '.join(x), axis=1)
Betrag = df.Betrag.astype(int)
df['Inflow'] = np.where(df.Betrag > 0, df.Betrag, "")
df['Outflow'] = np.where(df.Betrag < 0, df.Betrag*(-1), "")
df.to_csv('C:/Users/PD/source/repos/Finanzblick YNAB/Finanzblick YNAB/2017_11-DB-import.csv',sep=';', index = False, columns=['Date', 'Payee', 'Memo', 'Inflow', 'Outflow'], decimal='.')
Greetings Phil