·¢²¼Ê±¼ä:2022-11-30 21:34:02 ÎÄÕÂÀ´Ô´:»¥ÁªÍø
΢²© ΢ÐÅ QQ¿Õ¼ä

¡¾Kaggle¡¿>´û¿îÈ˵ÄÄêÁ伯ÖÐÔÚʲôÄêÁä¶Î£¿£¨Ò»£©

¡¾Kaggle¡¿>´û¿îÈ˵ÄÄêÁ伯ÖÐÔÚʲôÄêÁä¶Î£¿£¨Ò»£©

´û¿î˵Ã÷ ->

´û¿îÊÇÒøÐлòÆäËû½ðÈÚ»ú¹¹°´Ò»¶¨ÀûÂÊ´û³ö»õ±Ò×ʽ𲢱ØÐë¹é»¹µÄÒ»ÖÖÐÅÓûÐÎʽ¡£¹ãÒåµÄ´û¿îÊÇÖ¸´û¿î¡¢ÌùÏÖ¡¢Í¸Ö§µÈ½è´û×ʽðµÄ×ܳơ£ÒøÐÐͨ¹ý´û¿îÊͷż¯ÖеĻõ±ÒºÍ»õ±Ò×ʽ𣬿ÉÒÔÂú×ãÉç»áÀ©´óÔÙÉú²ú²¹³ä×ʽ𡢴ٽø¾­¼Ã·¢Õ¹µÄÐèÒª¡£Í¬Ê±£¬ÒøÐÐÒ²¿ÉÒÔ»ñµÃ´û¿îÀûÏ¢ÊÕÈ룬Ôö¼ÓÒøÐÐ×ÔÉíµÄ»ýÀÛ¡£

Êý¾ÝÔ´->

±¾ÎÄÊý¾ÝÀ´×ÔÒÔÏÂÍøÖ·£º

À´×Ô Kaggle Êý¾Ý¼¯¡£

ÎÊÒ»¸öÎÊÌâ ->

1.´û¿îÈ˼¯ÖÐÔÚÄĸöÄêÁä¶Î£¿

2. ´û¿îÈ˵ÄÄÐÅ®±ÈÀýÊǶàÉÙ£¿

3¡¢´û¿îÆÚÏÞµÄÑ¡ÔñÇãÏò£¿

4.´û¿îÈ˵ÄѧÀú·Ö²¼ÈçºÎ£¿

Êý¾ÝÇåÏ´ ->

ͨ¹ýÒÔϲ½Ö轫Êý¾ÝÏÂÔص½µçÄÔ²¢µ¼Èëµ½¿Í»§¶Ë£ºNavicat¡£

µ¼ÈëÊý¾Ýºó£¬¿ÉÒÔÖ±½Óͨ¹ý¿Í»§¶ËÐ޸ıíÃû£¬Ò²¿ÉÒÔÔËÐÐSQLÓï¾äÐ޸ıíÃûµ½loan¡£

rename table `loan payments data` to loan;

ÇåÀíÊý¾ÝÒÔ¹©ºóÐø·ÖÎö¡£

1.Ö´ÐÐÒÔÏÂÓï¾äɾ³ý¶àÓàµÄÁС£

ALTER TABLE loan
DROP loan_status,
DROP effective_date,
DROP due_date,
DROP paid_off_time,
DROP past_due_days;

²éѯִÐнá¹û£¬±£ÁôÐèÒª·ÖÎöµÄÖ÷ÒªÐÅÏ¢£º

ɾ³ýIDÁÐÖеÄÖظ´Öµ£¬Ö´Ðкó±íÖн«Ã»ÓпÕÖµ¡£

SELECT DISTINCT loan_ID FROM loan;

Ð޸ıíÖÐÁÐÃû£¬·½±ã¹Û²ì

ALTER TABLE loan RENAME COLUMN Loan_ID TO ID,
RENAME COLUMN Principal TO ±¾½ð,
RENAME COLUMN terms TO ÆÚÏÞ,
RENAME COLUMN age TO ÄêÁä,
RENAME COLUMN education TO ½ÌÓý³Ì¶È,
RENAME COLUMN Gender TO ÐÔ±ð;

½á¹û£º

È»ºó½«followersÁеÄÊý¾ÝÀàÐÍת»»ÎªÕûÊýÀàÐÍ£º

ALTER TABLE loan
MODIFY ±¾½ð INT,
MODIFY ÆÚÏÞ INT,
MODIFY ÄêÁä INT;

Êý¾Ý·ÖÎö ->

1. ×ÜÊý¾Ý

Ö´ÐÐÏÂÃæµÄÓï¾ä£¬ÔÚÊý¾ÝÇåÏ´µÄʱºòÒ»Ö±ÔÚÖظ´¡£

SELECT COUNT(ID) FROM loan;

ËüÏÔʾֻÓÐ 500 ¸öÊý¾ÝÑù±¾¡£¶ÔÓÚÊý¾Ý·ÖÎö£¬Êý¾ÝÑù±¾ÓеãС¡£³öÓÚѧϰĿµÄ£¬ËüÃÇÊ×ÏÈÓÃÓÚÊý¾Ý·ÖÎö¡£ºóÆÚÊìÁ·Ö®ºóÔÙÕÒÊý¾ÝÁ¿±È½Ï´óµÄ×ÊÁÏ¡£

