Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 20,946
» Latest member: blackopsdlc
» Forum threads: 21,999
» Forum posts: 22,966

Full Statistics

Online Users
There are currently 1388 online users.
» 0 Member(s) | 1383 Guest(s)
Applebot, Baidu, Bing, Facebook, Google

Latest Threads
[Steam Release] The Unive...
Forum: New Game Releases
Last Post: xSicKxBot

» Replies: 0
» Views: 4
[DevBlog MS] Creating a m...
Forum: C#, Visual Basic, & .Net Frameworks
Last Post: xSicKxBot

» Replies: 0
» Views: 9
[WoW Retail News] Fixed C...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 11
[PS.Blog] Fading Echo mak...
Forum: Sony Discussion
Last Post: xSicKxBot

» Replies: 0
» Views: 11
[Steam Release] Cowbots a...
Forum: New Game Releases
Last Post: xSicKxBot

» Replies: 0
» Views: 14
[Dev News] September Free...
Forum: Game Development
Last Post: xSicKxBot

» Replies: 0
» Views: 12
Marvel Rivals Venom guide...
Forum: PC Discussion
Last Post: xSicKxBot

» Replies: 0
» Views: 16
[WoW Retail News] Midnigh...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 21
[Steam Release] Kodon
Forum: New Game Releases
Last Post: xSicKxBot

» Replies: 0
» Views: 22
[WoW Retail News] Downloa...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 18

 
  News - NBA 2K23 Detroit Pistons Roster And Ratings
Posted by: xSicKxBot - 09-09-2022, 12:16 PM - Forum: Lounge - No Replies

NBA 2K23 Detroit Pistons Roster And Ratings

NBA 2K23 is here, and that means hoop heads and casual NBA fans will have about a season's worth of debates to start and more than a few Michael Jordan dunks to choreograph. We're breaking down the new NBA 2K23 rosters for all 32 NBA teams, and in this guide we're taking a closer look at the Detroit Pistons. The Pistons still aren't ready to contend for a championship, but they've acquired some solid young talent that could be enjoyable to build around. If you're curious about who the Pistons' best players might be, where their top players rank in the league, or which team positions may need an upgrade in MyNBA Eras, then here's everything you need to know about the new NBA 2K23 Pistons roster.

Detroit Pistons - Best Players

The Pistons are the 27th best team in the league according to the new ratings for all 32 teams in NBA 2K23. At launch, Detroit's set for an overall team rating of 83. The Pistons will also have a total of two players rated 80 or above in NBA 2K23, including a pair of young playmakers:

  • Cade Cunningham (SG) - 84 OVR
  • Jaden Ivey (SG) - 76 OVR

Below you will find a table of the starting roster and bench players for the Detroit Pistons at launch in NBA 2K23, which includes all five starters and their new rookie class of Jalen Duren and Jaden Ivey.

Continue Reading at GameSpot

https://www.gamespot.com/articles/nba-2k...01-10abi2f

Print this item

  PC - Immortality
Posted by: xSicKxBot - 09-09-2022, 12:16 PM - Forum: New Game Releases - No Replies

Immortality



Marissa Marcel was a film star. She made three movies. But none of the movies was ever released. And Marissa Marcel disappeared. An interactive trilogy from Sam Barlow, creator of Her Story.

Publisher: Half Mermaid

Release Date: Aug 30, 2022




https://www.metacritic.com/game/pc/immortality

Print this item

  [Tut] Solidity by Example – Simple Open Auction (Explained)
Posted by: xSicKxBot - 09-08-2022, 04:59 PM - Forum: Python - No Replies

Solidity by Example – Simple Open Auction (Explained)

5/5 – (1 vote)
YouTube Video

This article continues on the series we started the last time: Solidity smart contract examples, which implement a simplified real-world process.

Here, we’re walking through an example of a simple open auction.

? Original Source Code: Solidity Docs

We’ll first lay out the entire smart contract example without the comments for readability and development purposes.

Then we’ll dissect it part by part, analyze it and explain it.

Following this path, we’ll get a hands-on experience with smart contracts, as well as good practices in coding, understanding, and debugging smart contracts.

