CS3
DownloadTélécharger
Actions
Vote :
ScreenshotAperçu
Informations
Catégorie :Category: nCreator TI-Nspire
Auteur Author: NSRBIKE
Type : Classeur 3.0.1
Page(s) : 1
Taille Size: 3.57 Ko KB
Mis en ligne Uploaded: 24/10/2024 - 05:58:19
Uploadeur Uploader: NSRBIKE (Profil)
Téléchargements Downloads: 1
Visibilité Visibility: Archive publique
Shortlink : http://ti-pla.net/a4272407
Type : Classeur 3.0.1
Page(s) : 1
Taille Size: 3.57 Ko KB
Mis en ligne Uploaded: 24/10/2024 - 05:58:19
Uploadeur Uploader: NSRBIKE (Profil)
Téléchargements Downloads: 1
Visibilité Visibility: Archive publique
Shortlink : http://ti-pla.net/a4272407
Description
Fichier Nspire généré sur TI-Planet.org.
Compatible OS 3.0 et ultérieurs.
<<
sales_df = pd.read_excel("Sales_Data.xlsx") sales_df.head(5) # Calculate the total sales revenue tot_sales_revenue = sales_df['Sales$'].sum() # Display the result print(f"Total sales revenue: ${round(tot_sales_revenue)}") # Group by product and get the total sales for each product prod_sales = sales_df.groupby('Product Name')['Sales$'].sum().reset_index() # Sort the products by total sales in a descending order top_selling_prods = prod_sales.sort_values(by='Sales$', ascending=False) print("Top 5 selling products based on sales:") top_selling_prods.head(5) # Group by category and get the total sales for each category categ_sales = sales_df.groupby('Category')['Sales$'].sum().reset_index() # Sort the categories by total sales in a descending order top_selling_categs = categ_sales.sort_values(by='Sales$', ascending=False) print("Top-selling categories by number of orders:") top_selling_categs.head(5) # Transform the 'Order Date' column to datetime sales_df['Order Date'] = pd.to_datetime(sales_df['Order Date']) sales_df.head(5) print(f"The earliest order date is: {str(sales_df['Order Date'].min())}") print('--------------') print(f"The latest order date is: {str(sales_df['Order Date'].max())}") # Extract the year and month from the 'Order Date' column sales_df['year-month-order'] = sales_df['Order Date'].dt.to_period('M') sales_df.head(3) # Group by the 'Year-Month' and sum the sales monthly_sales = sales_df.groupby('year-month-order')['Sales$'].sum().reset_index() monthly_sales # Convert 'Year-Month' back to datetime for plotting monthly_sales['year-month-order'] = monthly_sales['year-month-order'].dt.to_timestamp() # Plot the total monthly sales plt.figure(figsize=(10, 6)) plt.plot(monthly_sales['year-month-order'], monthly_sales['Sales$'], marker='o') plt.title('Total monthly sales') plt.xlabel('Month') plt.ylabel('Total sales in dollars') plt.tight_layout() plt.show() Conclusion: The overall trend of the total monthly sales is increasing. Despite some short-term fluctuations, the long-term trajectory shows growth in sales over the years. # Select the columns needed for correlation correl_data = sales_df[['Sales$', 'Discount$', 'ShippingCost$']] # Get the correlation matrix correl_matrix = correl_data.corr() print(correl_matrix) ### Sales and Discount: Correlation coefficient: 0.904485 There is a strong positive correlation between Sales and Discount. This means that as the sales amount increases, the discount amount tends to increase as well. ### Sales and ShippingCost: Correlation coefficient: 0.992095 There is a very strong positive correlation between Sales and ShippingCost. This indicates that as the sales amount increases, the shipping cost also increases very closely. ### Discount and ShippingCost: Correlation coefficient: 0.906014 There is a strong positive correlation between Discount and ShippingCost. This means that higher discounts are associated with higher shipping costs. # Plot the histogram of the sales data plt.figure(figsize=(10, 6)) plt.hist(sales_df['Sales$'], bins=100) plt.title('Histogram of sales') plt.xlabel('Sales in dollars') plt.ylabel('Frequency') plt.show() # Filter the data to keep only the consumer segment consumer_data = sales_df[sales_df['Segment'] == 'Consumer'] # Calculate the mean discount for the consumer segment mean_discount_consumer = consumer_data['Discount$'].mean() print(f"Mean discount for consumer segment: ${round(mean_discount_consumer, 2)}") # Group the data by segment and get the standard deviation of sales for each segment std_sales_segment = sales_df.groupby('Segment')['Sales$'].std().reset_index() std_sales_segment The Home Office segment has the highest standard deviation of 763.71, which has the most variability in sales among the three segments. # Group the data by category and get the total sales total_sales_category = sales_df.groupby('Category')['Sales$'].sum().reset_index() total_sales_category # Plot the bar chart for total sales for each category plt.figure(figsize=(6, 4)) plt.bar(total_sales_category['Category'], total_sales_category['Sales$'], color='blue', width=0.3) plt.title('Total sales by category') plt.ylabel('Total sales in dollars') plt.show() # Count the number of sales per ship mode sales_ship_mode = sales_df['Ship Mode'].value_counts().reset_index() sales_ship_mode.columns = ['Ship Mode', 'Number of Sales'] sales_ship_mode # Plot the bar chart for the number of sales per ship mode plt.figure(figsize=(6, 4)) plt.bar(sales_ship_mode['Ship Mode'], sales_ship_mode['Number of Sales'], color='blue', width=0.3) plt.title('Number of sales per ship mode') plt.ylabel('Number of sales') plt.show() # Filter the data to keep only the period 2017-2018 filtered_data = sales_df[(sales_df['Order Date'].dt.year >= 2017) & (sales_df['Order Date'].dt.year <= 2018)] filtered_data.head(3) # Group the data by region and calculate the total sales sales_region = filtered_data.groupby('Region')['Sales$'].sum().reset_index() sales_region # Sort the regions by
[...]
>>
Compatible OS 3.0 et ultérieurs.
<<
sales_df = pd.read_excel("Sales_Data.xlsx") sales_df.head(5) # Calculate the total sales revenue tot_sales_revenue = sales_df['Sales$'].sum() # Display the result print(f"Total sales revenue: ${round(tot_sales_revenue)}") # Group by product and get the total sales for each product prod_sales = sales_df.groupby('Product Name')['Sales$'].sum().reset_index() # Sort the products by total sales in a descending order top_selling_prods = prod_sales.sort_values(by='Sales$', ascending=False) print("Top 5 selling products based on sales:") top_selling_prods.head(5) # Group by category and get the total sales for each category categ_sales = sales_df.groupby('Category')['Sales$'].sum().reset_index() # Sort the categories by total sales in a descending order top_selling_categs = categ_sales.sort_values(by='Sales$', ascending=False) print("Top-selling categories by number of orders:") top_selling_categs.head(5) # Transform the 'Order Date' column to datetime sales_df['Order Date'] = pd.to_datetime(sales_df['Order Date']) sales_df.head(5) print(f"The earliest order date is: {str(sales_df['Order Date'].min())}") print('--------------') print(f"The latest order date is: {str(sales_df['Order Date'].max())}") # Extract the year and month from the 'Order Date' column sales_df['year-month-order'] = sales_df['Order Date'].dt.to_period('M') sales_df.head(3) # Group by the 'Year-Month' and sum the sales monthly_sales = sales_df.groupby('year-month-order')['Sales$'].sum().reset_index() monthly_sales # Convert 'Year-Month' back to datetime for plotting monthly_sales['year-month-order'] = monthly_sales['year-month-order'].dt.to_timestamp() # Plot the total monthly sales plt.figure(figsize=(10, 6)) plt.plot(monthly_sales['year-month-order'], monthly_sales['Sales$'], marker='o') plt.title('Total monthly sales') plt.xlabel('Month') plt.ylabel('Total sales in dollars') plt.tight_layout() plt.show() Conclusion: The overall trend of the total monthly sales is increasing. Despite some short-term fluctuations, the long-term trajectory shows growth in sales over the years. # Select the columns needed for correlation correl_data = sales_df[['Sales$', 'Discount$', 'ShippingCost$']] # Get the correlation matrix correl_matrix = correl_data.corr() print(correl_matrix) ### Sales and Discount: Correlation coefficient: 0.904485 There is a strong positive correlation between Sales and Discount. This means that as the sales amount increases, the discount amount tends to increase as well. ### Sales and ShippingCost: Correlation coefficient: 0.992095 There is a very strong positive correlation between Sales and ShippingCost. This indicates that as the sales amount increases, the shipping cost also increases very closely. ### Discount and ShippingCost: Correlation coefficient: 0.906014 There is a strong positive correlation between Discount and ShippingCost. This means that higher discounts are associated with higher shipping costs. # Plot the histogram of the sales data plt.figure(figsize=(10, 6)) plt.hist(sales_df['Sales$'], bins=100) plt.title('Histogram of sales') plt.xlabel('Sales in dollars') plt.ylabel('Frequency') plt.show() # Filter the data to keep only the consumer segment consumer_data = sales_df[sales_df['Segment'] == 'Consumer'] # Calculate the mean discount for the consumer segment mean_discount_consumer = consumer_data['Discount$'].mean() print(f"Mean discount for consumer segment: ${round(mean_discount_consumer, 2)}") # Group the data by segment and get the standard deviation of sales for each segment std_sales_segment = sales_df.groupby('Segment')['Sales$'].std().reset_index() std_sales_segment The Home Office segment has the highest standard deviation of 763.71, which has the most variability in sales among the three segments. # Group the data by category and get the total sales total_sales_category = sales_df.groupby('Category')['Sales$'].sum().reset_index() total_sales_category # Plot the bar chart for total sales for each category plt.figure(figsize=(6, 4)) plt.bar(total_sales_category['Category'], total_sales_category['Sales$'], color='blue', width=0.3) plt.title('Total sales by category') plt.ylabel('Total sales in dollars') plt.show() # Count the number of sales per ship mode sales_ship_mode = sales_df['Ship Mode'].value_counts().reset_index() sales_ship_mode.columns = ['Ship Mode', 'Number of Sales'] sales_ship_mode # Plot the bar chart for the number of sales per ship mode plt.figure(figsize=(6, 4)) plt.bar(sales_ship_mode['Ship Mode'], sales_ship_mode['Number of Sales'], color='blue', width=0.3) plt.title('Number of sales per ship mode') plt.ylabel('Number of sales') plt.show() # Filter the data to keep only the period 2017-2018 filtered_data = sales_df[(sales_df['Order Date'].dt.year >= 2017) & (sales_df['Order Date'].dt.year <= 2018)] filtered_data.head(3) # Group the data by region and calculate the total sales sales_region = filtered_data.groupby('Region')['Sales$'].sum().reset_index() sales_region # Sort the regions by
[...]
>>