You are reading the article How To Setup A Logitech Mouse (Beginner’s Guide) updated in December 2023 on the website Hatcungthantuong.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 How To Setup A Logitech Mouse (Beginner’s Guide)
You’ve just bought a new Logitech mouse, but you have no idea how to use it? Well, you don’t need to scratch your head as we bring you the beginner’s guide on how to set up a Logitech mouse.
Interestingly, Logitech has introduced various types of mice since 1982. Whether you’re looking for a normal mouse for your work or you need a multi-functioning gaming mouse, Logitech provides a variety of models.
Well, each type of mouse has a different way of setup. So, let’s jump into how you can use a wired, wireless, and Bluetooth-supporting Logitech mouse.
How to Setup a Wired Logitech MouseWhile using a wireless mouse, you may face issues with the batteries or their connection. The same thing applies to a Bluetooth-supporting mouse. However, when you use a wired one, all you have to do is connect the two ends, and your mouse works completely fine unless there are faults in the cables.
Thus, when we buy a wireless Logitech mouse, we often receive a cable along with it. This is to ensure that if there’s a fault in our wireless connection, we can use the device with the help of the wire.
Well, setting up a wired Logitech mouse is not a difficult task for anyone. Here’s a general idea of how to do it the correct way so that you do not face any issues with the connection:
How Can I Setup a Wireless Logitech Mouse?A wireless mouse runs with the help of radio frequency. Hence, you can even control it from a long distance compared to a wired mouse. However, the obstacles in between may not help you use the mouse from a much larger distance.
If you possess a wireless Logitech mouse, you do not require a dedicated cable to use the device. Nonetheless, you need to check whether your mouse has a USB dongle or not.
Well, most Logitech models provide this inside the box containing your mouse. If you have lost it, you can use the Logitech Unifying receiver that helps connect multiple Logitech input devices.
Before proceeding with the steps below, ensure the wireless Logitech mouse supports your operating system. Now, let’s dive into the detailed guide on setting it up.
Configure Your Mouse BatteryA wireless mouse won’t function if your battery is drained. So, it’s important to insert batteries that are working.
Well, the cells on your Logitech mouse support mostly AA and AAA batteries. For any confusion, we have a comprehensive guide on how to change batteries of a wireless mouse.
In some Logitech mouse models, you have an option to charge your mouse battery. When the device is charging, you see a green light glowing on its dedicated LED.
Plug in Your Wireless USB DongleOnce you’ve configured your mouse batteries, now you need the dedicated USB dongle. Remember that you can’t use another device’s USB receiver.
Well, all you have to do is take the USB dongle and insert it into an available port on your PC. Make sure you have plugged it well so there won’t be a connection issue.
Turn on the MouseThe next step is to turn on your Logitech mouse. The button you’re looking for should be in the bottom section of the device.
By default, the mouse is turned off. To turn it on, simply drag the slider toward the On letter printed on the device. Depending on your Logitech mouse, you’ll have to slide it upwards/downwards, while in some models, you’ll have to drag it sideways. In some models, you can simply press the ON button to turn on the mouse.
Check for the glowing light to ensure your Logitech mouse has turned on. For some reason, your light may not work. In such a case, simply unplug the USB dongle and plug it back again. Then, turn on the mouse, which should now light the LED.
Note: We recommend turning off the mouse once you’ve finished using it. This way, your battery is saved.
Check ConnectionIn some Logitech mice, you may have to press the Connector button in your mouse. However, most modern mice have removed this option. This means that once you plug in the USB and turn on your mouse, the connection will establish automatically.
But, if your model requires a connection to be set up, simply find the connector button on your mouse. Then, use a pin to press it.
Finally, check if your wireless Logitech mouse is working or not. To do so, drag your mouse around; if the pointer is moving well, Bravo! You’ve done it.
Install a Logitech Software [Optional]Well, you can download and install either Logi Options+ or Logitech G Hub. These programs help you change the mouse DPI or even increase the polling rate.
How Do You Set up a Bluetooth Logitech Mouse?Unlike wireless mice, a Bluetooth mouse works only for a shorter distance. Even they use radio waves for communication but in a lower GHz.
Setting up a Bluetooth Logitech mouse is quite similar to a wireless mouse setup. However, there are a few more added steps you need to do to ensure proper connection.
Before moving on, make sure your Logitech mouse supports your OS. Also, ensure your battery is fine. Then, turn on your mouse and press the Connector button, if available. Now, head to the below guide to set up your input device.
Turn on BluetoothFirstly, you must turn on Bluetooth on your mouse and your PC. To turn on the Bluetooth of your mouse, navigate to the bottom and hold the Bluetooth button for a few seconds. This will make the light on your device blink continuously, meaning your mouse is in pairing mode.
Along with the mouse, you need to turn on the Bluetooth of your PC. Here, we will explore the steps on both Windows and macOS.
On Windows 11
On MacOS
Pair Mouse With PCAfter you have turned on the Bluetooth on both mouse and PC, now you need to pair the Logitech mouse with your PC. Here’s a simple guideline to walk you through on both Windows and Mac.
On Windows
On Mac
Once you set up the Bluetooth mouse, you can download and install compatible Logitech software to access additional features. But, if your Bluetooth mouse is lagging, read our other article that will help you fix it.
You're reading How To Setup A Logitech Mouse (Beginner’s Guide)
Xrp Wallets: A Beginner’s Guide To Storing Xrp (2023)
A wallet is necessary in order to store, receive and send XRP. There are many different types of wallets available, and it can be confusing for beginners to know which one to choose.
In this article, we will give you an overview of the most popular XRP wallets so that you can make an informed decision about which one is right for you.
What is an XRP wallet?As the name suggests, an XRP wallet is a digital wallet that can be used to store XRP, the native currency of the Ripple network, and is used to facilitate transactions on the network. These wallets can be used to send, receive and store cryptocurrency.
Types of walletsXRP wallet
An XRP holder has access to a variety of wallets, including hardware, desktop, mobile, exchange, and paper wallets, so they need to choose one that best suits their needs. For instance, if you’re a novice user looking to purchase or hold a small amount of XRP, a desktop or mobile wallet will offer you a fair blend of security and use.
On the other hand, if you need to hold a large amount of XRP for investment purposes or plan to trade XRP frequently, a hardware wallet is the best option.
Hardware walletsA hardware wallet is a physical device designed specifically for storing cryptocurrencies. Hardware wallets are considered to be the most secure type of wallet as they store your funds offline on a physical device. Ledger Nano S and Trezor are popular hardware wallets for XRP.
Desktop walletsA desktop wallet is a software program that you can download and install on your computer. Desktop wallets are considered to be fairly secure as they are not connected to the internet and are, therefore, less vulnerable to hacking. Toast Wallet and Edge are popular desktop wallets.
Mobile walletsA mobile wallet is a software program that you can download and install on your smartphone. Mobile wallets are considered to be fairly secure and very accessible. Edge is a popular mobile wallet for XRP.
Exchange walletsAn exchange wallet is a wallet that is provided by a cryptocurrency exchange. Exchange wallets are considered to be less secure than other types of wallets as they are often connected to the internet, making them more vulnerable to hacking. However, many exchanges offer two-factor authentication and other security features to help protect your assets. GateHub is a popular exchange wallet for XRP.
Paper walletsA paper wallet is a paper copy of your private key. Paper wallets are considered to be very secure as they are less vulnerable to hacking. However, it is important to keep your paper wallet in a safe place as it can be easily lost or stolen. XRP Paper Wallet is a popular paper wallet for XRP.
Security featuresWhen choosing a wallet, it is important to consider the security features that are offered. Some of the most important security features to look for include two-factor authentication, multi-signature support, and a secure connection.
Two-factor authenticationTwo-factor authentication (2FA) is an extra layer of security that is used to verify your identity when logging into your wallet. 2FA requires you to enter a code that is sent to your cell phone in addition to your password, making it more difficult for hackers to gain access to your funds as they would need both your password and access to your cell phone.
Multi-signature supportMulti-signature (multi-sig) support allows you to set up your wallet so that it requires more than one signature to authorize a transaction. This makes it more difficult for hackers to gain access to your assets, as they would need more than one key to sign a transaction.
Secure connectionA secure connection is important for keeping your XRP safe from hackers. Look for XRP wallets that use HTTPS or SSL to encrypt their connection. This will help to ensure that your XRP is safe when you are sending or receiving XRP.
Which XRP wallet should you use?XRP
The type of XRP wallet that you use will depend on your needs. If security is your main concern, then a hardware wallet is the best option. If convenience is your main concern, then a software or web wallet might be better for you.
No matter what wallet you choose, be sure to keep your recovery phrase in a safe place. This phrase is used to recover your XRP if your wallet is lost or stolen.
Should I move XRP to the cold wallet?Ripple cold storage with an XRP cold wallet is recommended for anyone holding XRP, whether you have 100 or 100,000. Cold storage keeps your XRP holdings safe from hacking attempts and other security risks.
An XRP cold wallet is a device that stores your private keys offline, making it impossible for hackers to access them through the internet. Cold wallets can range from hardware devices such as Ledger or Trezor to paper wallets and mobile apps such as Guarda Wallet.
One of the main benefits of cold storage is that it requires you to physically possess your wallet in order to access your funds. This means that even if someone were to gain access to your private keys, they would not be able to move any XRP without having physical possession of the device containing those keys.
Final thoughtsWhen choosing an XRP wallet, it is important to consider your needs and the security features that are offered. Hardware wallets are considered to be the most secure type of wallet, while software and web wallets are more convenient.
Related articles:
What Is Liss Cardio? A Detailed Beginner’s Guide
LISS stands for ‘Low-Intensity Steady State’ which aims for a low level of exertion for a long period of time. LISS cardio exercise is also called steady-state training (SST) which is good for people of all ages and fitness levels. These exercises involve slower aerobic activity and are beneficial for cross-training and endurance.
The types of LISS training include activities like walking, cycling or jogging at a comfortable pace. They are low-intensity cardio activities which concentrate on overall body conditioning rather than focusing on power and speed.
LISS is a steady approach to burning calories and improving cardiovascular health according to the American Heart Association. The AHA recommends getting 30-60 minutes of aerobic activities, three to four times a week for cardiovascular fitness and to minimize the risk of obesity.
Types of LISS CardioThere are many types of LISS cardio exercises that you can incorporate into your fitness routine. As there are many options to choose from, you won’t get bored repeating the same type of LISS cardio. Some of the types include −
Walking at your pace
Hiking
Cycling at home or outdoors
Swimming
Rowing
Skateboarding
Surfing
If you wish to do LISS cardio at the gymnasium, you can use cardio equipment like an elliptical trainer at a moderate pace for about 30 to 45 minutes.
LISS versus HIITOne of the major differences between LISS and high-intensity interval training (HIIT) is the intensity of the workouts. The higher your heart rate, the higher the intensity of the physical activity you are doing. This could be problematic for people with low fitness levels. If you are a beginner, you can spend 20 to 30 minutes on a LISS workout and as you build endurance; your sessions may last up to 60 minutes per day.
HIIT workouts are designed specially to raise your heart rate for burning calories and concentrate on limit-pushing bursts and slowed-down recovery periods.
Some of the major differences between LISS and HIIT include −
Time − LISS workouts are significantly longer as compared to HIIT exercises. HIIT workout usually takes 30 minutes and both workouts may offer the same benefits in terms of calories burned.
Speed − Normally, LISS training is done at the same pace while HIIT alternates periods of intense exercise and includes relatively short recovery time.
Attention and focus − In HIIT workouts, you have to pay more attention to the exercises as you are constantly switching up movements. However, in the LISS cardio workouts, you may require less concentration as you are doing the same activity for a long time.
Benefits of LISS CardioThe primary benefits of LISS cardio include improvisation of cardiovascular health and reducing the risk of heart disease. Nevertheless, the benefits don’t end here. Let us understand the benefits of this LISS cardio for overall fitness.
Aids in recovery − LISS cardio makes your heart pump blood throughout the body and hence, the muscles may get nutrients to heal the micro-damage incurred from the workout sessions. Enhanced recovery and less soreness can motivate you to look forward to your training session.
Fat and calories burning − The body needs oxygen to metabolise fat. The lower the intensity of your activity, the more oxygen is available to be used to break down fat. LISS cardio may also help you achieve a caloric deficit which makes weight loss and fat loss manageable.
Good option if you are tired − You can achieve your fitness goals while avoiding strenuous workouts with the help of LISS cardio exercises. Also, the majority of the LISS exercises can be done outdoors which allows you to get fresh air. LISS cardio can have a mood-boosting effect on you and while increasing your endurance may also act as a stress buster.
Apart from the above-mentioned benefits, LISS cardio may also help lower the risk of high blood pressure, stroke, diabetes and obesity. These workouts may improve cognitive function, mental health, endurance, muscle strength and sleep cycle.
Who Should Do LISS Cardio?If you are new to exercise or are getting back into it, beginning with LISS may help you increase your fitness levels without risking over-exertion. Additionally, if your goal is to improve aerobic fitness, LISS cardio can be a great option.
If you have a sedentary lifestyle, are obese or have knee or back issues, you can opt for LISS cardio as it put less stress on the joints as compared to HIIT and other high-impact workouts.
Usually, HIIT sessions are preferred by people who have less time and need to get fit in a short time. However, HIIT may cause more pressure on the body and mind. Also, if you love doing intense workouts, you still need LISS cardio in your well-balanced workout for cardiovascular training and recovery.
Getting Started with LISS CardioThe best way to design a LISS workout is to think about your hobbies and activities that can be easily incorporated into your lifestyle and schedule. Many forms of LISS cardio may include low to moderate-intensity physical workouts such as −
Doing any one of the activities from walking, dancing, aerobics or water aerobics for 30 minutes
Swimming for 20 minutes
Walk up and down the stairs for 15 minutes
Cycling for 15 minutes
Jumping rope for 15 minutes
Shooting a basket for 30 minutes
You can try these LISS workouts −
Two to four mile walks aiming for a pace between 15 to 18 minutes per mile as per your fitness levels
Hop on a treadmill, cross trainer or exercise bike for 30-60 minutes at a moderate pace
Go for a Vinyasa or flow yoga class
You can begin with walking for 30 to 60 minutes and once you get used to it, try rucking (walking with a weighted backpack). You can also use intervals in between by slowing down for two minutes after 10 rounds and then beginning the walk again.
Word of CautionLISS cardio may feel repetitive and boring, especially in a gym. You can do LISS with your friend to combat boredom as you can hold a conversation in the low-intensity physical activity. However, don’t shift your focus to talking and forget about the workout. Another shortcoming of LISS cardio is that it may cause overuse injuries.
If you experience chronic fatigue, brain fog or prolonged muscle soreness, this could be a sign of overtraining. In any form of workout, may it be high or low intensity, you must give your body adequate time to rest and recover.
ConclusionIf your goal is to improve your fitness, and you have time for longer workouts, LISS cardio may be a good option for you. LISS workouts are the opposite of HIIT workouts and are generally easier for beginners to maintain a healthy weight. To get the most weight loss benefit with LISS, you can add in some strength training and incorporate a nutrition strategy.
Beginner’s Guide To Cryptocurrency Investments For 2023
Throughout the years, the cryptocurrency market has gathered a lot of momentum and investors’ attention from all over the world. Crypto investments are gaining traction as digital assets gain prominence. But, especially for newcomers, investing in cryptocurrencies can be rather difficult. There are more than 22,000 cryptocurrencies available for trading as of February 2023. Not to forget how volatile the cryptocurrency market is. It is indeed crucial to do proper research and refer to a guide who wishes to invest before entering the world of cryptocurrencies.
Understand Cryptocurrencies- It is essential to have a firm grasp of what cryptocurrency is before stepping foot into the realm of cryptocurrency investment. A digital or virtual currency secured by cryptography referred known as cryptocurrency, makes it nearly impossible to forge or double spend. Cryptocurrencies, as opposed to conventional money, are decentralized, meaning they run without the assistance of a central authority or financial institution. There are many other kinds of cryptocurrencies available, with Bitcoin being the most well-known. Ethereum, Litecoin, and Ripple are a few other well-liked cryptocurrencies. Before making an investment in a cryptocurrency, it is crucial to comprehend its fundamentals and features.
Conducting Research- Investing in cryptocurrency is a long-term investment, and it is vital to conduct thorough research before investing in any digital asset. This research involves studying the market trends, the cryptocurrency’s history, and the project’s development team. Researching the market trends will give you an idea of the cryptocurrency’s performance over time while studying the cryptocurrency’s history will give you insight into the project’s viability. Investors should also research the development team responsible for the project. The team’s credentials, experience, and vision will give you an idea of the project’s potential for success. It is crucial to invest in a project with a strong development team with a proven track record.
Choosing the Right Cryptocurrency Exchange- Cryptocurrency exchanges are platforms that allow users to buy, sell, and trade cryptocurrencies. It is crucial to choose the right cryptocurrency exchange to invest in cryptocurrency. Some of the popular cryptocurrency exchanges include Coinbase, Binance, Kraken, and Bitfinex. When selecting a cryptocurrency exchange, it is essential to consider factors such as fees, security, and user interface. Fees are the charges imposed by the cryptocurrency exchange for using their platform. Security is another critical factor to consider when selecting a cryptocurrency exchange. The exchange should have robust security measures to prevent hacking and other cybersecurity threats. Lastly, the user interface should be user-friendly, making it easy for investors to navigate the platform.
Creating a Cryptocurrency Wallet- A cryptocurrency wallet is a digital wallet used to store cryptocurrencies. Cryptocurrency wallets come in two types, hot wallets, and cold wallets. Hot wallets are connected to the internet and are used for quick and easy access to cryptocurrencies. Cold wallets, on the other hand, are offline wallets and are used for long-term storage. Investors must choose the right cryptocurrency wallet to store their digital assets. Some of the popular cryptocurrency wallets include Trezor, Ledger Nano S, and MyEtherWallet. When selecting a cryptocurrency wallet, it is essential to consider factors such as security, user-friendliness, and supported cryptocurrencies.
Investing in Cryptocurrency- Investing in cryptocurrency requires a long-term investment strategy. The volatility of cryptocurrency markets means that the value of digital assets can fluctuate rapidly. As such, it is essential to invest in a cryptocurrency that you believe in and that has a strong potential for long-term growth.
Dollar-cost averaging is a popular investment strategy used in cryptocurrency investment. Dollar-cost averaging involves buying small amounts of a cryptocurrency over a set period, instead of investing a lump sum at once. This strategy helps reduce the impact of market volatility on the investment.
Diversifying Your Portfolio- Diversification is a critical investment strategy used in cryptocurrency investment. Diversification involves investing in multiple cryptocurrencies to spread the investment risk. This strategy helps reduce the risk of loss in case one cryptocurrency underperformance.
Beginner’s Guide For Data Analysis Using Sql
This article was published as a part of the Data Science Blogathon
Overview Important DefinitionsThe most significant part of the database is its tables, which contain all of the data. Normally, data would be divided among several tables rather than being saved all in one location (so designing the data structure properly is very important). The majority of this script would deal with table manipulation. Aside from tables, there are a few more extremely helpful concepts/features that we will not discuss:
table creation
inserting/updating data in the database
functions – takes a value as an input and returns a value that has been manipulated (for example function that remove white spaces)
#Improts import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) import sqlite3 import matplotlib.pyplot as plt # Load data from database.sqlite database = 'database.sqlite' We’ll start by connecting to the database and seeing what tables we have.The query’s basic structure is straightforward: After the SELECT, you specify what you wish to see; * denotes all possible columns. Following the FROM, you select the table. After the WHERE, you add the conditions for the data you wish to use from the table(s).
The section’s structure and order of content, with spaces, new lines, capital letters, and indentation to make the code easier to understand.
conn = sqlite3.connect(database) tables = pd.read_sql("""SELECT * FROM sqlite_master WHERE type='table';""", conn) tables List of countriesThis is the most basic query. The only must part of a query is the SELECT and the FROM (assuming you want to pull from a table)
countries = pd.read_sql("""SELECT * FROM Country;""", conn) countries List of leagues and their countryWhen joining tables, you must do the following:
Choose the type of join you want to utilize. The following are the most common:
INNER JOIN – only maintain records in both tables that match the criterion (after the ON), and records from both tables that don’t match won’t appear in the output.
LEFT JOIN – all values from the first (left) table are combined with the matching rows from the right table. NULL values would be assigned to the columns from the right table that doesn’t have a corresponding value in the left table.
Specify the common value that will be used to link the tables together (the id of the country in that case).
Ensure that at least one of the values in the table is a key. It’s the chúng tôi in our case. Because there can be more than one league in the same nation, the League.country id is not unique.
leagues = pd.read_sql("""SELECT * FROM League JOIN Country ON chúng tôi = League.country_id;""", conn) leagues List of teamsORDER BY defines the sorting of the output – ascending or descending (DESC)
LIMIT limits the number of rows in the output – after the sorting
teams = pd.read_sql("""SELECT * FROM Team ORDER BY team_long_name LIMIT 10;""", conn) teamsWe’ll just show the columns that interest us in this example, so instead of *, we’ll use the actual names.
The names of several of the cells are the same (Country.name, League.name). We’ll use AS to rename them.
This query, as you can see, includes a lot more joins. The reason for this is that the database is designed in a star structure, with one table (Match) containing all of the “performance” and metrics, but only keys and IDs, and other tables including all of the descriptive information (Country, League, Team)
It’s important to note that the Team is joined twice. This is a hard one because, despite the fact that we are using the same table name, we are bringing two separate copies (and rename them using AS). The reason for this is that we need to bring data for two separate values (home team API id and away team API id), and joining them to the same database would imply that they are equal.
It’s also worth noting that the Team tables are linked together using a left join. The reason for this is that I’ve decided to keep the matches in the output, even if one of the teams isn’t on the Team table.
ORDER comes before LIMIT and after WHERE and determines the output order.
detailed_matches = pd.read_sql("""SELECT chúng tôi chúng tôi AS country_name, chúng tôi AS league_name, season, stage, date, HT.team_long_name AS home_team, AT.team_long_name AS away_team, home_team_goal, away_team_goal FROM Match JOIN Country on chúng tôi = Match.country_id JOIN League on chúng tôi = Match.league_id LEFT JOIN Team AS HT on HT.team_api_id = Match.home_team_api_id LEFT JOIN Team AS AT on AT.team_api_id = Match.away_team_api_id WHERE country_name = 'Spain' ORDER by date LIMIT 10;""", conn) detailed_matches Let’s do some basic analyticsHere we are starting to look at the data at a more aggregated level. Instead of looking at the raw data, we will start to group it to the different levels we want to examine. In this example, process the previous query, remove the match and date information, and look at it at the country league season level.
The functionality we will use for that is GROUP BY, which comes between the WHERE and ORDER
Once you chose what level you want to analyze, we can decide the select statement into two:
Dimensions are the values we’re describing, and they’re the same ones we’ll group by later.
Metrics must be grouped together using functions. sum(), count(), count(distinct), avg(), min(), and max() are some of the most common functions.
It’s critical to use the same dimensions in both the select and the GROUP BY functions. Otherwise, the output could be incorrect.
HAVING is another feature that can be used after grouping. This adds another layer of data filtering, this time using the table’s output after grouping. It’s frequently used to clean the output.
leages_by_season = pd.read_sql("""SELECT chúng tôi AS country_name, chúng tôi AS league_name, season, count(distinct stage) AS number_of_stages, count(distinct HT.team_long_name) AS number_of_teams, avg(home_team_goal) AS avg_home_team_scors, avg(away_team_goal) AS avg_away_team_goals, avg(home_team_goal-away_team_goal) AS avg_goal_dif, avg(home_team_goal+away_team_goal) AS avg_goals, sum(home_team_goal+away_team_goal) AS total_goals FROM Match JOIN Country on chúng tôi = Match.country_id JOIN League on chúng tôi = Match.league_id LEFT JOIN Team AS HT on HT.team_api_id = Match.home_team_api_id LEFT JOIN Team AS AT on AT.team_api_id = Match.away_team_api_id WHERE country_name in ('Spain', 'Germany', 'France', 'Italy', 'England') GROUP BY Country.name, League.name, season ORDER BY Country.name, League.name, season DESC ;""", conn) leages_by_season df = pd.DataFrame(index=np.sort(leages_by_season['season'].unique()), columns=leages_by_season['country_name'].unique()) df.loc[:,'Germany'] = list(leages_by_season.loc[leages_by_season['country_name']=='Germany','avg_goals']) df.loc[:,'Spain'] = list(leages_by_season.loc[leages_by_season['country_name']=='Spain','avg_goals']) df.loc[:,'France'] = list(leages_by_season.loc[leages_by_season['country_name']=='France','avg_goals']) df.loc[:,'Italy'] = list(leages_by_season.loc[leages_by_season['country_name']=='Italy','avg_goals']) df.loc[:,'England'] = list(leages_by_season.loc[leages_by_season['country_name']=='England','avg_goals']) df.plot(figsize=(12,5),title='Average Goals per Game Over Time') df = pd.DataFrame(index=np.sort(leages_by_season['season'].unique()), columns=leages_by_season['country_name'].unique()) df.loc[:,'Germany'] = list(leages_by_season.loc[leages_by_season['country_name']=='Germany','avg_goal_dif']) df.loc[:,'Spain'] = list(leages_by_season.loc[leages_by_season['country_name']=='Spain','avg_goal_dif']) df.loc[:,'France'] = list(leages_by_season.loc[leages_by_season['country_name']=='France','avg_goal_dif']) df.loc[:,'Italy'] = list(leages_by_season.loc[leages_by_season['country_name']=='Italy','avg_goal_dif']) df.loc[:,'England'] = list(leages_by_season.loc[leages_by_season['country_name']=='England','avg_goal_dif']) df.plot(figsize=(12,5),title='Average Goals Difference Home vs Out') Query Run OrderNow that we are familiar with most of the functionalities being used in a query, it is very important to understand the order that code runs.
First, order of how we write it (reminder):
SELECT
FROM
JOIN
WHERE
GROUP BY
HAVING
ORDER BY
LIMIT
Define which tables will be used and how they will be connected (FROM + JOIN).
Only the rows that apply to the conditions should be kept (WHERE)
Sort the information by the required level (if need) (BY GROUP)
Select the data you wish to include in the new table. It can contain only raw data (if there is no grouping), or a combination of dimensions (from the grouping), as well as metrics. You’ve decided to show the following from the table.
Order the new table’s output (ORDER BY)
Add extra filtering conditions to the newly generated table (HAVING)
Limit the number of rows – this would reduce the number of rows, as well as the need for filtering (LIMIT)
Sub Queries and FunctionsUse a subquery as a solution. The attributes database would need to be grouped to a different key-player level only (without season). Of course, we would need to decide first how we would want to combine all the attributes to a single row. use AVG, also one can decide on maximum, latest season and etc. Once both tables have the same keys, we can join them together (think of the subquery like any other table, only temporal), knowing that we won’t have duplicated rows after the join.
You can also see two examples of how to use functions here:
– A conditional function is an important tool for data manipulation. While the IF statement is widely used in other languages, SQLite does not support it, hence CASE + WHEN + ELSE is used instead. As you can see, the query would return varied results depending on the data input.
– ROUND – straightforward. Every SQL language comes with a lot of useful functions by default.
players_height = pd.read_sql("""SELECT CASE WHEN ROUND(height)<165 then 165 ELSE ROUND(height) END AS calc_height, COUNT(height) AS distribution, (avg(PA_Grouped.avg_overall_rating)) AS avg_overall_rating, (avg(PA_Grouped.avg_potential)) AS avg_potential, AVG(weight) AS avg_weight FROM PLAYER LEFT JOIN (SELECT Player_Attributes.player_api_id, avg(Player_Attributes.overall_rating) AS avg_overall_rating, avg(Player_Attributes.potential) AS avg_potential FROM Player_Attributes GROUP BY Player_Attributes.player_api_id) AS PA_Grouped ON PLAYER.player_api_id = PA_Grouped.player_api_id GROUP BY calc_height ORDER BY calc_height ;""", conn) players_height players_height.plot(figsize=(12,5)) EndNote About the AuthorConnect with me on Github
The media shown in this article are not owned by Analytics Vidhya and are used at the Author’s discretion.
Related
Beginner’s Guide To Build Data Visualisations On The Web With D3.Js
Introduction
I am sure you have heard this many times
A picture is worth a thousand words.
I think with the proliferation of data, this statement can easily be modified to
A picture is worth thousand(s) of data points.
If you are not convinced, look at the example below.
Storytelling through Data VisualisationLet’s look at the following statement:
“In 2013, Gun Deaths Claimed 11,419 lives in the U.S.”
What comes to your mind first?
In 2013, US saw a lot of gun violence
Gun violence is high in the US
Deaths due to Gun violence were 11,419 (in 2013)
Without visualisation the above are just a set of statistics. Though this stat is useful, it still falls short in conveying the bigger picture. You don’t get the complete context – What kind of people were involved? How much was the nation’s loss? etc.
Let’s see what happens when we visualise it:
Periscope’s US Gun Deaths Visualisation (takes some time to load) – Periscope has made this visualisation that shows the number of people died due to the gun violence in the U.S. in 2013. The orange line denotes the age at which they died and the white line denotes the number of years those people could have lived had they died of natural causes. This visualisation shows what 11,419 lost lives looks like and just how many years of life was stolen from the victims. It is a good example of how we can express the data in a more sublime and impactful manner by using basic animations and interactivity.
“When we present the data as a story, it gives a range of new perspectives and a much more holistic view of the situation which helps policy makers in making informed decisions.”
The Web as a platform for visualisationA lot of organisations are already using web / mobile applications showing dashboards to your mobile as well at your laptop and computer.
How chúng tôi fits in the picture?Enter chúng tôi , a powerful library that enables you to build customized visualisations for any kind of storytelling you could imagine for the web.
Let’s look at another amazing visualisation :
Hans Rosling’s 200 Countries, 200 Years, 4 Minutes – Hans tries to explain the change in health and income in the last 200 years across 200 countries of the world in just 4 minutes by utilising the power of effective visualisation.
The properties of this graph are as follows:
The x axis is the income per person in $/year and the y axis is the life expectancy in years.
Each sphere represents a country, countries of the same continent are of the same colour.
The size of the sphere represents the population of the country.
As time passes and countries improve in terms of life expectancy and/or per capita income the spheres start moving towards top-right of the graph.
Notice how by using simple visual encodings like shape, size, colour, etc. such complex information(200 years of data) is conveyed across. We will talk about what is visual encoding and this visualisation in detail in the upcoming articles.
What if I tell you the above visualisation is created using chúng tôi That’s the potential of chúng tôi Hopefully, we will learn to create magic of our own too 🙂
Setup your machineWe would be needing a few things before starting:
Text Editor – Any text editor of choice, though I’d recommend Sublime Text . It’s a free, multi-platform text editor with useful features like syntax highlighting and code completion.
Browser – Any modern browser. I’d recommend Google Chrome. This tutorial will assume you are using Chrome.
Web Server – In its simplest form, a web server is a software that helps you deliver content over the internet. You can relate a web server to a real server in a restaurant, that “serves” the dishes you request.
Note: Since chúng tôi is designed to make visualisations on the web, it can fetch data over the internet from a web server to show visualisations. Hence we will also be working with a small server of our own.
Create a simple web server in PythonStep 1: Go to the directory you want to keep your chúng tôi project.
Step 2: Python 2.7.x users can start the server by typing the code in the command line:
python -m SimpleHTTPServerPython 3.x users can do so by type the code in command line:
You can check your python version by:
python --versionNote: For windows users, please install anaconda and then open anaconda prompt.
This should give an output similar to the following:
Step 3: Here “0.0.0.0” is your server’s IP address and “8000” is the port number. Imagine you have ordered your favorite pizza and you need to give your house address to complete the order. You will first give the Street Name and then the House Number, here IP address is analogous to street name (i.e. It identifies your computer) and Port number is analogous to the house number that helps you reach a particular house (i.e. identifies the process on your computer) in a building.
You will get an output like this:
Congratulations, you are now on your way to build your first chúng tôi visualisation!
Technical Interlude – Brushing up basics of HTML, CSS, JavaScript and SVGBefore diving into D3, we need to know some web development basics. The web is built on three main pillars: HTML, CSS and JavaScript. Also, for a clearer understanding of chúng tôi you should know the basics of SVG. We will have a crash course on these topics with some task based questions.
Note: You can skip this section if you are familiar with HTML, CSS and JavaScript. In case you have some doubts or need help, each task is followed by a stepwise guide 🙂
We have a list of four tasks to complete before we can get started with D3. Tasks 1 to 3 are based on HTML,CSS and JavaScript. Task 4 is based on SVG and related topics.
Let’s start with our first task!
Task 1. Create a basic HTML page with the text “Hello World” :For this task, you would need to :
Know the basic structure of an HTML page.
Create a new file in Sublime Text and save your HTML code with “.html” extension.
Start your python server and access the file in a browser.
Try doing this task on your own before checking the solution 🙂
Solution:
HTML or Hypertext Markup Language describes the structure of your web pages. HTML uses “tags”, a kind of syntax to form the skeletal structure of a web page. Specific text enclosed between angular brackets form a tag.
Let’s create our first HTML !
Create a new file in your folder and save it with the name index.html
Copy the following code into it and save
Start your server
python -m SimpleHTTPServer 8000
Congratulations! You just made your first web page. Let’s get into some details:
For example :
Task 2. Add formatting and styling to the text using CSS. Specifically, we want to increase size, bring the text to the center of the page, add colour and change its typeface:
For this task you would need to :
Include your CSS in your HTML.
Know about some commonly used CSS rules especially rules related to “font”.
Have an idea about CSS selectors(like id, class etc.) and how they help in setting rules for HTML elements.
Save your changes and refresh the browser page to see the effect.
Try doing this task on your own before checking the solution 🙂
Solution:
CSS or Cascading Style Sheets is used to add styling and formatting to web pages. In other words, it helps to set a variety of rules(like: position, color, formatting etc.) that make the HTML look pretty. Let’s make our own web page pretty!
Let’s think what we can do to make our text look better?
Align the text in the center
Add colour
Change font family(font style)
Increase the size of font
The CSS code for above changes will be:
text-align: center; /*align our text in center*/ color: teal; /*write your favourite colour here */ font-family: Tahoma; /*change font family*/ font-size: 66px; /*set font size to 66 pixels*/
Now we have our CSS ready, how to tell our CSS where do these rules apply?
#myText{ text-align: center; /*align our text in center*/ color: teal; /*set color to teal*/ font-family: Tahoma; /*change font family*/ font-size: 66px; /*set font size to 66 pixels*/ }
Note: that we use the # symbol to call id in our CSS. This tells CSS to look for an element with the id = “myText”.
Save your HTML file, Refresh the page and voila!
CSS Selectors – Selectors are way our CSS is able to know which HTML elements does the rule applies to? We have already learned about the id selector.
Now imagine, that if we have multiple paragraphs and we want to do the same styling to each? Surely we can repeat the ids for all elements but an id is supposed to be unique. We can use a class selector to group the elements that belong to the same class of styling.
.text-beautify{ text-align: center; /*align our text in center*/ color: teal; /*set color to teal*/ font-family: Tahoma; /*change font family */ font-size: 66px; /*set font size to 66 pixels*/ }
Note: We use “.” (dot) to tell our CSS we mean a class.
This is how you group elements with similar styling by adding a class to them.
For this task you would need to:
Learn basic javascript syntax like how to create functions, variables.
How to update CSS property of an element using javascript.
Include your javascript code in your HTML.
How to add images to HTML.
The image gif can be downloaded from here
Try doing this task on your own before checking the solution 🙂
Solution:
JavaScript is a programming language that adds immense functionality to a basic HTML web page. Almost all the “cool” things that you see in a website are because of the amazing power and flexibility JavaScript provides. It runs in the browser, unlike python and other programming languages you don’t need to install JavaScript, as long as you have a browser you can easily run it. Let’s add some special effects to impress our friend on his / her birthday!
You can download the image we are going to use from here. Save it with the name “happybday.gif”
Also, notice we have given an id to the image this is because we might want to add some CSS rules to our image.
Things like id, src add more functionality to our HTML elements and are hence called attributes. Attributes follow a general syntax of attributename = attributevalue. We will be dealing with them a lot in D3.
#image{ visibility: hidden;/* hide the image */ width: 100%; /* set width of image to 100% of body */ height: 50%; /* set height of image to 50% of body */ }
var show = function(){ var txt = document.getElementById(“myText”), img = document.getElementById(“image”); txt.innerHTML = “Happy Birthday! :D”; img.style.visibility = “visible”; }
Save it and refresh your browser page. You’ll see something similar to this:
Isn’t it amazing what 5 lines of JavaScript can achieve? Let us dive into the code and understand what each line does:
var show = function(){ – Here we create a function with the name show. The syntax for creating a function in JavaScript is :
var functionname = function(){Or
functionname(){
var txt = document.getElementById(“myText”) – we are telling javascript to bring the element that has id(nickname) of “myText” and store it as a variable of name txt. Now if we make any changes in txt it will reflect in our HTML element.
img = document.getElementById("image");
This is the syntax to change an element’s CSS property using javascript:
elementvariable.style.propertyname = propertyvalueCongratulations! So far so good, you have successfully learnt the building blocks of web! We will be learning more about them as we go ahead with our D3 journey 🙂
If you want to dig deeper into Web Technologies, you can look at W3Schools . For chúng tôi only basic understanding is required.
In order to build with D3 we also need a basic knowledge of SVG. The following tasks are designed to give you a brief intro into the world of SVG:
Task 4. Draw a group of two blue circles of radius 50px each. Fill the circle with blue colour and red boundary of some thickness using an SVG.For this task you would need to :
Have a basic idea about coordinate spaces in SVG.
Learn about basic shapes like circles and line using SVGs.
Learn about some attributes like “fill”, “stroke”.
Use “groups” of SVG.
Try doing this task on your own before checking the solution 🙂
Solution:
SVG or Scalable Vector Graphics is a format used to draw xml based graphics and animations. SVG graphics do NOT lose any quality if they are zoomed or resized.
SVG provides some basic shapes like lines, rectangles, circle, ellipse, polygon to work with. You can also create custom shapes by combining or tweaking these shapes. For extremely customisable graphics(like country maps, etc.) we use paths. A lot of these will refresh your high school geometry 🙂 Let’s go through each one:
Line
One of the simplest graphic. A line is formed when we join two points separated by a distance. There can be many such lines joining two points but we are interested in a straight line. For example, you and your friend are standing some distance apart, if you walk straight to him the path you’ll follow will make a straight line.
Create a new html file in your D3 project folder with the name “svg.html”
Let’s add basic HTML:
Let’s create our svg element with a width of 500px and a height of 500px:
The Line changes to blue. “stroke” sets the color of the stroke that will make the line. stroke along with x1,x2,y1,y2 are all attributes that define and affect our graphics.
A Side Note – Coordinate space in SVG:
Those of you who know a little about coordinate system in geometry would be finding something strange with the line. The line should be like this :
This is because the origin(0,0) in SVG is at the “top-left” corner as opposed to conventional “bottom-left”.
As we move towards the right the x value increases and on moving down y value increases.
Enough of serious talk, let’s draw !
Circle
Let’s add a circle with center coordinates as (100,100) and radius 50px and color “blue”:
Let’s give it a red boundary of 5px thickness:
Notice the use of stroke and stroke-width for the boundary.
Let’s create another circle :
Notice how the other circle is black because we haven’t added any attributes other than radius and center position. We want to apply same styling to this circle too, in such cases we use groups.
Groups
Let us move both of our circles into a group and apply stroke, fill and stroke-width attributes to the group as a whole. Our svg would look like:
You can read more about svg here, for using D3, only basic understanding of svg is required.
D3.js – Unpacking the nameD3’s name comes from the fact that it is designed to act as a driver for web documents(web page) based on the available data (json, csv, tsv etc.). In other words,
“D3’s magic helps you to create beautiful, interactive visualisations from seemingly boring data(json,csv,etc.)”
We will get to know more about it as we go deeper into D3. You can also look at some of the awesome visualisations created using chúng tôi 🙂
Building with D3.jsLet’s get our hands dirty with D3!
We will create a new html file , with name “barchart.html” in our D3 folder. Let us also put some basic html in our file :
Including chúng tôi libraryNote: This article uses version 3 of chúng tôi . You can find the documentation here.
Adding an element d3.select(“body”).append(“p”).text(“Our First Paragraph using D3!”);Wasn’t that easy? Let’s try to understand our D3 code:
d3.select(“body”).append(“p”).text(“Our First Paragraph using D3!”);Let’s walk through what just happened. In sequence, we:
Invoked D3’s .select(..) method, which selects a single element from the DOM using CSS selector syntax. (We selected the body.)
Set the text content of that new, empty paragraph to “Our First Paragraph using D3!”
All of those crazy dots are just part of D3’s chain syntax. The chain syntax is possible because every time you call a D3 function on an object it performs some operations on it and returns a reference to the new object, which in turn gets picked up by the next function in the chain.This is called method chaining. Note that the above task could have also achieved by calling each function separately like we do conventionally.
Adding CSS stylingOur text looks boring let us add some css styling to it and see what happens:
d3.select("body").append("p").text("Our First Paragraph using D3!").style({"font-size":"40px","font-family":"arial"});Much better! We use .style(….) to add css styling in D3. Our chain has become too long to fit in a single line, let’s us arrange it :
var p = d3.select(“body”).append(“p”).text(“Our First Paragraph using D3!”); p.style({“font-size”:”40px”,”font-family”:”arial”}); Data bindingWhat is data binding and why should I do it?
Data binding is when you associate your data to DOM elements so that the properties of DOM represent properties of data.
Data visualisation is mapping of data values to visuals so instead of looking at columns , rows and numbers , we can look at graphics that are easier to comprehend and derive inferences with lesser effort.
Hence you need to bind your data to the DOM elements in order to represent it as a visualisation. chúng tôi provides powerful ways to bind data in different forms(csv,tsv, json etc.) to the DOM.
Let’s create a data array :
var data_values = [5,10,30,8,45,24,16,55,60];Note: In javascript an array is an equivalent of collections of R or lists of Python.
var p = d3.selectAll("p") .data(data_values).enter().append("p").text("hello world"); p.style({"font-size":"20px","font-family":"arial"});Let’s see what does our browser show:
Whoa that was a lot of method chaining. We have got our text nine times on the page each as a paragraph. Let us break down the code:
d3.select(“body”) – Select body in the DOM.
Since we don’t have any paragraphs it will return an empty selection. Think of this as the selection of paragraphs that will soon exist.
.enter() – This is the function where all the magic happens. This function adds a placeholder element to our DOM for our data values and returns a reference to the same.
.text(“hello world”) – We add text content to our paragraphs.
This is how the entire process looked like:
We follow the similar process all throughout our code in D3. Hence it is important that you understand it thoroughly.
Where is our data?Did you notice that even though we got nine paragraphs, but we don’t see any data? Where did it go?
Remember the line where I said that every line following data(..) will be executed nine times, once for each value? D3 provides us a way to access each value while it iterates over them. Let’s check that value, edit the code to:
var p = d3.selectAll("p").data(data_values).enter().append("p").text(function(value){ return value; }); p.style({"font-size":"20px","font-family":"arial"});This time instead of directly providing text content we create a function inside text(..). D3 executes this function every time it goes over our data. Each time this function is called, it is passed the value for which it is called. That means if we are on the first element of the array this function will be called with 5. We return the same value to our text(..) function so that it can add it to the text content of the paragraph. Here’s our data:
Drawing SVG with D3Just like html elements, creating svg with D3 is quite easy(one line easy!). For example we want to create an svg with width 500px and height 500px :
var svg = d3.select(“body”).append(“svg”).attr({“width”:450,”height”:400});Let us draw a circle in this svg. We want to create a circle of radius 30 and centre at (50,50):
svg.append(“circle”).attr({“r”:”30px”, “cx”:”50px”, “cy”:”50px”});Notice how we used append(..) to add a circle to our svg.
Let us add fill to our circle and increase the radius:
svg.append(“circle”).attr({“r”:”50px”, ”fill”: “red” , “cx”:”50px”, “cy”:”50px”});You can see that the same attributes we learnt in the svg work here. D3 provides an easy interface to create SVGs programmatically.
Simple Barchart
A bar chart is a graphic that presents grouped data with rectangular bars. Here lengths of bars are proportional to the values they represent.
Drawing bars
svg.append("rect").attr({“x”:”30px”, “y”:”30px”, "width":"30px", "height":"100px"});Notice how the (x,y) control the starting point of the rectangle. Let us add colour to our bar but before we will store our rectangle in a variable so that we can reuse it again. Let’s do that:
var bars = svg.append(“rect”).attr({“x”:”30px”, “y”:”30px”, "width":"30px", "height":"150px"}); bars.attr(“fill”, ”blue”);Let us create bars based on our data values. We will use the same process that we used to bind data earlier. Our bars variable will change to:
var bars = svg.selectAll("rect").data(data_values).enter().append("rect").attr("width","25px").attr("height", function(d){ return d; });We have chosen a fixed width of 25 pixels for each bar and we are setting height based our data_values array. Let us see how the graphic looks:
Weren’t we supposed to get nine rectangles? We have nine rectangles but since we have not given different x values they all lie on the same position. Let’s add different x values to our bars:
bars.attr(“x”, function(d,i){ return i*30; }); What is the “i”We already know D3 passes the current data value while iterating through our data. Along with the current value it also passes the current value’s index. This index helps us keep track of the iteration count. What we are doing is we are giving i*30 as x value for our bars. This is because the i will denote the index of the current value and 30 is there because we know each bar’s width is 25 pixels so we give a padding of 5 pixels between each bar.
Let’s refresh our page and we got our 9 data bars !:
Isn’t our bars a little funky? Let’s scale our heights a little bit. Let’s multiply d by 5 in our height function:
.attr(“height”, function(d){ return d*5; });Much better, but why are the bars upside down?
Remember that SVG Coordinate space is different as compared to conventional? Here Origin is at the top left corner so our y-axis starts from the top. Let’s adjust this so that we get a proper bar chart, we can change this by subtracting the height of each bar from the total height of the svg(400px).
bars.attr(“y”, function(d){ return 400-d*5; });Let’s give a nice color to our bars:
bars.attr(“fill”, “steelblue”);Let’s add some more values to our data_values array , it should now look like this:
var data_values = [5,10,30,8,45,24,16,55,60,45,32,18,11,3];Do you think this visualisation is efficiently conveying the information? No, there are many things that can be improved so that we are able to convey inferences in as efficient manner as possible. One such improvement can be :
“Highlighting min and max bars so that as soon as we put our gaze on the visualisation we get an idea of the two extremes, we won’t have to go through each bars and hence this will save our time.”
Let’s do that!
We first need to find the two extremes in our dataset. Lucky for us, D3 provides d3.max(..) and d3.min(..) functions that we can use:
var max = d3.max(data_values); var min = d3.min(data_values);We will have to now select those two bars two have max and min value respectively , for that we’ll use D3’s filter(..) method. What this will do is select only those bars that match the filter. In this case we will have filter for maximum value. We will add “green” colour fill to the bar:
bars.filter(function(d){ return d==max; }).attr(“fill”,”green”);Similarly for the smallest bar, we will add “red” fill colour:
bars.filter(function(d){ return d==min; }).attr(“fill”,”red”);There we have our simple barchart in less than 20 lines of code!
End NotesI have included all the code of this article is available on github. Also check out these small visualisations that I created for fun to get a glimpse of some cool stuff we can do by knowing just the basics of D3 :
I urge you to try them out on your own. Good luck!
You can check out my next article on chúng tôi here
Related
Update the detailed information about How To Setup A Logitech Mouse (Beginner’s Guide) on the Hatcungthantuong.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!