I am using pandas to import a csv file with stocks data. It seems like every time I save the file, Pandas adds a row with the id of the row to the file.
import yfinance as yf
import pandas as pd
#Open File
df = pd.read_csv('balance.csv')
#Calculating Current Value
df['Value'] = df['BuyPrice'] * df['BuyAmount']
#Adding Most Recent Price to CSV File
ticker_stock = yf.Ticker('AAPL')
data = ticker_stock.history()
df['Price'] = (data.tail(1)['Close'].iloc[0])
print(df)
#Save File
df.to_csv('balance.csv')
If I run the program 3 times, I will have 3 rows with ids in them. Is there a way to stop pandas from showing me the row id and adding it to the file each time I save it? It also seems like the id is stopping me from using the data in the table to do statistics since it also includes the id every time I pull data from the table.