import psycopg2# Step 1: Connect to the PostgreSQL databasetry: connection = psycopg2.connect( host=”localhost”, # Database host port=”5432″, # Port (default for PostgreSQL) database=”postgres”, # Your database name user=”username”, […]
Learn Python 100 days (Day 3)
import matplotlib.pyplot as pltimport numpy as npxpoints = np.array([0, 3, 5, 6, 8])ypoints = np.array([0, 40, 90, 250, 330])plt.plot(xpoints, ypoints, marker=’o’, linestyle=’dotted’, color=’r’)plt.title(“Profits forecasting”)plt.xlabel(“No of Items”)plt.ylabel(“Profits in Thousands”)plt.show()
Learn Python 100 days (Day 2)
import pandas as pdimport numpy as npdata=pd.DataFrame(np.random.randn(5,3),columns=[‘A’,’B’,’C’])print(data.head(3))print(data.tail(2))data[‘Index’]=[‘A’,’B’,’C’,’D’,’E’]data=data.set_index(‘Index’)data=data.reset_index()print(data)grouped_data=pd.DataFrame({ ‘Category’:[‘A’,’B’,’C’,’D’,’E’], ‘Values’:[10,20,30,40,50], ‘Price’:[20,30,50,69,90]})print(grouped_data)grouped_data.to_csv(‘/Users/testing/output1.csv’, index=False, header=True)print(“csv file saved successfully”)
Learn Python 100 days (Day 1)
import numpy as np# Two 1D arrays (vectors)vec1 = np.array([1, 2, 3])vec2 = np.array([4, 5, 6])# Dot product of the two vectorsdot_product = np.dot(vec1, vec2)print(“Dot product of vec1 […]
Hello world!
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!