Smart contract – Simple Open Auction


// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4; contract SimpleAuction { address payable public beneficiary; uint public auctionEndTime; address public highestBidder; uint public highestBid; mapping(address => uint) pendingReturns; bool ended; event HighestBidIncreased(address bidder, uint amount); event AuctionEnded(address winner, uint amount); error AuctionAlreadyEnded(); error BidNotHighEnough(uint highestBid); error AuctionNotYetEnded(uint timeToAuctionEnd); error AuctionEndAlreadyCalled(); constructor( uint biddingTime, address payable beneficiaryAddress ) { beneficiary = beneficiaryAddress; auctionEndTime = block.timestamp + biddingTime; } function bid() external payable { if (block.timestamp > auctionEndTime) revert AuctionAlreadyEnded(); if (msg.value <= highestBid) revert BidNotHighEnough(highestBid); if (highestBid != 0) { pendingReturns[highestBidder] += highestBid; } highestBidder = msg.sender; highestBid = msg.value; emit HighestBidIncreased(msg.sender, msg.value); } function withdraw() external returns (bool) { uint amount = pendingReturns[msg.sender]; if (amount > 0) { pendingReturns[msg.sender] = 0; if (!payable(msg.sender).send(amount)) { pendingReturns[msg.sender] = amount; return false; } } return true; } function auctionEnd() external { if (block.timestamp < auctionEndTime) revert AuctionNotYetEnded(auctionEndTime - block.timestamp); if (ended) revert AuctionEndAlreadyCalled(); ended = true; emit AuctionEnded(highestBidder, highestBid); beneficiary.transfer(highestBid); }
}

Code breakdown and analysis


// SPDX-License-Identifier: GPL-3.0

Compiles only with Solidity compiler version 0.8.4 and later, but before version 0.9.

? Learn More: Layout of a Solidity File

pragma solidity ^0.8.4; contract SimpleAuction {

Parameters of the auction are variables beneficiary and auctionEndTime which we’ll initialize with contract creation arguments while the contract gets created, i.e. in the contract constructor.

Data type for time variables is unsigned integer uint, so that we can represent either absolute Unix timestamps (seconds since 1970-01-01) or time periods in seconds (seconds lapsed from the reference moment we chose).

 address payable public beneficiary; uint public auctionEndTime;

The current state of the auction is reflected in two variables, highestBidder and highestBid.

 address public highestBidder; uint public highestBid;

Previous bids can be withdrawn, that’s why we have mapping data structure to record pendingReturns.

 mapping(address => uint) pendingReturns;

Indicator flag variable for the auction end. By default, the flag is initialized to false; we’ll prevent changing it once it switches to true.

 bool ended;

When changes occur, we want our smart contract to emit the corresponding change events.

 event HighestBidIncreased(address bidder, uint amount); event AuctionEnded(address winner, uint amount);

We’re defining four errors to describe relevant failures. Along with these errors, we’ll also introduce “triple-slash” comments, commonly known as natspec comments. They enable users to see comments when an error is displayed or when users are asked to confirm the transaction.

? Learn More: Natspec comments are formally defined in Ethereum Natural Language Specification Format.

 /// The auction has already ended. error AuctionAlreadyEnded(); /// There is already a higher or equal bid. error BidNotHighEnough(uint highestBid); /// The auction has not ended yet, the remaining seconds are displayed. error AuctionNotYetEnded(uint timeToAuctionEnd); /// The function auctionEnd has already been called. error AuctionEndAlreadyCalled();

Initialization of the contract with the contract creation arguments biddingTime and beneficiaryAddress.

 /// Create a simple auction with `biddingTime` /// seconds bidding time on behalf of the /// beneficiary address `beneficiaryAddress`. constructor( uint biddingTime, address payable beneficiaryAddress ) { beneficiary = beneficiaryAddress; auctionEndTime = block.timestamp + biddingTime; }

A bidder bids by sending the currency (paying) to the smart contract representing the beneficiary, hence the bid() function is defined as payable.

? Learn More: What is payable in Solidity?

 /// Bid on the auction with the value sent /// together with this transaction. /// The value will only be refunded if the /// auction is not won. function bid() external payable {

The function call reverts if the bidding period ended.

 if (block.timestamp > auctionEndTime) revert AuctionAlreadyEnded();

The function rolls back the transaction to the bidder if the bid does not exceed the highest one.

 if (msg.value <= highestBid) revert BidNotHighEnough(highestBid);

The previous highest bidder was outbid and his bid is added to his previous bids reserved for a refund.

? A direct refund is considered a security risk due to the possibility of executing an untrusted contract.

Instead, the bidders (recipients) will withdraw their bids themselves by using withdraw() function below.

 if (highestBid != 0) { pendingReturns[highestBidder] += highestBid; }

The new highest bidder and his bid are recorded; the event HighestBidIncreased is emitted carrying this information pair.

 highestBidder = msg.sender; highestBid = msg.value; emit HighestBidIncreased(msg.sender, msg.value); }

