1618893353
Together we’ll build a complete social media analysis dashboard app of our Linkedin data in Python. You’ll learn how to create the layout, the styling, add needed graph components as well as Bootstrap cards. Download coded below.
Subscribe: https://www.youtube.com/channel/UCqBFsuAz41sqWcFjZkqmJqQ
Video layout:
00:00 - What you will learn and why
04:06 - Download LinkedIn data
05:27 - Wireframe step: jup-a-layout
09:10 - Building Rows and Columns
15:19 - Layout Spacing: Bootstrap Cheat Sheet
18:49 - Add Dash Components: jup-b-layout-components
27:11 - Lottie Animations
29:48 - Add Graph Components
33:28 - Next Tutorial
GitHub Code:
https://github.com/Coding-with-Adam/D…
Part 2 of the Linkedin Analysis Dashboard app. We’ll finalize the app, and learn how to use the Dash Callback to create interactivity between the Date Picker and the graphs on the page. Download coded below.
Video layout:
00:00 - What you will learn and why
01:53 - Update HTML in cards: jup-c-small file
11:34 - Important note on DatePicker
12:03 - Creating the line chart: jup-d-final file
18:45 - Plotly Figure Reference
22:13 - Bar, Pie Chart, Wordcloud
GitHub Code:
https://github.com/Coding-with-Adam/D…
#python
1645331260
Great job
1652748716
Exploratory data analysis is used by data scientists to analyze and investigate data sets and summarize their main characteristics, often employing data visualization methods. It helps determine how best to manipulate data sources to get the answers you need, making it easier for data scientists to discover patterns, spot anomalies, test a hypothesis, or check assumptions. EDA is primarily used to see what data can reveal beyond the formal modeling or hypothesis testing task and provides a better understanding of data set variables and the relationships between them. It can also help determine if the statistical techniques you are considering for data analysis are appropriate or not.
🔹 Topics Covered:
00:00:00 Basics of EDA with Python
01:40:10 Multiple Variate Analysis
02:30:26 Outlier Detection
03:44:48 Cricket World Cup Analysis using Exploratory Data Analysis
If we want to explain EDA in simple terms, it means trying to understand the given data much better, so that we can make some sense out of it.
We can find a more formal definition in Wikipedia.
In statistics, exploratory data analysis is an approach to analyzing data sets to summarize their main characteristics, often with visual methods. A statistical model can be used or not, but primarily EDA is for seeing what the data can tell us beyond the formal modeling or hypothesis testing task.
EDA in Python uses data visualization to draw meaningful patterns and insights. It also involves the preparation of data sets for analysis by removing irregularities in the data.
Based on the results of EDA, companies also make business decisions, which can have repercussions later.
In this article we’ll see about the following topics:
Data Sourcing is the process of finding and loading the data into our system. Broadly there are two ways in which we can find data.
Private Data
As the name suggests, private data is given by private organizations. There are some security and privacy concerns attached to it. This type of data is used for mainly organizations internal analysis.
Public Data
This type of Data is available to everyone. We can find this in government websites and public organizations etc. Anyone can access this data, we do not need any special permissions or approval.
We can get public data on the following sites.
The very first step of EDA is Data Sourcing, we have seen how we can access data and load into our system. Now, the next step is how to clean the data.
After completing the Data Sourcing, the next step in the process of EDA is Data Cleaning. It is very important to get rid of the irregularities and clean the data after sourcing it into our system.
Irregularities are of different types of data.
To perform the data cleaning we are using a sample data set, which can be found here.
We are using Jupyter Notebook for analysis.
First, let’s import the necessary libraries and store the data in our system for analysis.
#import the useful libraries.
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
# Read the data set of "Marketing Analysis" in data.
data= pd.read_csv("marketing_analysis.csv")
# Printing the data
data
Now, the data set looks like this,
If we observe the above dataset, there are some discrepancies in the Column header for the first 2 rows. The correct data is from the index number 1. So, we have to fix the first two rows.
This is called Fixing the Rows and Columns. Let’s ignore the first two rows and load the data again.
#import the useful libraries.
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
# Read the file in data without first two rows as it is of no use.
data = pd.read_csv("marketing_analysis.csv",skiprows = 2)
#print the head of the data frame.
data.head()
Now, the dataset looks like this, and it makes more sense.
Dataset after fixing the rows and columns
Following are the steps to be taken while Fixing Rows and Columns:
Now if we observe the above dataset, the customerid
column has of no importance to our analysis, and also the jobedu
column has both the information of job
and education
in it.
So, what we’ll do is, we’ll drop the customerid
column and we’ll split the jobedu
column into two other columns job
and education
and after that, we’ll drop the jobedu
column as well.
# Drop the customer id as it is of no use.
data.drop('customerid', axis = 1, inplace = True)
#Extract job & Education in newly from "jobedu" column.
data['job']= data["jobedu"].apply(lambda x: x.split(",")[0])
data['education']= data["jobedu"].apply(lambda x: x.split(",")[1])
# Drop the "jobedu" column from the dataframe.
data.drop('jobedu', axis = 1, inplace = True)
# Printing the Dataset
data
Now, the dataset looks like this,
Dropping Customerid
and jobedu columns and adding job and education columns
Missing Values
If there are missing values in the Dataset before doing any statistical analysis, we need to handle those missing values.
There are mainly three types of missing values.
Let’s see which columns have missing values in the dataset.
# Checking the missing values
data.isnull().sum()
The output will be,
As we can see three columns contain missing values. Let’s see how to handle the missing values. We can handle missing values by dropping the missing records or by imputing the values.
Drop the missing Values
Let’s handle missing values in the age
column.
# Dropping the records with age missing in data dataframe.
data = data[~data.age.isnull()].copy()
# Checking the missing values in the dataset.
data.isnull().sum()
Let’s check the missing values in the dataset now.
Let’s impute values to the missing values for the month column.
Since the month column is of an object type, let’s calculate the mode of that column and impute those values to the missing values.
# Find the mode of month in data
month_mode = data.month.mode()[0]
# Fill the missing values with mode value of month in data.
data.month.fillna(month_mode, inplace = True)
# Let's see the null values in the month column.
data.month.isnull().sum()
Now output is,
# Mode of month is
'may, 2017'
# Null values in month column after imputing with mode
0
Handling the missing values in the Response column. Since, our target column is Response Column, if we impute the values to this column it’ll affect our analysis. So, it is better to drop the missing values from Response Column.
#drop the records with response missing in data.
data = data[~data.response.isnull()].copy()
# Calculate the missing values in each column of data frame
data.isnull().sum()
Let’s check whether the missing values in the dataset have been handled or not,
All the missing values have been handled
We can also, fill the missing values as ‘NaN’ so that while doing any statistical analysis, it won’t affect the outcome.
Handling Outliers
We have seen how to fix missing values, now let’s see how to handle outliers in the dataset.
Outliers are the values that are far beyond the next nearest data points.
There are two types of outliers:
So, after understanding the causes of these outliers, we can handle them by dropping those records or imputing with the values or leaving them as is, if it makes more sense.
Standardizing Values
To perform data analysis on a set of values, we have to make sure the values in the same column should be on the same scale. For example, if the data contains the values of the top speed of different companies’ cars, then the whole column should be either in meters/sec scale or miles/sec scale.
Now, that we are clear on how to source and clean the data, let’s see how we can analyze the data.
If we analyze data over a single variable/column from a dataset, it is known as Univariate Analysis.
Categorical Unordered Univariate Analysis:
An unordered variable is a categorical variable that has no defined order. If we take our data as an example, the job column in the dataset is divided into many sub-categories like technician, blue-collar, services, management, etc. There is no weight or measure given to any value in the ‘job’ column.
Now, let’s analyze the job category by using plots. Since Job is a category, we will plot the bar plot.
# Let's calculate the percentage of each job status category.
data.job.value_counts(normalize=True)
#plot the bar graph of percentage job categories
data.job.value_counts(normalize=True).plot.barh()
plt.show()
The output looks like this,
By the above bar plot, we can infer that the data set contains more number of blue-collar workers compared to other categories.
Categorical Ordered Univariate Analysis:
Ordered variables are those variables that have a natural rank of order. Some examples of categorical ordered variables from our dataset are:
Now, let’s analyze the Education Variable from the dataset. Since we’ve already seen a bar plot, let’s see how a Pie Chart looks like.
#calculate the percentage of each education category.
data.education.value_counts(normalize=True)
#plot the pie chart of education categories
data.education.value_counts(normalize=True).plot.pie()
plt.show()
The output will be,
By the above analysis, we can infer that the data set has a large number of them belongs to secondary education after that tertiary and next primary. Also, a very small percentage of them have been unknown.
This is how we analyze univariate categorical analysis. If the column or variable is of numerical then we’ll analyze by calculating its mean, median, std, etc. We can get those values by using the describe function.
data.salary.describe()
The output will be,
If we analyze data by taking two variables/columns into consideration from a dataset, it is known as Bivariate Analysis.
a) Numeric-Numeric Analysis:
Analyzing the two numeric variables from a dataset is known as numeric-numeric analysis. We can analyze it in three different ways.
Scatter Plot
Let’s take three columns ‘Balance’, ‘Age’ and ‘Salary’ from our dataset and see what we can infer by plotting to scatter plot between salary
balance
and age
balance
#plot the scatter plot of balance and salary variable in data
plt.scatter(data.salary,data.balance)
plt.show()
#plot the scatter plot of balance and age variable in data
data.plot.scatter(x="age",y="balance")
plt.show()
Now, the scatter plots looks like,
Pair Plot
Now, let’s plot Pair Plots for the three columns we used in plotting Scatter plots. We’ll use the seaborn library for plotting Pair Plots.
#plot the pair plot of salary, balance and age in data dataframe.
sns.pairplot(data = data, vars=['salary','balance','age'])
plt.show()
The Pair Plot looks like this,
Correlation Matrix
Since we cannot use more than two variables as x-axis and y-axis in Scatter and Pair Plots, it is difficult to see the relation between three numerical variables in a single graph. In those cases, we’ll use the correlation matrix.
# Creating a matrix using age, salry, balance as rows and columns
data[['age','salary','balance']].corr()
#plot the correlation matrix of salary, balance and age in data dataframe.
sns.heatmap(data[['age','salary','balance']].corr(), annot=True, cmap = 'Reds')
plt.show()
First, we created a matrix using age, salary, and balance. After that, we are plotting the heatmap using the seaborn library of the matrix.
b) Numeric - Categorical Analysis
Analyzing the one numeric variable and one categorical variable from a dataset is known as numeric-categorical analysis. We analyze them mainly using mean, median, and box plots.
Let’s take salary
and response
columns from our dataset.
First check for mean value using groupby
#groupby the response to find the mean of the salary with response no & yes separately.
data.groupby('response')['salary'].mean()
The output will be,
There is not much of a difference between the yes and no response based on the salary.
Let’s calculate the median,
#groupby the response to find the median of the salary with response no & yes separately.
data.groupby('response')['salary'].median()
The output will be,
By both mean and median we can say that the response of yes and no remains the same irrespective of the person’s salary. But, is it truly behaving like that, let’s plot the box plot for them and check the behavior.
#plot the box plot of salary for yes & no responses.
sns.boxplot(data.response, data.salary)
plt.show()
The box plot looks like this,
As we can see, when we plot the Box Plot, it paints a very different picture compared to mean and median. The IQR for customers who gave a positive response is on the higher salary side.
This is how we analyze Numeric-Categorical variables, we use mean, median, and Box Plots to draw some sort of conclusions.
c) Categorical — Categorical Analysis
Since our target variable/column is the Response rate, we’ll see how the different categories like Education, Marital Status, etc., are associated with the Response column. So instead of ‘Yes’ and ‘No’ we will convert them into ‘1’ and ‘0’, by doing that we’ll get the “Response Rate”.
#create response_rate of numerical data type where response "yes"= 1, "no"= 0
data['response_rate'] = np.where(data.response=='yes',1,0)
data.response_rate.value_counts()
The output looks like this,
Let’s see how the response rate varies for different categories in marital status.
#plot the bar graph of marital status with average value of response_rate
data.groupby('marital')['response_rate'].mean().plot.bar()
plt.show()
The graph looks like this,
By the above graph, we can infer that the positive response is more for Single status members in the data set. Similarly, we can plot the graphs for Loan vs Response rate, Housing Loans vs Response rate, etc.
If we analyze data by taking more than two variables/columns into consideration from a dataset, it is known as Multivariate Analysis.
Let’s see how ‘Education’, ‘Marital’, and ‘Response_rate’ vary with each other.
First, we’ll create a pivot table with the three columns and after that, we’ll create a heatmap.
result = pd.pivot_table(data=data, index='education', columns='marital',values='response_rate')
print(result)
#create heat map of education vs marital vs response_rate
sns.heatmap(result, annot=True, cmap = 'RdYlGn', center=0.117)
plt.show()
The Pivot table and heatmap looks like this,
Based on the Heatmap we can infer that the married people with primary education are less likely to respond positively for the survey and single people with tertiary education are most likely to respond positively to the survey.
Similarly, we can plot the graphs for Job vs marital vs response, Education vs poutcome vs response, etc.
Conclusion
This is how we’ll do Exploratory Data Analysis. Exploratory Data Analysis (EDA) helps us to look beyond the data. The more we explore the data, the more the insights we draw from it. As a data analyst, almost 80% of our time will be spent understanding data and solving various business problems through EDA.
Thank you for reading and Happy Coding!!!
#dataanalysis #python
1658359680
O pacote Laravel Share permite que você gere dinamicamente botões de compartilhamento social de redes sociais populares para aumentar o engajamento de mídia social.
Isso permite que os visitantes do site compartilhem facilmente o conteúdo com suas conexões e redes de mídia social.
Neste tutorial, mostro como você pode adicionar links de compartilhamento social em seu projeto Laravel 8 usando o pacote Laravel Share.
Instale o pacote usando o compositor –
composer require jorenvanhocht/laravel-share
config/app.php
arquivo.Jorenvh\Share\Providers\ShareServiceProvider::class
em 'providers'
–'providers' => [
....
....
....
Jorenvh\Share\Providers\ShareServiceProvider::class,
];
'Share' => Jorenvh\Share\ShareFacade::class
em 'aliases'
–'aliases' => [
....
....
....
'Share' => Jorenvh\Share\ShareFacade::class,
];
Execute o comando -
php artisan vendor:publish --provider="Jorenvh\Share\Providers\ShareServiceProvider"
routes/web.php
arquivo.Código concluído
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PageController;
Route::get('/', [PageController::class, 'index']);
PageController
controlador.php artisan make:controller PageController
app/Http/Controllers/PageController.php
arquivo.index() – Crie um link de compartilhamento usando Share::page()
e atribua a $shareButtons1
. Da mesma forma, crie mais 2 links e atribua as variáveis.
Carregue index
a visualização e passe $shareButtons1
, $shareButtons2
, e $shareButtons3
.
Código concluído
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PageController extends Controller
{
public function index(){
// Share button 1
$shareButtons1 = \Share::page(
'https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-in-laravel-8/'
)
->facebook()
->twitter()
->linkedin()
->telegram()
->whatsapp()
->reddit();
// Share button 2
$shareButtons2 = \Share::page(
'https://makitweb.com/how-to-make-autocomplete-search-using-jquery-ui-in-laravel-8/'
)
->facebook()
->twitter()
->linkedin()
->telegram();
// Share button 3
$shareButtons3 = \Share::page(
'https://makitweb.com/how-to-upload-multiple-files-with-vue-js-and-php/'
)
->facebook()
->twitter()
->linkedin()
->telegram()
->whatsapp()
->reddit();
// Load index view
return view('index')
->with('shareButtons1',$shareButtons1 )
->with('shareButtons2',$shareButtons2 )
->with('shareButtons3',$shareButtons3 );
}
}
Criar index.blade.php
arquivo na resources/views/
pasta.
Inclua Bootstrap, CSS de fonte incrível, jQuery e js/share.js. –
<!-- CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<!-- Share JS -->
<script src="{{ asset('js/share.js') }}"></script>
Adicionado CSS para personalizar links de compartilhamento social.
Exiba links de compartilhamento social usando –
{!! $shareButtons1 !!}
Da mesma forma, exiba outros 2 – {!! $shareButtons2 !!} e {!! $shareButtons3 !!}.
Código concluído
<!DOCTYPE html>
<html>
<head>
<title>Add social share button in Laravel 8 with Laravel Share</title>
<!-- Meta -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<!-- Share JS -->
<script src="{{ asset('js/share.js') }}"></script>
<style>
#social-links ul{
padding-left: 0;
}
#social-links ul li {
display: inline-block;
}
#social-links ul li a {
padding: 6px;
border: 1px solid #ccc;
border-radius: 5px;
margin: 1px;
font-size: 25px;
}
#social-links .fa-facebook{
color: #0d6efd;
}
#social-links .fa-twitter{
color: deepskyblue;
}
#social-links .fa-linkedin{
color: #0e76a8;
}
#social-links .fa-whatsapp{
color: #25D366
}
#social-links .fa-reddit{
color: #FF4500;;
}
#social-links .fa-telegram{
color: #0088cc;
}
</style>
</head>
<body>
<div class='container'>
<!-- Post 1 -->
<div class='row mt-5'>
<h2>Datatables AJAX pagination with Search and Sort in Laravel 8</h2>
<p>With pagination, it is easier to display a huge list of data on the page.</p>
<p>You can create pagination with and without AJAX.</p>
<p>There are many jQuery plugins are available for adding pagination. One of them is DataTables.</p>
<p>In this tutorial, I show how you can add Datatables AJAX pagination without the Laravel package in Laravel 8.</p>
<!-- Social Share buttons 1 -->
<div class="social-btn-sp">
{!! $shareButtons1 !!}
</div>
</div>
<!-- Post 2 -->
<div class='row mt-5'>
<h2>How to make Autocomplete search using jQuery UI in Laravel 8</h2>
<p>jQuery UI has different types of widgets available, one of them is autocomplete.</p>
<p>Data is loaded according to the input after initialize autocomplete on a textbox. User can select an option from the suggestion list.</p>
<p>In this tutorial, I show how you can make autocomplete search using jQuery UI in Laravel 8.</p>
<!-- Social Share buttons 2 -->
<div class="social-btn-sp">
{!! $shareButtons2 !!}
</div>
</div>
<!-- Post 3 -->
<div class='row mt-5 mb-5'>
<h2>How to upload multiple files with Vue.js and PHP</h2>
<p>Instead of adding multiple file elements, you can use a single file element for allowing the user to upload more than one file.</p>
<p>Using the FormData object to pass the selected files to the PHP for upload.</p>
<p>In this tutorial, I show how you can upload multiple files using Vue.js and PHP.</p>
<!-- Social Share buttons 3 -->
<div class="social-btn-sp">
{!! $shareButtons3 !!}
</div>
</div>
</div>
</body>
</html>
No exemplo, consertei os links, mas você pode configurá-los dinamicamente.
Personalize o design usando CSS e o número de ícones sociais visíveis usando o controlador.
Usando o pacote Laravel Share, você pode compartilhar links para –
Fonte: https://makitweb.com
1658363460
El paquete Laravel Share le permite generar dinámicamente botones para compartir en redes sociales populares para aumentar la participación en las redes sociales.
Estos permiten a los visitantes del sitio web compartir fácilmente el contenido con sus conexiones y redes sociales.
En este tutorial, muestro cómo puede agregar enlaces para compartir en redes sociales en su proyecto Laravel 8 usando el paquete Laravel Share.
Instale el paquete usando composer –
composer require jorenvanhocht/laravel-share
config/app.php
archivo.Jorenvh\Share\Providers\ShareServiceProvider::class
en 'providers'
–'providers' => [
....
....
....
Jorenvh\Share\Providers\ShareServiceProvider::class,
];
'Share' => Jorenvh\Share\ShareFacade::class
en 'aliases'
–'aliases' => [
....
....
....
'Share' => Jorenvh\Share\ShareFacade::class,
];
Ejecute el comando –
php artisan vendor:publish --provider="Jorenvh\Share\Providers\ShareServiceProvider"
routes/web.php
archivo.Código completado
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PageController;
Route::get('/', [PageController::class, 'index']);
PageController
controlador.php artisan make:controller PageController
app/Http/Controllers/PageController.php
archivo.index (): cree un enlace compartido usando Share::page()
y asigne a $shareButtons1
. Del mismo modo, cree 2 enlaces más y asígnelos a variables.
Cargue la index
vista y pase $shareButtons1
, $shareButtons2
y $shareButtons3
.
Código completado
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PageController extends Controller
{
public function index(){
// Share button 1
$shareButtons1 = \Share::page(
'https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-in-laravel-8/'
)
->facebook()
->twitter()
->linkedin()
->telegram()
->whatsapp()
->reddit();
// Share button 2
$shareButtons2 = \Share::page(
'https://makitweb.com/how-to-make-autocomplete-search-using-jquery-ui-in-laravel-8/'
)
->facebook()
->twitter()
->linkedin()
->telegram();
// Share button 3
$shareButtons3 = \Share::page(
'https://makitweb.com/how-to-upload-multiple-files-with-vue-js-and-php/'
)
->facebook()
->twitter()
->linkedin()
->telegram()
->whatsapp()
->reddit();
// Load index view
return view('index')
->with('shareButtons1',$shareButtons1 )
->with('shareButtons2',$shareButtons2 )
->with('shareButtons3',$shareButtons3 );
}
}
Crear index.blade.php
archivo en resources/views/
carpeta.
Incluya Bootstrap, font-awesome CSS, jQuery y js/share.js. –
<!-- CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<!-- Share JS -->
<script src="{{ asset('js/share.js') }}"></script>
Se agregó CSS para personalizar los enlaces para compartir en redes sociales.
Mostrar enlaces para compartir en redes sociales usando –
{!! $shareButtons1 !!}
Del mismo modo, muestra otros 2 – {!! $shareButtons2 !!}, y {!! $compartirBotones3 !!}.
Código completado
<!DOCTYPE html>
<html>
<head>
<title>Add social share button in Laravel 8 with Laravel Share</title>
<!-- Meta -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<!-- Share JS -->
<script src="{{ asset('js/share.js') }}"></script>
<style>
#social-links ul{
padding-left: 0;
}
#social-links ul li {
display: inline-block;
}
#social-links ul li a {
padding: 6px;
border: 1px solid #ccc;
border-radius: 5px;
margin: 1px;
font-size: 25px;
}
#social-links .fa-facebook{
color: #0d6efd;
}
#social-links .fa-twitter{
color: deepskyblue;
}
#social-links .fa-linkedin{
color: #0e76a8;
}
#social-links .fa-whatsapp{
color: #25D366
}
#social-links .fa-reddit{
color: #FF4500;;
}
#social-links .fa-telegram{
color: #0088cc;
}
</style>
</head>
<body>
<div class='container'>
<!-- Post 1 -->
<div class='row mt-5'>
<h2>Datatables AJAX pagination with Search and Sort in Laravel 8</h2>
<p>With pagination, it is easier to display a huge list of data on the page.</p>
<p>You can create pagination with and without AJAX.</p>
<p>There are many jQuery plugins are available for adding pagination. One of them is DataTables.</p>
<p>In this tutorial, I show how you can add Datatables AJAX pagination without the Laravel package in Laravel 8.</p>
<!-- Social Share buttons 1 -->
<div class="social-btn-sp">
{!! $shareButtons1 !!}
</div>
</div>
<!-- Post 2 -->
<div class='row mt-5'>
<h2>How to make Autocomplete search using jQuery UI in Laravel 8</h2>
<p>jQuery UI has different types of widgets available, one of them is autocomplete.</p>
<p>Data is loaded according to the input after initialize autocomplete on a textbox. User can select an option from the suggestion list.</p>
<p>In this tutorial, I show how you can make autocomplete search using jQuery UI in Laravel 8.</p>
<!-- Social Share buttons 2 -->
<div class="social-btn-sp">
{!! $shareButtons2 !!}
</div>
</div>
<!-- Post 3 -->
<div class='row mt-5 mb-5'>
<h2>How to upload multiple files with Vue.js and PHP</h2>
<p>Instead of adding multiple file elements, you can use a single file element for allowing the user to upload more than one file.</p>
<p>Using the FormData object to pass the selected files to the PHP for upload.</p>
<p>In this tutorial, I show how you can upload multiple files using Vue.js and PHP.</p>
<!-- Social Share buttons 3 -->
<div class="social-btn-sp">
{!! $shareButtons3 !!}
</div>
</div>
</div>
</body>
</html>
En el ejemplo, arreglé los enlaces pero puedes configurarlos dinámicamente.
Personaliza el diseño usando CSS y la cantidad de íconos sociales visibles usando el controlador.
Usando el paquete Laravel Share puede compartir enlaces a –
Fuente: https://makitweb.com
1658370780
Le package Laravel Share vous permet de générer dynamiquement des boutons de partage social à partir de réseaux sociaux populaires pour augmenter l'engagement sur les réseaux sociaux.
Ceux-ci permettent aux visiteurs du site Web de partager facilement le contenu avec leurs connexions et réseaux de médias sociaux.
Dans ce didacticiel, je montre comment vous pouvez ajouter des liens de partage social dans votre projet Laravel 8 à l'aide du package Laravel Share.
Installez le package à l'aide de composer -
composer require jorenvanhocht/laravel-share
config/app.php
le fichier.Jorenvh\Share\Providers\ShareServiceProvider::class
dans 'providers'
-'providers' => [
....
....
....
Jorenvh\Share\Providers\ShareServiceProvider::class,
];
'Share' => Jorenvh\Share\ShareFacade::class
dans 'aliases'
-'aliases' => [
....
....
....
'Share' => Jorenvh\Share\ShareFacade::class,
];
Exécutez la commande -
php artisan vendor:publish --provider="Jorenvh\Share\Providers\ShareServiceProvider"
routes/web.php
le fichier.Code terminé
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PageController;
Route::get('/', [PageController::class, 'index']);
PageController
un contrôleur.php artisan make:controller PageController
app/Http/Controllers/PageController.php
le fichier.index() - Créez un lien de partage en utilisant Share::page()
et attribuez-le à $shareButtons1
. De même, créez 2 autres liens et affectez-les aux variables.
Charger la index
vue et passer $shareButtons1
, $shareButtons2
et $shareButtons3
.
Code terminé
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PageController extends Controller
{
public function index(){
// Share button 1
$shareButtons1 = \Share::page(
'https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-in-laravel-8/'
)
->facebook()
->twitter()
->linkedin()
->telegram()
->whatsapp()
->reddit();
// Share button 2
$shareButtons2 = \Share::page(
'https://makitweb.com/how-to-make-autocomplete-search-using-jquery-ui-in-laravel-8/'
)
->facebook()
->twitter()
->linkedin()
->telegram();
// Share button 3
$shareButtons3 = \Share::page(
'https://makitweb.com/how-to-upload-multiple-files-with-vue-js-and-php/'
)
->facebook()
->twitter()
->linkedin()
->telegram()
->whatsapp()
->reddit();
// Load index view
return view('index')
->with('shareButtons1',$shareButtons1 )
->with('shareButtons2',$shareButtons2 )
->with('shareButtons3',$shareButtons3 );
}
}
Créer index.blade.php
un fichier dans resources/views/
le dossier.
Incluez Bootstrap, CSS font-awesome, jQuery et js/share.js. –
<!-- CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<!-- Share JS -->
<script src="{{ asset('js/share.js') }}"></script>
CSS ajouté pour personnaliser les liens de partage social.
Afficher les liens de partage social en utilisant –
{!! $shareButtons1 !!}
De même, affichez les autres 2 – {!! $shareButtons2 !!}, et { !! $shareButtons3 !!}.
Code terminé
<!DOCTYPE html>
<html>
<head>
<title>Add social share button in Laravel 8 with Laravel Share</title>
<!-- Meta -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<!-- Share JS -->
<script src="{{ asset('js/share.js') }}"></script>
<style>
#social-links ul{
padding-left: 0;
}
#social-links ul li {
display: inline-block;
}
#social-links ul li a {
padding: 6px;
border: 1px solid #ccc;
border-radius: 5px;
margin: 1px;
font-size: 25px;
}
#social-links .fa-facebook{
color: #0d6efd;
}
#social-links .fa-twitter{
color: deepskyblue;
}
#social-links .fa-linkedin{
color: #0e76a8;
}
#social-links .fa-whatsapp{
color: #25D366
}
#social-links .fa-reddit{
color: #FF4500;;
}
#social-links .fa-telegram{
color: #0088cc;
}
</style>
</head>
<body>
<div class='container'>
<!-- Post 1 -->
<div class='row mt-5'>
<h2>Datatables AJAX pagination with Search and Sort in Laravel 8</h2>
<p>With pagination, it is easier to display a huge list of data on the page.</p>
<p>You can create pagination with and without AJAX.</p>
<p>There are many jQuery plugins are available for adding pagination. One of them is DataTables.</p>
<p>In this tutorial, I show how you can add Datatables AJAX pagination without the Laravel package in Laravel 8.</p>
<!-- Social Share buttons 1 -->
<div class="social-btn-sp">
{!! $shareButtons1 !!}
</div>
</div>
<!-- Post 2 -->
<div class='row mt-5'>
<h2>How to make Autocomplete search using jQuery UI in Laravel 8</h2>
<p>jQuery UI has different types of widgets available, one of them is autocomplete.</p>
<p>Data is loaded according to the input after initialize autocomplete on a textbox. User can select an option from the suggestion list.</p>
<p>In this tutorial, I show how you can make autocomplete search using jQuery UI in Laravel 8.</p>
<!-- Social Share buttons 2 -->
<div class="social-btn-sp">
{!! $shareButtons2 !!}
</div>
</div>
<!-- Post 3 -->
<div class='row mt-5 mb-5'>
<h2>How to upload multiple files with Vue.js and PHP</h2>
<p>Instead of adding multiple file elements, you can use a single file element for allowing the user to upload more than one file.</p>
<p>Using the FormData object to pass the selected files to the PHP for upload.</p>
<p>In this tutorial, I show how you can upload multiple files using Vue.js and PHP.</p>
<!-- Social Share buttons 3 -->
<div class="social-btn-sp">
{!! $shareButtons3 !!}
</div>
</div>
</div>
</body>
</html>
Dans l'exemple, j'ai corrigé les liens mais vous pouvez les définir dynamiquement.
Personnalisez la conception à l'aide de CSS et du nombre d'icônes sociales visibles à l'aide du contrôleur.
En utilisant le package Laravel Share, vous pouvez partager des liens vers -
Source : https://makitweb.com
1561523460
This Matplotlib cheat sheet introduces you to the basics that you need to plot your data with Python and includes code samples.
Data visualization and storytelling with your data are essential skills that every data scientist needs to communicate insights gained from analyses effectively to any audience out there.
For most beginners, the first package that they use to get in touch with data visualization and storytelling is, naturally, Matplotlib: it is a Python 2D plotting library that enables users to make publication-quality figures. But, what might be even more convincing is the fact that other packages, such as Pandas, intend to build more plotting integration with Matplotlib as time goes on.
However, what might slow down beginners is the fact that this package is pretty extensive. There is so much that you can do with it and it might be hard to still keep a structure when you're learning how to work with Matplotlib.
DataCamp has created a Matplotlib cheat sheet for those who might already know how to use the package to their advantage to make beautiful plots in Python, but that still want to keep a one-page reference handy. Of course, for those who don't know how to work with Matplotlib, this might be the extra push be convinced and to finally get started with data visualization in Python.
You'll see that this cheat sheet presents you with the six basic steps that you can go through to make beautiful plots.
Check out the infographic by clicking on the button below:
With this handy reference, you'll familiarize yourself in no time with the basics of Matplotlib: you'll learn how you can prepare your data, create a new plot, use some basic plotting routines to your advantage, add customizations to your plots, and save, show and close the plots that you make.
What might have looked difficult before will definitely be more clear once you start using this cheat sheet! Use it in combination with the Matplotlib Gallery, the documentation.
Matplotlib
Matplotlib is a Python 2D plotting library which produces publication-quality figures in a variety of hardcopy formats and interactive environments across platforms.
>>> import numpy as np
>>> x = np.linspace(0, 10, 100)
>>> y = np.cos(x)
>>> z = np.sin(x)
>>> data = 2 * np.random.random((10, 10))
>>> data2 = 3 * np.random.random((10, 10))
>>> Y, X = np.mgrid[-3:3:100j, -3:3:100j]
>>> U = 1 X** 2 + Y
>>> V = 1 + X Y**2
>>> from matplotlib.cbook import get_sample_data
>>> img = np.load(get_sample_data('axes_grid/bivariate_normal.npy'))
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> fig2 = plt.figure(figsize=plt.figaspect(2.0))
>>> fig.add_axes()
>>> ax1 = fig.add_subplot(221) #row-col-num
>>> ax3 = fig.add_subplot(212)
>>> fig3, axes = plt.subplots(nrows=2,ncols=2)
>>> fig4, axes2 = plt.subplots(ncols=3)
>>> plt.savefig('foo.png') #Save figures
>>> plt.savefig('foo.png', transparent=True) #Save transparent figures
>>> plt.show()
>>> fig, ax = plt.subplots()
>>> lines = ax.plot(x,y) #Draw points with lines or markers connecting them
>>> ax.scatter(x,y) #Draw unconnected points, scaled or colored
>>> axes[0,0].bar([1,2,3],[3,4,5]) #Plot vertical rectangles (constant width)
>>> axes[1,0].barh([0.5,1,2.5],[0,1,2]) #Plot horiontal rectangles (constant height)
>>> axes[1,1].axhline(0.45) #Draw a horizontal line across axes
>>> axes[0,1].axvline(0.65) #Draw a vertical line across axes
>>> ax.fill(x,y,color='blue') #Draw filled polygons
>>> ax.fill_between(x,y,color='yellow') #Fill between y values and 0
>>> fig, ax = plt.subplots()
>>> im = ax.imshow(img, #Colormapped or RGB arrays
cmap= 'gist_earth',
interpolation= 'nearest',
vmin=-2,
vmax=2)
>>> axes2[0].pcolor(data2) #Pseudocolor plot of 2D array
>>> axes2[0].pcolormesh(data) #Pseudocolor plot of 2D array
>>> CS = plt.contour(Y,X,U) #Plot contours
>>> axes2[2].contourf(data1) #Plot filled contours
>>> axes2[2]= ax.clabel(CS) #Label a contour plot
>>> axes[0,1].arrow(0,0,0.5,0.5) #Add an arrow to the axes
>>> axes[1,1].quiver(y,z) #Plot a 2D field of arrows
>>> axes[0,1].streamplot(X,Y,U,V) #Plot a 2D field of arrows
>>> ax1.hist(y) #Plot a histogram
>>> ax3.boxplot(y) #Make a box and whisker plot
>>> ax3.violinplot(z) #Make a violin plot
y-axis
x-axis
The basic steps to creating plots with matplotlib are:
1 Prepare Data
2 Create Plot
3 Plot
4 Customized Plot
5 Save Plot
6 Show Plot
>>> import matplotlib.pyplot as plt
>>> x = [1,2,3,4] #Step 1
>>> y = [10,20,25,30]
>>> fig = plt.figure() #Step 2
>>> ax = fig.add_subplot(111) #Step 3
>>> ax.plot(x, y, color= 'lightblue', linewidth=3) #Step 3, 4
>>> ax.scatter([2,4,6],
[5,15,25],
color= 'darkgreen',
marker= '^' )
>>> ax.set_xlim(1, 6.5)
>>> plt.savefig('foo.png' ) #Step 5
>>> plt.show() #Step 6
>>> plt.cla() #Clear an axis
>>> plt.clf(). #Clear the entire figure
>>> plt.close(). #Close a window
>>> plt.plot(x, x, x, x**2, x, x** 3)
>>> ax.plot(x, y, alpha = 0.4)
>>> ax.plot(x, y, c= 'k')
>>> fig.colorbar(im, orientation= 'horizontal')
>>> im = ax.imshow(img,
cmap= 'seismic' )
>>> fig, ax = plt.subplots()
>>> ax.scatter(x,y,marker= ".")
>>> ax.plot(x,y,marker= "o")
>>> plt.plot(x,y,linewidth=4.0)
>>> plt.plot(x,y,ls= 'solid')
>>> plt.plot(x,y,ls= '--')
>>> plt.plot(x,y,'--' ,x**2,y**2,'-.' )
>>> plt.setp(lines,color= 'r',linewidth=4.0)
>>> ax.text(1,
-2.1,
'Example Graph',
style= 'italic' )
>>> ax.annotate("Sine",
xy=(8, 0),
xycoords= 'data',
xytext=(10.5, 0),
textcoords= 'data',
arrowprops=dict(arrowstyle= "->",
connectionstyle="arc3"),)
>>> plt.title(r '$sigma_i=15$', fontsize=20)
Limits & Autoscaling
>>> ax.margins(x=0.0,y=0.1) #Add padding to a plot
>>> ax.axis('equal') #Set the aspect ratio of the plot to 1
>>> ax.set(xlim=[0,10.5],ylim=[-1.5,1.5]) #Set limits for x-and y-axis
>>> ax.set_xlim(0,10.5) #Set limits for x-axis
Legends
>>> ax.set(title= 'An Example Axes', #Set a title and x-and y-axis labels
ylabel= 'Y-Axis',
xlabel= 'X-Axis')
>>> ax.legend(loc= 'best') #No overlapping plot elements
Ticks
>>> ax.xaxis.set(ticks=range(1,5), #Manually set x-ticks
ticklabels=[3,100, 12,"foo" ])
>>> ax.tick_params(axis= 'y', #Make y-ticks longer and go in and out
direction= 'inout',
length=10)
Subplot Spacing
>>> fig3.subplots_adjust(wspace=0.5, #Adjust the spacing between subplots
hspace=0.3,
left=0.125,
right=0.9,
top=0.9,
bottom=0.1)
>>> fig.tight_layout() #Fit subplot(s) in to the figure area
Axis Spines
>>> ax1.spines[ 'top'].set_visible(False) #Make the top axis line for a plot invisible
>>> ax1.spines['bottom' ].set_position(( 'outward',10)) #Move the bottom axis line outward
Have this Cheat Sheet at your fingertips
Original article source at https://www.datacamp.com
#matplotlib #cheatsheet #python