Online see about the use of pandas, although practiced a lot, but still some can not remember very clearly. So it was written down.
Chapter1 is talking about reading a CSV file. The following code:
1 #%%2 ImportPandas as PD3 ImportNumPy as NP4 ImportMatplotlib.pyplot as Plt5 #Make the graphs a bit prettier6Pd.set_option ('Display.mpl_style','default')7plt.rcparams['figure.figsize'] = (15,5)8 9 #%%TenBROKEN_DF = Pd.read_csv ('C:\Users\rui\Desktop\pandas-cookbook-master\data\bikes.csv') One #Look at the first 3rows;
There is no in-depth understanding of the use of read_csv. The next article will be a special explanation.
1 fixed_df = pd.read_csv ( " c:\users\rui\desktop\pandas-cookbook-master\data\bikes.csv , 2 sep= " ; ", Encoding=" Latinl , Parse_dates=[" date "],dayfirst=true,index_col=date ")
where Sep represents the delimiter, encoding is the specified encoding, and if the file contains non--ASCII character fields, ensure that it is read in the correct encoding. This is a major problem in reading Latin-1 files inside the UTF-8 Local system. At this point, you can handle the following. For parameters Parse_date:if True then index would be parsed as dates (False by default). Can specify more complicated options to parse a subset of columns or a combination of columns into a single date colum N (List of ints or names, list of lists, or dict) [1, 2,3];
Dayfirst:boolean, default False//dd/mm format dates, international and European format;
Index_col:int or sequence or False, default None
Column to use as the row labels of the DataFrame. If a sequence is given, a multiindex is used. If you had a malformed file with delimiters at the end of each line, you might consider Index_col=false to Forc E Pandas to _not_ use the first column as the index (row names)
1 fixed_df['Berri 1'].plot () 2 fixed_df.plot ( Figsize= (15,5))
Where the plot function does not draw the same Berri 1 data as in the original document. The reasons are currently being sought;
Pandas Cookbook "1"