Bidders call the withdraw() function to retrieve the amount they bid.

 /// Withdraw a bid that was overbid. function withdraw() external returns (bool) { uint amount = pendingReturns[msg.sender]; if (amount > 0) {

It is possible to call the withdraw() function again before the send() function returns. That’s the reason why we need to disable multiple sequential withdrawals from the same sender by setting the pending returns for a sender to 0.

 pendingReturns[msg.sender] = 0;

Variable type of msg.sender is not address payable, therefore we need to convert it explicitly by using function payable() as a wrapping function.

If the send() function ends with an error, we’ll just reset the pending amount and return false.

 if (!payable(msg.sender).send(amount)) { // No need to call throw here, just reset the amount owing pendingReturns[msg.sender] = amount; return false; } } return true; }

The auctionEnd() function ends the auction and sends the highest bid to the beneficiary.

The official Solidity documentation recommends dividing the interacting functions into three functional parts:

  • checking the conditions,
  • performing the actions, and
  • interacting with other contracts.

Otherwise, by combining these parts rather than keeping them separated, more than one calling contract could try and modify the state of the called contract and change the called contract’s state.

 /// End the auction and send the highest bid /// to the beneficiary. function auctionEnd() external {

Checking the conditions…

 if (block.timestamp < auctionEndTime) revert AuctionNotYetEnded(auctionEndTime - block.timestamp); if (ended) revert AuctionEndAlreadyCalled();

…performing the actions…

 ended = true; emit AuctionEnded(highestBidder, highestBid);

…and interacting with other contracts.

 beneficiary.transfer(highestBid); }
}

Our smart contract example is a simple, but a powerful one, enabling us to bid an amount of currency to the beneficiary.

When the contract instantiates via its constructor, it sets the auction end time and its beneficiary, i.e. beneficiary address.

The contract has three simple features, implemented via dedicated functions: bidding, withdrawing the bids and ending the auction.

A new bid is accepted only if its amount is strictly larger than the current highest bid. A new bid acceptance means that the current highest bid is added to the bidder’s balance for later withdrawal. The new highest bidder becomes the current highest bidder and the new highest bid becomes the current highest bid.

Bid withdrawing returns all summed previous bids to each bidder (mapping pendingReturns).

Contract Test Scenario


Open auction duration (in seconds): 240

Beneficiary: 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4

Testing/demonstration steps:

  1. Account 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2 bids 10 Wei;
  2. Account 0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db bids 25 Wei;
  3. Account 0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB bids 25 Wei (rejected);
  4. Account 0x617F2E2fD72FD9D5503197092aC168c91465E7f2 bids 35 Wei;
  5. Account 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2 bids 40 Wei + initiates premature auction end;
  6. Account 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2 withdraws his bids;
  7. Account 0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db withdraws his bids;
  8. Account 0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB withdraws his bids;
  9. Account 0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB initiates timely auction end;
  10. Account 0x617F2E2fD72FD9D5503197092aC168c91465E7f2 withdraws his bids;

Appendix – The Contract Arguments


In this section is additional information for running the contract. We should expect that our example accounts may change with each refresh/reload of Remix.

