17-numpy笔记-莫烦pandas-5】的更多相关文章

代码 import pandas as pd import numpy as np dates = pd.date_range('20130101', periods=6) df=pd.DataFrame(np.arange(24).reshape((6,4)),index=dates, columns=['A','B','C','D']) # 行数,列数,赋值 df.iloc[0,1] = np.nan df.iloc[1,2] = np.nan # 以行丢掉 print('-1-') pri…
代码 import pandas as pd import numpy as np dates = pd.date_range('20130101', periods=6) df=pd.DataFrame(np.arange(24).reshape((6,4)),index=dates, columns=['A','B','C','D']) # 行数,列数,赋值 df.iloc[1,2] = 1111 df.loc['20130101','B'] = 2222 print('-1-') prin…
代码 import pandas as pd import numpy as np dates = pd.date_range('20130101', periods=6) df=pd.DataFrame(np.arange(24).reshape((6,4)), index=dates, columns=['A','B','C','D']) print('-1-') print(df) print('-2-') print(df['A'],df.A) print('-3-') print(df…
代码 import pandas as pd import numpy as np import matplotlib.pyplot as plt data = pd.Series(np.random.randn(1000),index=np.arange(1000)) data = data.cumsum() data.plot() plt.show() 结果 -------------------------------------------------------------------…
代码 import pandas as pd import numpy as np left=pd.DataFrame({'key':['K0','K1','K2','K3'], 'A':['A0','A1','A3','A3'], 'B':['B0','B1','B2','B3'],}) right=pd.DataFrame({'key':['K0','K1','K2','K3'], 'C':['C0','C1','C3','C3'], 'D':['D0','D1','D2','D3'],})…
代码 import pandas as pd import numpy as np s = pd.Series([1,3,6,np.nan, 44,1]) print('-1-') print(s) dates = pd.date_range('20160101', periods=6) print('-2-') print(dates) # index 是行的key; 默认就是数字 df = pd.DataFrame(np.random.randn(6,4), index=dates, col…
代码 import numpy as np array = np.array([[1,2,5],[3,4,6]]) print('-1-') print('数组维度', array.ndim) print('-2-') print('', array.shape) a = np.array([1,2,3]) print('-3-') print(a) a = np.array([1,2,3], dtype=np.int) print('-4-') print(a.dtype) a = np.ar…
代码 import numpy as np A = np.arange(3,15) print('-1-') print(A) print('-2-') print(A[3]) A = np.arange(3,15).reshape((3,4)) print('-3-') print(A[1]) print('-4-') print(A[2][1]) # 第一行和第二行 print('-5-') print(A[1:3]) print('-6-') for row in A: print (ro…
记性不好,多记录些常用的东西,真·持续更新中::先列出一些常用的网址: 参考了的 莫烦python pandas DOC numpy DOC matplotlib 常用 习惯上我们如此导入: import pandas as pd import numpy as np import maplotlib.pyplot as plt pandas 篇 pd.Series是一种一维的数组结构,可以列表形式初始化,得到的Series的index默认∈[0,n) s = pd.Series([1, 3,…
bilibili莫烦tensorflow视频教程学习笔记 1.初次使用Tensorflow实现一元线性回归 # 屏蔽警告 import os os.environ[' import numpy as np import tensorflow as tf # create dataset x_data = np.random.rand(100).astype(np.float32) y_data = x_data * 2 + 5 ### create tensorflow structure St…