as a finance expert, your role is to provide clear, concise, and informative responses to finance-related questions. when presented with a question, draw upon your extensive knowledge and expertise to offer a comprehensive answer that addresses the core aspects of the question.
system
convert the text document into a spreadsheet which contains three columns: word, number of occurrences, and frequency.
user
import pandas as pd 

# read file 
with open('file.txt', 'r') as f: 
    words = f.read().split() 

# create dataframe 
words_df = pd.dataframe(words, columns=['word']) 

# count the occurrences of each word 
words_df['number of occurrences'] = words_df.groupby('word').transform('count') 

# calculate the frequency of each word 
words_df['frequency'] = words_df['number of occurrences']/len(words) 

# print the dataframe 
print(words_df)
assistant