Our contract creation arguments are the open auction duration (in seconds) and the beneficiary address (copy this line when deploying the example):

300, 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4

? Info: we could’ve used any amount of time, but I went with 300 seconds to timely simulate both a rejected attempt of ending the auction and the successful ending of the auction.

Conclusion


We continued our smart contract example series with this article that implements a simple open auction.

First, we laid out clean source code (without any comments) for readability purposes. Omitting the comments is not recommended, but we love living on the edge – and trying to be funny! ?

Second, we dissected the code, analyzed it, and explained each possibly non-trivial segment. Just because we’re terrific, safe players who never risk it and do everything by the book ?



Programmer Humor – Blockchain


“Blockchains are like grappling hooks, in that it’s extremely cool when you encounter a problem for which they’re the right solution, but it happens way too rarely in real life.” source xkcd



https://www.sickgaming.net/blog/2022/09/...explained/

Print this item

  [Tut] PHP Session Destroy after 30 Minutes
Posted by: xSicKxBot - 09-08-2022, 04:59 PM - Forum: PHP Development - No Replies

PHP Session Destroy after 30 Minutes

by Vincy. Last modified on September 6th, 2022.

PHP has a core function session_destroy() to clear all the session values. It is a simple no-argument function that returns a boolean true or false.

The PHP session ID is stored in a cookie by default. Generally that session cookie file is name PHPSESSID. The session_destroy function will not unset the session id in the cookie.

To destroy the session ‘completely’, the session ID must also be unset.

This quick example uses session_destroy() to destroy the session. It uses the set_cookie() method to kill the entirety by expiring the PHP session ID.

Quick example


destroy-session.php

<?php
// Always remember to initialize the session,
// even before attempting to destroy it. // Destroy all the session variables.
$_SESSION = array(); // delete the session cookie also to destroy the session
if (ini_get("session.use_cookies")) { $cookieParam = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $cookieParam["path"], $cookieParam["domain"], $cookieParam["secure"], $cookieParam["httponly"]);
} // as a last step, destroy the session.
session_destroy();

Note:

  1. Use session_start() to reinitiate the session after the PHP session destroy.
  2. Use PHP $_SESSION to unset a particular session variable. For an older PHP version, use session_unset().

php session destroy output

About this login session_destroy() example


Let’s create a login example code to use PHP session, session_destroy and all. It allows users to login and logout from the current session. Use this code if you are looking for a complete user registration and login in PHP script.

This example provides an automatic login session expiry feature.

Landing page with a login form


This form posts the username and the password entered by the user. It verifies the login credentials in PHP.

On successful login, it stores the logged-in state into a PHP session. It sets the expiry time to 30 minutes from the last login time.

It stores the last login time and the expiry time into the PHP session. These two session variables are used to expire the session automatically.

login.php

<?php
session_start();
$expirtyMinutes = 1;
?>
<html>
<head>
<title>PHP Session Destroy after 30 Minutes</title>
<link rel='stylesheet' href='style.css' type='text/css' />
<link rel='stylesheet' href='form.css' type='text/css' />
</head>
<body> <div class="phppot-container"> <h1>Login</h1> <form name="login-form" method="post"> <table> <tr> <td>Username</td> <td><input type="text" name="username"></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password"></td> </tr> <tr> <td><input type="submit" value="Sign in" name="submit"></td> </tr> </table> </form>
<?php
if (isset($_POST['submit'])) { $usernameRef = "admin"; $passwordRef = "test"; $username = $_POST['username']; $password = $_POST['password']; // here in this example code focus is session destroy / expiry only // refer for registration and login code https://phppot.com/php/user-registration...-download/ if ($usernameRef == $username && $passwordRef == $password) { $_SESSION['login-user'] = $username; // login time is stored as reference $_SESSION['ref-time'] = time(); // Storing the logged in time. // Expiring session in 30 minutes from the login time. // See this is 30 minutes from login time. It is not 'last active time'. // If you want to expire after last active time, then this time needs // to be updated after every use of the system. // you can adjust $expirtyMinutes as per your need // for testing this code, change it to 1, so that the session // will expire in one minute // set the expiry time and $_SESSION['expiry-time'] = time() + ($expirtyMinutes * 60); // redirect to home // do not include home page, it should be a redirect header('Location: home.php'); } else { echo "Wrong username or password. Try again!"; }
}
?>
</div>
</body>
</html>

