Advertisement
brandblox

Lab_BD(8/1/25)

Jan 8th, 2025 (edited)
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import pandas as pd
  2. import matplotlib.pyplot as plt
  3.  
  4. file_path = 'TESLA.csv'
  5. df = pd.read_csv(file_path)
  6. start_index = 0
  7. df_subset = df.iloc[start_index:start_index+10]
  8.  
  9. # df_subset['Date'] = pd.to_datetime(df_subset['Date'])
  10. df_subset.loc[:, 'Date'] = pd.to_datetime(df_subset['Date'], format='%m/%d/%y')
  11. x = df_subset['Date']
  12. y = df_subset['Open']
  13. # plt.bar(x, y, color='g')
  14. plt.plot(x, y, marker='o', linestyle='--', color='b')
  15.  
  16.  
  17. plt.xlabel('Date')
  18. plt.ylabel('Open Price in $')
  19. plt.title('Open Prices for the First 10 Days of Tesla Stock Market')
  20.  
  21. plt.xticks(rotation=45)
  22. plt.tight_layout()
  23. plt.grid()
  24. plt.show()
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement