In this we discussed how to import csv in python and get first 5 rows from csv and save it on another sheet. import pandas as pd #Read the CSV filedf = pd.read_csv('annual-enterprise-survey-2021-financial-year-provisional-csv.csv') #Select the first 10 rowsdf_subset = df.head(5) display(df) #Save the selected rows to a new CSV filedf_subset.to_csv('First-5-Rows.csv', index=False)
Data Analysis
Display Bar Graph in Python [Jupyter]
import pandas as pdimport matplotlib.pyplot as plt #Read the CSV file into a DataFramedf = pd.read_csv('First-5-Rows.csv') #Group the data by 'Variable_name' and aggregate the 'Value' column by sumgrouped_df = df.groupby('Variable_name')['Value'].sum().reset_index() #Create a bar chart of the dataplt.bar(grouped_df['Variable_name'], grouped_df['Value']) #Add labels and title to the chartplt.xlabel('Variable Name')plt.ylabel('Value')plt.title('Bar Chart of First 5 Rows by Variable Name') Show … Continue reading Display Bar Graph in Python [Jupyter]
Data Analyst – Roadmap
As a data analyst, there are several skills and knowledge areas you should focus on to excel in your role. Here's a roadmap that can guide you through your journey:
You must be logged in to post a comment.