login

Dashboard validates PHP login session and displays login, and logout links


This is the target page redirected after login. It shows the logout link if the logged-in session exists.

Once timeout, it calls the destroy-session.php code to destroy all the sessions.

If the 30 minutes expiry time is reached or the session is empty, it asks the user to log in.

home.php

<?php
session_start();
?>
<html>
<head>
<title>PHP Session Destroy after 30 Minutes</title>
<link rel='stylesheet' href='style.css' type='text/css' />
<link rel='stylesheet' href='form.css' type='text/css' />
</head>
<body> <div class="phppot-container">
<?php
if (! isset($_SESSION['login-user'])) { echo "Login again!<br><br>"; echo "<a href='login.php'>Login</a>";
} else { $currentTime = time(); if ($currentTime > $_SESSION['expiry-time']) { require_once __DIR__ . '/destroy-session.php'; echo "Session expired!<br><br><a href='login.php'>Login</a>"; } else { ?> <h1>Welcome <?php echo $_SESSION['login-user'];?>!</h1> <a href='logout.php'>Log out</a>
<?php }
}
?>
</div>
</body>
</html>

This PHP code is used for users who want to log out before the session expiry time.

It destroys the session by requiring the destroy-session.php code. Then, it redirects the user to the login page.

logout.php

<?php
session_start();
require_once __DIR__ . '/destroy-session.php';
header('Location: login.php');
?>

I hope this example helps to understand how to destroy PHP sessions. And also, this is a perfect scenario that is suitable for explaining the need of destroying the session.
Download

↑ Back to Top



https://www.sickgaming.net/blog/2022/09/...0-minutes/

Print this item

  (Indie Deal) FREE Robot Robert, POSTAL Sale, MythBusters is out
Posted by: xSicKxBot - 09-08-2022, 04:59 PM - Forum: Deals or Specials - No Replies

FREE Robot Robert, POSTAL Sale, MythBusters is out

Robot Robert FREEbie
[freebies.indiegala.com]
Your mission begins in a cave full of riddles, hostile creatures, and dangerous plants.

https://www.youtube.com/watch?v=WKkWVV4IbvM
Running With Scissors Sale
[www.indiegala.com]
https://www.youtube.com/watch?v=ZAbnDdnD2qM


https://steamcommunity.com/groups/indieg...7940535579

Print this item

  (Free Game Key) Shadow of the Tomb Raider Def. Ed. and Submerged: Hidden Depths
Posted by: xSicKxBot - 09-08-2022, 04:59 PM - Forum: Deals or Specials - No Replies

Shadow of the Tomb Raider Def. Ed. and Submerged: Hidden Depths

Grab these games on the Epic Games Store

❤️ Shadow of the Tomb Raider: Definitive Edition
https://store.epicgames.com/p/shadow-of-the-tomb-raider

❤️ Submerged: Hidden Depths
https://store.epicgames.com/p/submerged-hidden-depths-6065a1

Knockout city has some items that are free too

The games is free to keep until Thursday, September 8, 2022 5:00 PM.

Next week's freebies:
Hundred Days - Winemaking Simulator
Realm Royale Reforged Epic Launch Bundle

We are welcoming everyone to join our discord[discord.gg]. We are more active there on finding giveaways, small or large, and there are daily raffles you can participate.

?GrabFreeGames.com ?Twitter ?Steam Curator ?Facebook[fb.me]?Discord[discord.gg]
❤️Support us: HumbleBundle Partner[www.humblebundle.com] Fanatical Affiliate[www.fanatical.com]


https://steamcommunity.com/groups/GrabFr...5115666075

Print this item

  PC - SD Gundam Battle Alliance
Posted by: xSicKxBot - 09-08-2022, 04:59 PM - Forum: New Game Releases - No Replies