2¡¢±¾½ð±ÈÀý

SELECT  ±¾½ð, COUNT(±¾½ð) AS ÊýÁ¿,CONCAT(ROUND(COUNT(±¾½ð)/(SELECT COUNT(*)FROM loan)*100 ,2),'%') AS Õ¼±È FROM loan
GROUP BY ±¾½ð
ORDER BY Õ¼±È DESC ;

3. ÐÔ±ð±ÈÀý

SELECT  ÐÔ±ð, COUNT(ÐÔ±ð) AS ÊýÁ¿,CONCAT(ROUND(COUNT(ÐÔ±ð)/(SELECT COUNT(*)FROM loan)*100 ,2),'%') AS Õ¼±È FROM loan
GROUP BY ÐÔ±ð;

4.´û¿îÆÚÏÞ

SELECT  ÆÚÏÞ, COUNT(ÆÚÏÞ) AS ÊýÁ¿,CONCAT(ROUND(COUNT(ÆÚÏÞ)/(SELECT COUNT(*)FROM loan)*100 ,2),'%') AS Õ¼±È FROM loan
GROUP BY ÆÚÏÞ
ORDER BY Õ¼±È DESC ;

Îå¡¢ÄêÁä·Ö²¼

--Ñù±¾ÖÐ×î´óÄêÁä
SELECT MAX(ÄêÁä) FROM loan;
--Ñù±¾ÖÐ×îСÄêÁä
SELECT MIN(ÄêÁä) FROM loan;
--Ñù±¾ÄêÁä²î
SELECT MAX(ÄêÁä)-(SELECT MIN(ÄêÁä)FROM loan) FROM loan;
--ÄêÁä²îΪ33£¬½«ÄêÁä·ÖΪ4¶Î
SELECT elt(interval(ÄêÁä,16,25,35,45,55),
			 '16~25','26~35','36~45','46~55') as ÄêÁä¶Î,
			 count(ÄêÁä) AS ÊýÁ¿,
			 CONCAT(ROUND(COUNT(ÄêÁä)/(SELECT COUNT(*)FROM loan)*100 ,2),'%') AS Õ¼±È
FROM loan
GROUP BY 1
ORDER BY ÊýÁ¿ DESC;

Áù¡¢½ÌÓý³Ì¶È

SELECT  ½ÌÓý³Ì¶È, COUNT(½ÌÓý³Ì¶È) AS ÊýÁ¿,CONCAT(ROUND(COUNT(½ÌÓý³Ì¶È)/(SELECT COUNT(*)FROM loan)*100 ,2),'%') AS Õ¼±È FROM loan
GROUP BY ½ÌÓý³Ì¶È
ORDER BY Õ¼±È DESC ;

½áÂÛÓ뽨Òé->

´ÓÉÏÃæµÄ·ÖÎö¿ÉÒÔ¿´³ö£º

1¡¢ÔÚ´û¿îÖÐÑ¡Ôñ»¹¿î¶î¶Èʱ£¬´ó²¿·ÖÈËÑ¡Ôñ×î¸ß´û¿î¶î¶È1000³¤ÆÚ³öÊÛ½è´ûÊý¾Ý£¬Ö»ÓÐÉÙ²¿·ÖÈËÑ¡Ôñ1000ÒÔÏ£¬¶øÔÚÕâ¸öÊý¾ÝÖУ¬84.6%µÄ´û¿îÈËÊÇÄÐÐÔ£¬¿É¼ûÔÚ·¢Õ¹µÄʱºò´û¿îÈË¿ÉÒÔ°ÑÖصã·ÅÔÚÄÐÈËÉíÉÏ¡£

2¡¢26~35ËêÄêÁä¶ÎÈËȺռÑù±¾´û¿îÈ˵Ä62.40%¡£Õâ¸öÄêÁä¶ÎµÄÈ˸üÏñÊÇÔÚÉú»îºÍ¹¤×÷ÖÐŬÁ¦Æ´²«µÄÄêÇáÈË¡£Ò»Çж¼²»ÊǺÜÎȶ¨£¬Éú»îÖÐËûÃÇËƺõÐèÒª¸ü¶à¡£´û¿îµÄ°ïÖú£»¸ßÖкʹóѧ¸÷Õ¼ÊܽÌÓý³Ì¶ÈµÄ40%×óÓÒ£¬×ÜÌåÉÏûÓÐËæÊܽÌÓý³Ì¶È±ä»¯¶øÔö¼Ó»ò¼õÉÙµÄÇ÷ÊÆ¡£ËüÒ²¿ÉÄÜÊܵ½Ñù±¾Á¿Ð¡µÄÓ°Ïì¡£

3¡¢´û¿î¹«Ë¾ÔÚ¿ª·¢´û¿î¶ÔÏóʱ£¬¿ÉÖصã¹Ø×¢26-35Ëê¡¢¾ßÓдóר»ò¸ßÖÐÎÄ»¯³Ì¶ÈµÄÄÐÐÔ¡£Êý¾ÝÏÔʾ³¤ÆÚ³öÊÛ½è´ûÊý¾Ý£¬Õⲿ·ÖÈ˸üÐèÒª´û¿î°ïÖú¡£

ÁíÒ»ÊÓ½Ç

»»Ò»»»