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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

计算机语言pandas,计算机语言python100道pandas(含答案)

發布時間:2025/4/5 python 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 计算机语言pandas,计算机语言python100道pandas(含答案) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

大學生

1.Import pandas under the name pd .

In [1]:

import pandas as pd

import numpy as np

2.Print the version of pandas that has been imported.

In [2]:

pd.__version_

3.Print out all the version information of the libraries that are required by the pandas library In [3]:

pd.show_versions()

4.Create a DataFrame df from this dictionary data which has the index labels .

In [2]:

data = {'animal': ['cat', 'cat', 'snake', 'dog', 'dog', 'cat', 'snake', 'cat', 'dog

'age': [2.5, 3, 0.5, np.nan, 5, 2, 4.5, np.nan, 7, 3],

'visits': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],

'priority': ['yes', 'yes', 'no', 'yes', 'no', 'no', 'no', 'yes', 'no', 'no']

labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

df = pd.DataFrame(data, index=labels)

5. Display a summary of the basic information about this DataFrame and its data.

In [5]:

http://doc.xuehai.net()

# ...or...

df.describe()

6.Return the first 3 rows of the DataFrame df

In [6]:

df.iloc[:3]

# or equivalently

df.head(3)

7.Select just the 'animal' and 'age' columns from the DataFrame df .

In [7]:

df.loc[:, ['animal', 'age']]

# or

df[['animal', 'age']]

8.Select the data in rows [3, 4, 8] and in columns ['animal', 'age'] .

In [3]:

df.loc[df.index[[3, 4, 8]], ['animal', 'age']]

9.Select only the rows where the number of visits is greater than 3.

In [4]:

df[df['visits'] > 3]

10. Select the rows where the age is missing, i.e. is NaN .

In [5]:

df[df['age'].isnull()]

11. Select the rows where the animal is a cat and the age is less than 3.

In [6]:

總結

以上是生活随笔為你收集整理的计算机语言pandas,计算机语言python100道pandas(含答案)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。