SD Gundam Battle Alliance



In SD Gundam Battle Alliance, Mobile Suits and characters from across Mobile Suit Gundam history take center stage in this all-new action RPG.

A Battle Alliance to Correct a False World
The story takes place in G: Universe, a world where Gundam canon twists and turns in ways no one can predict. To correct this world's distorted history, the player leads a 3-unit squadron consisting of Mobile Suits and pilots from across Gundam history - a true Battle Alliance.What Awaits Beyond False History...

Combo action with stunning visuals and dynamic animation
Indulge in a wide array of Mobile Suit weaponry to crush many foes with! Control Mobile Suits portrayed with realistic weathering that showcases them as weapons of war as they tear across the battlefield with dynamic animations.

Strange phenomena known as Breaks are twisting legendary moments from Gundam history, and you're in charge to fix them.
Experience Gundam history's most famous scenes as you develop new Mobile Suits to add to your arsenal. Gather Capital and expansion parts to transform your favorite machine into the ultimate MS.

Tackle missions with friends in multiplayer!
Launch into battle with 2 partners to back you up. In multiplayer, you can play through the game with up to 2 other players in a 3-person team. Enjoy this new SD Gundam action RPG solo, or with friends.

Publisher: Bandai Namco Games

Release Date: Aug 25, 2022




https://www.metacritic.com/game/pc/sd-gu...e-alliance

Print this item

  News - Little Nightmares Is Coming To Mobile This Winter
Posted by: xSicKxBot - 09-08-2022, 04:59 PM - Forum: Lounge - No Replies

Little Nightmares Is Coming To Mobile This Winter

More than five years after it first hit consoles and PC, Little Nightmares is coming to mobile. Developer Tarsier Studios made the announcement as a part of GameSpot's first-ever Swipe Showcase, revealing an Android and iOS version of the horror adventure game is coming later this year.

Set in a grim and mysterious world, Little Nightmares follows a young girl named Six as she navigates a ship filled with unusual horrors. All the while, Six must contend with a ravenous hunger that is taking over her body, leading to some pretty gruesome situations. The game features a dark, almost Coraline-like art style--though its content is decidedly more disturbing than that of the children's story. Little Nightmares explores horror through the eyes of a child and emphasizes the powerlessness they have through "hide-and-seek" style gameplay rather than allowing the players to engage in combat.

In GameSpot's review of Little Nightmares, we praised the game for its "haunting narrative," "tense cat-and-mouse style chases," and "enthralling visual and audio design." However, the game's short length did lead to some criticism.

Continue Reading at GameSpot

https://www.gamespot.com/articles/little...01-10abi2f

Print this item

  [Tut] Python – Finding the Most Common Element in a Column
Posted by: xSicKxBot - 09-06-2022, 10:19 PM - Forum: Python - No Replies

Python – Finding the Most Common Element in a Column

5/5 – (1 vote)

Problem Formulation and Solution Overview


This article will show you how to find the most common element in a Pandas Column.

To make it more interesting, we have the following running scenario:

You have been provided with a downloadable CSV file containing crime statistics for the San Diego area, including their respective NCIC Crime Codes.


? Question: How would you determine the most common NCIC Crime Code that occurs in San Diego’s jurisdiction?

We can accomplish this task by one of the following options:


Preparation


Before moving forward, please ensure the Pandas library is installed. Click here if you require instructions.

Then, add the following code to the top of each script. This snippet will allow the code in this article to run error-free.

import pandas as pd

After importing the Pandas library, this library is referenced by calling the shortcode (pd).


Method 1: Use Pandas mode()


This example uses the mode() method to determine the single most common crime committed in San Diego on a given day.

df = pd.read_csv('crimes.csv', usecols=['crimedescr'])
max_crime = df['crimedescr'].mode()
print(max_crime)

The above code reads in the crimedescr column from the crimes.csv file downloaded earlier. This saves to the DataFrame df.

Next, the crimedescr column is then accessed, and the mode() method is appended. This method returns a value or set of values that appear most often along a selected axis. The results save to max_crime.

These results are output to the terminal.


