Python related article index (9) __python

Source: Internet
Author: User
Tags arithmetic matplotlib tutorial
Environment Deployment

Resolves the issue where pycharm cannot import a local package (unresolved reference ' tutorial ')

① Clear Cache and reboot (File-->invalidate Caches\restart)
② set the source directory basic knowledge

How to implement print not wrap in python3.x

Print ("I wish you all good health", end= ', ')
this penalty, replacing the default newline character \ n

W =stringvar (), where W.get and W.set () mean

In Python, Stringvar is a variable string, get () and set () are the basic common sense of getting and setting their content Tkinter tkinter Baidu Encyclopedia Python GUI Programming (Tkinter) Debug

Tkinter.messagebox.showinfo doesn ' t always work

This is a problem with the import method, if you direct import Tkinter may appear as an error, you need to replace the import Tkinter.messagebox or from Tkinter import MessageBox. Data Science Environment Deployment Anaconda install Keras denoted Win7 integrated graphics installation tensorflow1.0 fool steps basic Knowledge of the game: how to understand the confidence level of ice and fire. NumPy

Numpy.zeros (Np.zeros) Use method –python Learning notes 31

usage : Zeros (Shape, dtype=float, order= ' C ')
returns : Returns a 0-filled array of the given shape and type;
Example :
Np.zeros (5)
Array ([0., 0., 0., 0., 0.])

NumPy Concise tutorial (Ii., array 2)

The reshape function changes the shape of the calling array and returns the array

The use of Numpy.clip () Numpy.fabs () in Python, and the description of Math.pow ()

Application of Numpy.clip (A,a_min,a_max,a=none):
Method Explanation: Clip (limit) The values in the array.
This method gives an interval in which the number outside the interval is clipped to the edge of the interval, for example given an interval [0,1], then the less than 0 will become 0, and greater than 1 becomes 1.

Usage of nonzero () in Python numpy

Nonzeros (a) returns the subscript of an element whose value is not zero in array A, its return value is a tuple of length A.ndim (the number of axes of an array a), and each element of the tuple is an array of integers with values that are not 0 elements subscript on the corresponding axis.

The Axis=0,axis=1 in Python

Axis=0 Express Column
Axis=1 Express Line

Numpy.newaxis

Literally inserting the meaning of a new dimension

Numpy.concatenate

Join a sequence of arrays along an existing axis.

Learning NumPy (2)

NumPy. Nan to mark an illegal value, which is not a real value. Pandas

"Original" 10 minutes to fix pandas

Summary of the use of Pandas (II.)

Pandas Library Learning Notes (i) series Introductory study

Series is a one-dimensional array structure that can be stored in any one by one Python data types (integers, strings, floating point numbers, Python objects, etc.).

Pandas tutorial: [22] fill missing values

When there is a Nan missing value in the data, we can replace Nan with other values, mainly using the Dataframe.fillna () method

Pandas tutorial: [24] deleting missing data

If the data volume is larger or redundant, we can delete the missing value of the data, you can choose to remove rows or delete columns, with Dataframe.dropna (), of course, series also have Dropna method, the same use.

"Using Python for Data analysis" Reading notes – Chapter Fifth Pandas Introduction

Pandas data Structure Introduction
Two data structures: series and Dataframe . The
Series is an object similar to an NumPy array, consisting of a set of data (various numpy data types) and a set of data labels (that is, indexes) associated with it. Indexes and values can be specified separately using index and value. If no index is specified, 0 to N-1 indexes are created automatically. The
Dataframe is a tabular structure that contains an ordered set of columns, each of which can be of different data types. Both row and column indexes can be considered as dictionaries composed of series (using a common index). With other similar data structures (such as data.frame in R), Dataframe-oriented operations for rows and columns are basically balanced. In fact, the data in the dataframe is stored in one or more two-dimensional blocks (not lists, dictionaries, or other). Pandas data merging and remodeling (join/merge) Sklearn using Sklearn as a stand-alone feature project
There is a word that is widely circulated in the industry: data and characteristics determine the upper limit of machine learning, and the model and algorithm are just approaching this limit. What exactly is the characteristic project? As the name suggests, its essence is an engineering activity, designed to maximize the extraction of features from raw data for use in algorithms and models. Use Sklearn to perform data mining gracefully
Data mining typically includes steps such as data acquisition, data analysis, feature engineering, training models, and model evaluations. Use the Sklearn tool to facilitate feature engineering and model training based on Spark automatic extension Scikit-learn (spark-sklearn) matplotlib Python 3 Next Matplotlib Paint legned (legend) Chinese display garbled resolution
① find fonts in your computer, choose a Chinese font
② Right-click its properties to learn about the font name
③ then define matplotlib font management in your program. This is named Zhfont1, and the code is as follows:

Zhfont1 = Matplotlib.font_manager. Fontproperties (fname= ' C:\Windows\Fonts\simkai.ttf ')
④ is finally invoked in legend via the prop parameter:
Plt.legend (PROP=ZHFONT1)

Matplotlib Tutorial (translated)

