日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

notebook python 内嵌 数据库_python数据分析:在jupyter notebook上使用pythonSQL做数据分析...

發(fā)布時間:2024/7/23 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 notebook python 内嵌 数据库_python数据分析:在jupyter notebook上使用pythonSQL做数据分析... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

python數(shù)據(jù)分析:在jupyter notebook上使用python&SQL做數(shù)據(jù)分析

發(fā)布時間:2019-01-14 21:14,

瀏覽次數(shù):1143

, 標簽:

python

jupyter

notebook

SQL

類似于在jupyter上使用R語言,同樣可以使用SQL語句:

詳細見github項目:https://github.com/catherinedevlin/ipython-sql

<>安裝ipython-sql

pip install ipython-sql

<>載入

%load_ext sql

<>連接數(shù)據(jù)庫 同 SQLAlchemy

* postgresql://will:[email?protected]/shakes

* mysql+pymysql://scott:[email?protected]/foo

* oracle://scott:[email?protected]:1521/sidname

* sqlite://

* sqlite:///foo.db

*

mssql+pyodbc://username:[email?protected]/databasedriver=SQL+Server+Native+Client+11.0

我是使用的是mysql,本地鏈接,用戶名ffzs,密碼666666,test數(shù)據(jù)庫:

%sql mysql+pymysql://ffzs:[email?protected]/test

<>簡單使用

%matplotlib inline import matplotlib.pyplot as plt plt.style.use('bmh')

<>1.顯示表

%%sql show tables;

<>2.選取steam_users表的前5行

df = %sql select * from steam_users limit 5 df.DataFrame()

<>3.計算表中包含多少游戲數(shù)和玩家數(shù)

%%sql select count(distinct Game) gameCount, count(distinct UserID) userCount

from steam_users

<>4.篩選出擁有用戶前十的游戲

%%sql data << select Game , count(1) as count from steam_users where Action=

'play' group by Game order by count desc limit 10

data.DataFrame()[::-1].plot.barh("Game","count")

<>5.篩選出被玩總時長前十的游戲

%%sql playHour << select Game,sum(Hours) as playHour from steam_users where

Action="play" group by Game order by playHour desc limit 10

playHour.DataFrame()[::-1].plot.barh('Game', 'playHour')

<>6.篩選出被玩平均時長前十的游戲

%%sql avgHour << select Game, avg(Hours) as avgHour from steam_users where

Action='play' group by Game order by avgHour desc limit 10

avgHour.DataFrame()[::-1].plot.barh('Game','avgHour')

<>7.平均時長前十的游戲的游戲人數(shù)

%%sql select Game, avg(Hours) as avgHour, count(1) as count from steam_users

where Action='play' group by Game order by avgHour desc limit 10

聯(lián)系join on:

%%sql select a.Game, avgHour, count from (select Game, avg(Hours) as avgHour

from steam_users where Action='play' group by Game order by avgHour desc limit

10) a left join (select Game ,count(1) as count from steam_users where Action=

'play' group by Game) b on a.Game=b.Game order by avgHour desc

可見平均時長長的游戲大多是小眾游戲

<>8.玩家人數(shù)大于500人的游戲的個數(shù)(having使用)

%%sql select count(1) as count from (select Game, count(1) as count from

steam_userswhere Action='play' group by Game having count > 500) a

<>9.擁有游戲數(shù)量前十用戶

%%sql games << select UserID, count(1) count from steam_users where Action=

'play' group by UserID order by count desc limit 10

games.DataFrame()[::-1].plot.barh('UserID','count')

<>10.游戲總時長最多5個用戶和最少5個用戶(union使用)

%%sql (select UserID, sum(Hours) as allHour from steam_users where Action=

'play' group by UserID order by allHour desc limit 5) union (select UserID, sum(

Hours) as allHour from steam_users where Action='play' group by UserID order by

allHourlimit 5)

總結(jié)

以上是生活随笔為你收集整理的notebook python 内嵌 数据库_python数据分析:在jupyter notebook上使用pythonSQL做数据分析...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 青青草综合 | 肉色超薄丝袜脚交一区二区 | 999国产精品视频免费 | 亚洲国产精品久久久久婷婷老年 | 最新中文字幕av | 在线视频a | 毛片视频免费观看 | 日韩一区二区a片免费观看 伊人网综合在线 | 天天操天天干天天干 | 欧洲自拍偷拍 | 国产精品乱码一区 | 日韩在线视频网址 | h网站在线播放 | 国产精品一区二区性色av | 国产精品久久777777 | 国产麻豆成人传媒免费观看 | 免费观看亚洲 | 特黄aaaaaa私密按摩 | 日韩高清网站 | 少妇精品无码一区二区免费视频 | www欧美色 | 伊人一级片 | 97干在线| 欧美第一夜 | 性五月天 | 超碰公开在线观看 | 特级西西www444人体聚色 | 国产无码精品一区二区 | 国产区在线 | 啪啪网站免费看 | 波多野结衣免费观看视频 | 美女少妇一区二区 | 日本少妇电影 | 国产美女黄色片 | 日日射日日干 | 超碰999| 超碰夜夜| 日本裸体xx少妇18在线 | 午夜怡红院 | 亚洲成人诱惑 | 亚洲综合另类小说 | 日韩视频在线一区二区 | 久久免费成人 | 玖玖免费| 久久精品视频一区 | 999精品国产 | 99热欧美| 国产精品视频一区二区三区不卡 | 久久久久亚洲av成人无码电影 | 激情五月色播五月 | 在线观看 一区 | 国产黄色在线 | 自拍视频在线观看 | 中文在线一区二区三区 | 香蕉爱爱视频 | 久久蜜桃av一区二区天堂 | 亚洲电影中文字幕 | 久久久久久五月天 | 成年人在线免费观看视频网站 | 午夜不卡福利视频 | 男人免费视频 | 久久综合激情网 | 激情小说亚洲色图 | 国产三区精品 | 中文字幕乱码中文字幕 | 亚洲精品尤物 | 新超碰在线 | 久久精品黄 | 亚洲精品久久久久久 | 欧美日韩精品久久 | 视频一区二区三 | 日韩一卡二卡三卡四卡 | 女同一区二区 | 亚洲一区二区三区高清 | 久久网亚洲 | 国产美女无遮挡免费 | 亚洲精品手机在线 | 男人天堂中文字幕 | 91精品啪 | 亚洲av无码一区二区三区在线观看 | 国产熟女一区二区 | 一级黄色淫片 | 香蕉视频在线观看视频 | 国产精品白嫩白嫩大学美女 | 一区二区 亚洲 | 天堂аⅴ在线最新版在线 | 久久久久国产精品国产 | 欧美日韩国产三区 | 秋霞99 | 国产老头户外野战xxxxx | 久久久久久久成人 | 国产成人av一区二区三区 | 97人妻精品一区二区三区软件 | 黄色美女免费网站 | 亚洲av综合色区无码另类小说 | 欧美精品日韩少妇 | 超碰pron | 日韩三级欧美 | 亚洲最大av网站 |