0 10851(A)VC TAKE VEH W/O OWNER
Name: crimedescr, dtype: object

So, out of 7,854 rows of crimes committed on a given day for San Diego, the above offense was committed the highest number of times.

The above code only provides us with the name of the most common crime; what if we need the crime name and the respective count?

df = pd.read_csv('crimes.csv', usecols=['crimedescr', 'ucr_ncic_code'])
max_crime = df['crimedescr'].mode()
max_count = df['ucr_ncic_code'].mode() print(max_crime)
print(max_count)

The above code is output to the terminal and displays the following.


0 10851(A)VC TAKE VEH W/O OWNER
Name: crimedescr, dtype: object
0 7000
Name: ucr_ncic_code, dtype: int64

Now, you are equipped to return to your boss and tell them that 7,000 offenses of 10851 (A) VC TAKE VEH W/O OWNER occurred on a given day in San Diego.

YouTube Video


Method 2: Use value_counts()


This example uses the value_counts() function to determine the top 5 most common crimes committed in San Diego on a given day.

df = pd.read_csv('crimes.csv', usecols=['crimedescr', 'ucr_ncic_code'])
top5_names = df['crimedescr'].value_counts()[:5].index.tolist()
print(top5_names)

The above code reads in the crimedescr and ucr_ncic_code columns from the crimes.csv file downloaded earlier. This saves to the DataFrame df.

Then, the crimedescr column is accessed, and the value_counts() function is appended. This function returns a series containing the counts of unique values.

However, since slicing is also appended ([:5]), only the top five (5) common crimes are retrieved and then converted to a List. The results save to top5_names.


['10851(A)VC TAKE VEH W/O OWNER', 'TOWED/STORED VEH-14602.6', '459 PC BURGLARY VEHICLE', 'TOWED/STORED VEHICLE', '459 PC BURGLARY RESIDENCE']

The above code only provides us with the names of the top 5 most common crimes; what if we need the names and their respective counts?

df = pd.read_csv('crimes.csv', usecols=['crimedescr', 'ucr_ncic_code'])
top5 = df['crimedescr'].value_counts()[:5].sort_values(ascending=False)
print(top5)

The above output is sent to the terminal.


10851(A)VC TAKE VEH W/O OWNER 653
TOWED/STORED VEH-14602.6 463
459 PC BURGLARY VEHICLE 462
TOWED/STORED VEHICLE 434
459 PC BURGLARY RESIDENCE 356
Name: crimedescr, dtype: int64

YouTube Video

A cleaner way to achieve the same results is to use the following code.

df = pd.read_csv('crimes.csv', usecols=['crimedescr', 'ucr_ncic_code'])
top5 = df['crimedescr'].value_counts().nlargest(5)
print(top5)

The above code calls the nlargest() method to determine and retrieve the top five (5) common crimes. The output is identical to the above.


10851(A)VC TAKE VEH W/O OWNER 653
TOWED/STORED VEH-14602.6 463
459 PC BURGLARY VEHICLE 462
TOWED/STORED VEHICLE 434
459 PC BURGLARY RESIDENCE 356
Name: crimedescr, dtype: int64

A much cleaner and more precise output to send to the boss!


Method 3: Use value_counts() and idxmax()


This example uses value_counts() and idxmax() to determine the single most common crime committed in San Diego on a given day.

df = pd.read_csv('crimes.csv', usecols=['crimedescr', 'ucr_ncic_code'])
max_crime = df['crimedescr'].value_counts().idxmax()
print(max_crime)

The above code reads in the crimedescr and ucr_ncic_code columns from the crimes.csv file downloaded earlier. This saves to the DataFrame df.

Then, the crimedescr column is accessed, and the value_counts() function is appended. This function returns a series containing the count of unique values.

Next, idxmax() is appended. This method returns the index of the first occurrence of the maximum index(es) over a selected axis.

The results save to max_crime and are output to the terminal.


10851(A)VC TAKE VEH W/O OWNER


Method 4: Use value_counts() and keys()


This example uses value_counts() and keys() to determine the top 5 most common crimes committed in unique grid areas of San Diego on a given day.

