随笔分类 - Python Cookbook
Record techniques in Python
摘要:1. 下载anaconda Anaconda installer for linxu: https://www.anaconda.com/distribution/#linux wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linu
阅读全文
摘要:For Loop ls = [1, 2, 3, 4] for i in ls: print (i) Enumerate Method ls = [1, 2, 3, 4] for i, j in enumerate(ls): print(i, j) Out: 0 1 1 2 2 3 3 4 List
阅读全文
摘要:1. Combine Two Series series1=pd.Series([1,2,3],name='s1') series2=pd.Series([4,5,6],name='s2') df = pd.concat([series1, series2], axis=1) Out: series
阅读全文
摘要:Groupby Count The command returns a series where the index is the name of a Party and the value is the count of that Party. Note that the series is or
阅读全文
摘要:Selecting a Row or Selecting a Column Or Selecting an Element Selecting Multiple Discontinuous Rows Or E.g.
阅读全文
摘要:Using Series (Row-Wise) Using Series (Column-Wise) Using Dictionary (Columnwise) Using Nested Dictionary The outer dictionary is columnwise and the in
阅读全文
摘要:Convert from list Apply np.array() method to convert a list to a numpy array: Apply np.array() method to convert a list to a numpy array: Apply np.arr
阅读全文
摘要:1-D Array Indexing Use bracket notation [ ] to get the value at a specific index. Remember that indexing starts at 0. Output: array([ 0, 1, 2, 3, 4, 5
阅读全文
摘要:1. Using for-loop Iterate along row axis: Output: [1 2 3] [4 5 6] Iterate by index: Output: [1 2 3] [4 5 6] Iterate by row and index: Iterate by row a
阅读全文
摘要:1. Reshape: The np.reshape() method will give a new shape to an array without changing its data. Note that the new shape should be compatible with the
阅读全文
摘要:数组拼接方法一 思路:首先将数组转成列表,然后利用列表的拼接函数 、`extend()`等进行拼接处理,最后将列表转成数组。 示例1: [1, 2, 5, 10, 12, 15] array([ 1, 2, 5, 10, 12, 15]) 该方法只适用于简单的一维数组拼接,由于转换过程很耗时间,对于
阅读全文
摘要:Here is a function in Numpy module which could apply a function to 1D slices along the Given Axis. It works like apply funciton in Pandas. This functi
阅读全文
摘要:You can launch IPython on the command line just like launching the regular Python interpreter except with the ipython command: $ ipython Then you can
阅读全文

浙公网安备 33010602011771号