import numpy as np
import pandas as pd
import time
import warnings
warnings.filterwarnings('ignore')
pandas数据结构
l = np.array([1,2,3,6,9])
s1 = pd.Series(data=l)
display(l,s1)
array([1, 2, 3, 6, 9])
0 1
1 2
2 3
3 6
4 9
dtype: int32
s2 = pd.Series(data = l,index = list('ABCDE'))
s2
A 1
B 2
C 3
D 6
E 9
dtype: int32
s3 = pd.Series(data = {'A':149,'B':130,'C':118,'D':99,'E':66})
s3
A 149
B 130
C 118
D 99
E 66
dtype: int64
df1 = pd.DataFrame(data = np.random.randint(0,151,size=(10,3)),
index = list('ABCDEFHIJK'),
columns=['python','math','english'],
dtype = np.float16)
df1
pythonmathenglishA120.076.039.0B10.0139.085.0C69.014.033.0D85.097.0144.0E132.011.035.0F129.025.0148.0H45.066.095.0I148.054.061.0J56.014.081.0K55.0137.0104.0
df2 = pd.DataFrame(data={'python':[66,99,128],'math':[88,65,137],'english':[100,121,45]})
df2
pythonmathenglish0668810019965121212813745
数据查看
df = pd.DataFrame(data = np.random.randint(0,151,size=(100,3)),
columns=['python','math','english'])
df
pythonmathenglish015011183131137412126129130391231184966822…………9521297896347609713421111981081301379912710559
100 rows × 3 columns
df.shape
(100, 3)
df.head(n=3)
pythonmathenglish015011183131137412126129130
df.tail(n=5)
pythonmathenglish9521297896347609713421111981081301379912710559
df.dtypes
python int32
math int32
english int32
dtype: object
df.info()
`
RangeIndex: 100 entries, 0 to 99
Data columns (total 3 columns):
# Column Non-Null Count Dtype
ValueError Traceback (most recent call last)
Input In [106], in
ValueError Traceback (most recent call last)
Input In [32], in
Original: https://blog.csdn.net/weixin_44556829/article/details/124700504
Author: pandazdy
Title: Pandas个人最强笔记
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/742031/
转载文章受原作者版权保护。转载请注明原作者出处!