df = pd.read_csv('crimes.csv', usecols=['crimedescr', 'grid', 'ucr_ncic_code'])
top5_grids = df['grid'].value_counts().keys()[:5]
print(top5_grids)

The above code reads in the crimedescr, grid, and the ucr_ncic_code columns from the crimes.csv file downloaded earlier. This saves to the DataFrame df.

Let’s break the highlighted line down.

If df['grid'].value_counts() was output to the terminal, the following would display (snippet). However, we have added a heading row to make it more understandable, and only five (5) rows are displayed.


Grid # Grid Total
742 115
969 105
958 100
564 80
1084 71

Next, the code keys()[:5] is appended. The final output displays as follows.


Int64Index([742, 969, 958, 564, 1084], dtype='int64')


Method 5: Use groupby()


This examples uses groupby() to group our data on the Crime Code and displays the totals in descending order.

df = pd.read_csv('crimes.csv', usecols=['crimedescr', 'ucr_ncic_code']) res = (df.groupby(['ucr_ncic_code','crimedescr']).size() .sort_values(ascending=False) .reset_index(name='count'))
print(res)

The above code reads in the crimedescr and the ucr_ncic_code columns from the crimes.csv file downloaded earlier. This saves to the DataFrame df.

Next, the groupby() function is called and passed the first argument: df.groupby(['ucr_ncic_code','crimedescr']).size(). If this was output to the terminal at this point, the following would display (snippet).

print(df.groupby(['ucr_ncic_code','crimedescr']).size())

ucr_ncic_code crimedescr
909 2
999 1
197 1
664 1
1099 1

As you can see, the other arguments need to be added to turn this into something usable. Sorting the data in descending order and adding a count column will provide the results we are looking for.

If the original Method 5 code example was output to the terminal, the following would display.


ucr_ncic_code crimedescr count
0 2404 10851(A)VC TAKE VEH W/O OWNER 653
1 7000 TOWED/STORED VEH-14602.6 463
2 2299 459 PC BURGLARY VEHICLE 462
3 7000 TOWED/STORED VEHICLE 434
4 2204 459 PC BURGLARY RESIDENCE 356

YouTube Video


Summary


This article has provided five (5) ways to find the most common element in a Panda Column. These examples should provide you with enough information to select the one that best meets your coding requirements.

Good Luck & Happy Coding!


Programming Humor – Python


“I wrote 20 short programs in Python yesterday. It was wonderful. Perl, I’m leaving you.”xkcd



https://www.sickgaming.net/blog/2022/09/...-a-column/

Print this item

  News - NBA 2K23 Ratings For Players, Rookies, And More
Posted by: xSicKxBot - 09-06-2022, 10:19 PM - Forum: Lounge - No Replies

NBA 2K23 Ratings For Players, Rookies, And More

Wake up babe, NBA 2K23 ratings are here. Visual Concepts' latest dissertation on dropping dimes arrives this week, Friday September 9th, and as a part of their own #2KDay Countdown with brand spotlights, 2K Beats, and J. Cole's Dreamer Edition, they have offered a first look at the official 2K23 overalls--highlighting rising stars, top rookies, and which new shooters are going to swoosh.

The NBA made some noise this summer with LeBron going Drew League and back to the Lake Show, Giannis having dad jokes, Derrick Rose being the internet's “Most Loved” MVP, Trae Young sharing a few scenes from Rico Hines’ UCLA runs, and Donovan Mitchell skipping Knicks threads for Ohio, and because of that, 2K ratings will forever be a status symbol. They set the bar for the season ahead and while our predictions were headlined by new blood, the launch 2K23 ratings settle "Luka vs Curry" and dictate Day One moves in MyTeam, MyNBA Eras, and more. There's a lot to unpack (if you're a Sixers fan), so dive into the Top 10 players list below and stay tuned for more NBA 2K23 ratings.

For more NBA 2K23, check out the "First Look" trailer and info on The Jordan Challenge.

Continue Reading at GameSpot

https://www.gamespot.com/articles/nba-2k...01-10abi2f

Print this item