1. Create Dataframe several ways
1.1
Import Pandas as PD
df1= PD. DataFrame ({' A ': Range (3), ' B ': Range (3)})
2. Traverse a column
L = [Str (v) for V in DF.A]
Print L
3. Common operation
Slice
db= da.loc[:,[' A ', ' B ',]]
Polymerizationdb = Da_38.groupby ([' a ']). SUM ()
Filter
da = da[(da.a==1) | (Da.b==1)]
Add a column
D1[' C '] = d1[' A ']/d1[' B ']
Apply
D2[' C '] = d2[' A '].apply (lambda x:1)
da["B"]=da.a.apply (lambda x:
) pd.read_sql_table (table_name, con, Schema=none, Index_col=none, Coerce_float=true, Parse_dates=none, columns= None, Chunksize=none) For example: data = pd.read_sql_table (table_name = ' t_line ', con = engine,parse_dates = ' time ', Index_col = ' time ', columns = [' A ', ' B ', ' C ']) 3: Read database (via SQL statement or table name) See me through the SQL statement another article: http://www.cnblogs.com/cymwill/articles/7576600.html pd.read_sql (sql, con, index_col=none, Coerce_float=t
Label:Read the contents of the table, as in the following example: ImportMySQLdbTry: Conn= MySQLdb.connect (host='127.0.0.1', user='Root', passwd='Root', db='MyDB', port=3306) DF= Pd.read_sql ('select * from test;', con=conn) Conn.close ()Print "Finish Load DB"
exceptmysqldb.error,e:PrintE.ARGS[1] Write the data to the table, as in the following example DF = PD. DataFrame ([[1,'XXX'],[2,'yyy']],columns=list ('AB'))
Try: Conn= MySQLdb.connect (host='127.0.0.1', user='Root', passwd='Root', db='My
Objective
Pandas is a numpy built with more advanced data structures and tools than the NumPy core is the Ndarray,pandas is also centered around Series and dataframe two core data structures. Series and Dataframe correspond to one-dimensional sequence and two-dimensional table structure respectively. Pandas's conventional approach to importing is as follows:
From
Operating system: Windowspython:3.5Welcome to join the Learning Exchange QQ Group: 657341423
The previous section describes the library of data analysis and mining needs, the most important of which is pandas,matplotlib.Pandas: Mainly on data analysis, calculation and statistics, such as the average, square bad.Matplotlib: The main combination of pandas to generate images. Both are often used in combination
merging and splitting of arrays in numpy and pandas
Merging
in NumPy
In NumPy, you can combine two arrays on both the vertical and horizontal axes by concatenate, specifying parameters axis=0 or Axis=1.
Import NumPy as NP import pandas as PD Arr1=np.ones (3,5) arr1 out[5]: Array ([[1., 1., 1., 1., 1.], [1., 1
., 1., 1., 1.], [1., 1., 1., 1., 1.]] Arr2=np.random.randn. Reshape (Arr1.shape) arr2 out[8]: A
Rank () over, row_number () over, rank_dense () in SQL statements ()
Summary:
I created a table with the following data,
SQL> select * from test;
A1 A2
--------------------
1 3
2 4
3 2
3 5
4 2
Then rank () over,
SQL> select A1, A2, rank () over (order by a1) rank from test;
A1 A2 r
Getting started with Python for data analysis--pandas
Based on the NumPy established
from pandas importSeries,DataFrame,import pandas as pd
One or two kinds of data structure 1. Series
A python-like dictionary with indexes and values
Create a series#不指定索引,默认创建0-NIn [54]: obj = Series([1,2,3,4,5])In [55]: objOut[55]:0
Function Prototypes:Https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.fillna.html#pandas.DataFrame.fillnaPad/ffill: Fills the missing value with the previous non-missing valueBackfill/bfill: Fills the missing value with the next non-missing valueNone: Specify a value to replace the missing value
123456789101112131415161718192021st22232425262728293031323334353637383940414243444546474849505152535455565758596061 62 63
Original: Chapter 7
# usual opening
%matplotlib inline
import pandas as PD
import matplotlib.pyplot as Plt
import NumPy as NP
# make diagram Table bigger and prettier
pd.set_option (' Display.mpl_style ', ' Default ')
plt.rcparams[' figure.figsize '] = (5)
plt.rcparams[' font.family ' = ' sans-serif '
# need to show a lot of columns in Pandas 0.12
# in Pandas
absrtact: This article is mainly in the pandas how to split the string. Let's consider the following scenario.
This is our dataset (data), and you can see that a column (name) in the dataset is a category for an industry. Symbols ' | ' Between industries Segmentation. We're going to use each ' | ' Extract the contents of the partition. Pandas has a step-by-step approach to the place, very convenient.
Import
1. In the dataframe of pandas, we often need to select the rows of a specified condition based on a property, at which point the Isin method is particularly effective.
Import pandas as PD
DF = PD. Dataframe ([[1,2,3],[1,3,4],[2,4,3]],index = [' One ', ' two ', ' three '],columns = [' A ', ' B ', ' C '])
print DF
# A B C
# One 1 2 3
# two 1 3 4
# three 2 4 3
Let's say we choose a row w
First, use rownum for record ranking:
In the previous "Introduction to Oracle Development analysis function over", we understand the basic application of analytic function, now we consider the following questions:
① to rank all customers by total order② rank by region and customer order totals③ find the top 13 customers in order total④ find customers with the highest and lowest order totals⑤ find the top
1. Title Rank Scores (number of times by score) 2. Address of the topic https://leetcode.com/problems/rank-scores/ 3. Topic content Rank by score, if the score of two ID is the same, then their rank is the same, the ranking starts from 1. Note that the rank of each group of
Data dimensionality Reduction--low rank recoveryIn the actual signal or image acquisition and processing, the higher the dimension of the data, the greater the limit to the data collection and processing. For example, it is often difficult to acquire signals in three-dimensional or four-dimension (three spatial dimensions plus one spectral dimension or one time dimension). However, with the increase of data dimensionality, there are often more correla
[ACM] HDU 5131 Song Jiang's rank list (simulation ),Song Jiang's rank list
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)Total Submission (s): 36 Accepted Submission (s): 18Problem Description Shui Hu Zhuan, also Water Margin was written by Shi nai' an -- an writer of Yuan and Ming dynasty. shui Hu Zhuan is one of the Four Great Classical Novels of Chinese literature. it
Welcome to the Bestcoder-every Saturday night (with rice!) )
Song Jiang ' s rank listTime limit:2000/1000 MS (java/others) Memory limit:512000/512000 K (java/others)Total submission (s): 673 Accepted Submission (s): 333Problem Description "Shui Hu Zhuan", also "water Margin" was written by Shi Nai's--an writer of Yuan and Ming dynasty. "Shui Hu Zhuan" is one of the four great classical novels of Chinese literature. It tells a story abou
linearly with each other, then the two vector groups are called equivalent. Two Principles, formulas, and rules
1. The basic principle of determining the linear correlation of a vector group:
When the upper form is set up, not all is 0, then can determine the linear correlation, if only, then can determine linearly independent.
2. The determination of the linear correlation of vectors
1) A vector A is a sufficient and necessary condition for linear correlation: a=0;
2 The sufficient and necess
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.