An image (figure) means the entire window of the user interface. In an image, you can have some sub extents (subplot). Subplot places the drawing in a regular grid position and axes allows for more free placement.

Matplotlib visualization--moving Axes (center position)

Matplotlib Learning Notes –legend

Show legend Debug

Unicodedecodeerror: ' ASCII ' codec can ' t decode byte 0xe0 in position 0:ordinal not in range (128)
In Anaconda Shell use pip install always error ' AscII ' can ' t decode, how to solve.

Can try to upgrade the next Anaconda version Oh ...

' Builtin_function_or_method ' object is not subscriptable

What if the parentheses are written in brackets? P.K.

Differentiation of NumPy (v)--numpy.ravel () vs Numpy.flatten ()

The first thing to declare is that the functionality to be implemented is consistent (the multidimensional array is reduced to one dimension), and the difference is whether the return copy (copy) or return view, Numpy.flatten () returns a copy, and changes made to the copy do not affect the original matrix (reflects). The Numpy.ravel () returns a view (and also quite a bit of a C + + reference reference) that affects the (reflects) original matrix.

Python base--min/max and Np.argmin/np.argmax

This should be a min/max (more suitable for dealing with iterative objects, optional parameters are Key=func) and Np.min/np.max (can be suitable for processing Numpy.ndarray objects, optional parameter is axis=0 or 1) for comparison, but np.argmin/ The use of Np.argmax is similar to Np.min/np.max, and no corrections are made here.
the function of the ① function is different
The former returns the value, which returns the index (subscript) of the highest value.
handles different objects
The former is more suitable to deal with the list and other iterative objects, while the latter is numpy core data structure Ndarray (multidimensional array)
function type is different
Min/max is a python-built function
Np.argmin/np.argmax is a member function in the NumPy library
interface is different
Min (iterable, Key=func)->value
Np.argmin (A, Axis=none)
Common interfaces as shown above, the former, in addition to an iterative object, also receives a function object (keyword argument), which specifies the object of the comparison (that is, the value comparison is to give the element in the iteration object to the return value of the Func function object individually), Visible Func can only accept one parameter, such as min (Dict, key=dict.get). And Np.argmax is more of a comparison of axes (axis=0, which is also the default axis, is the column)

The difference between arange () and Linspace () in Python

Arange () is similar to a built-in function range () to create a one-dimensional array representing arithmetic progression by specifying the start value, the end value, and the step size , noting that the resulting array does not contain a final value .
Linspace () Creates a one-dimensional array of arithmetic progression by specifying the start value, end value, and number of elements , which can be specified by the endpoint parameter to include the final value, the default is true, and the final value is included .

[Numpy]split () and Array_split ()

function is the same as split, the only difference is array_split allows indices_or_sections to be a integer that does not equally divide the axis. ( that is, you have an array, if there are 9 elements in it, you want to divide it into 3 parts, split and Array_split are OK, each 3 element Bai, but if you want to divide it into 2, then the problem comes, I can not be a 4.5, so this time split will be an error, and array_split can achieve this unequal division, such as the first 5, the second 4 of the actual combat drill 1. Python converts a picture into a character drawing

Python converts a picture to a character draw Debug

If you do not have a PIL module and want to install it through the PIP, you may have an error as follows:
could not find a version of that satisfies the requirement ...
So manually to the official website download (Note: There is no x64 version can be downloaded, can only download 32-bit ), download get pil-1.1.7.win32-py2.7.exe,
As the author's second article describes:
Python failed solution when installing Third-party library pil
But perhaps, we may not be as fortunate as the author: manual installation, will automatically identify the previous installation of the Python path, all the way by default
Maybe there will be a stumbling block, such as this:

At this point, you may need to execute the script described in the following article:
"Resolved" PiL Install exception "Python version 2.7 required, which is not found in the registry."
However, when you think everything is done, run with joy, and perhaps you will jump out of this:

Then pip install pillow down the bar ~
PiL the _imaging C module is not installed 2. Python3+requests crawl Baidu paste Post

Python2.7 Web crawler-Simple crawl Baidu paste small crawler
(Note: As above, the author is crawling through python2.7+urllib2 ) basic knowledge

Python Zfill () method

The Python Zfill () method returns a string of the specified length, the original string is right-aligned, and the front padding is 0.

Python3 raw_input () into input ()

Python3 use requests package to crawl and save the Web page source method Debug

one of my original intention is: I climbed down the HTML, browser open content pictures and Chinese can be normal display, and not garbled or content bytes So when the original intention is not up to, the beginning of the suspicion fell on the requests Library of the Chinese code on the :
Code Analysis Python Requests Library Chinese coding problem
However, when set in the coded format as described above, it is still impossible to do so, and then think about whether I want to open the written file encoding problem . So the following articles are referred to as follows:
Python Natural Language Code conversion module codecs Introduction

Specifies the language encoding of an open file by using the Open method provided by codecs, which is automatically converted to internal Unicode at read time

File = Codecs.open ("Dddd.txt", ' R ', "Utf-8")

If you open a file using the language-built open function, the output must be garbled.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.