import pandas as pd
pd.set_option()
pd.set_option("display.max_columns", None)
pd.set_option("expand_frame_repr", False)
pd.read_csv()
还有read_table、read_excel、read_json等,他们的参数内容都是大同小异
df = pd.read_csv(
filepath_or_buffer=r"D:\PyProjects\pandas\data\sh600000.csv",
encoding='gbk',
skiprows=1,
index_col=['交易日期'],
error_bad_lines=False,
na_values='NULL',
)
df
| 股票代码 | 股票名称 | 开盘价 | 最高价 | 最低价 | 收盘价 | 前收盘价 | 成交量 | 成交额 |
---|
交易日期 | | | | | | | | | |
---|
1999-11-10 | sh600000 | 浦发银行 | 29.50 | 29.80 | 27.00 | 27.75 | 10.00 | 174085100.0 | 4.859102e+09 |
---|
1999-11-11 | sh600000 | 浦发银行 | 27.58 | 28.38 | 27.53 | 27.71 | 27.75 | 29403500.0 | 8.215822e+08 |
---|
1999-11-12 | sh600000 | 浦发银行 | 27.86 | 28.30 | 27.77 | 28.05 | 27.71 | 15008000.0 | 4.215916e+08 |
---|
1999-11-15 | sh600000 | 浦发银行 | 28.20 | 28.25 | 27.70 | 27.75 | 28.05 | 11921100.0 | 3.329528e+08 |
---|
1999-11-16 | sh600000 | 浦发银行 | 27.88 | 27.97 | 26.48 | 26.55 | 27.75 | 23223100.0 | 6.289083e+08 |
---|
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
---|
2019-03-29 | sh600000 | 浦发银行 | 10.98 | 11.30 | 10.98 | 11.28 | 11.03 | 60526266.0 | 6.784365e+08 |
---|
2019-04-01 | sh600000 | 浦发银行 | 11.36 | 11.52 | 11.29 | 11.44 | 11.28 | 70637405.0 | 8.086575e+08 |
---|
2019-04-02 | sh600000 | 浦发银行 | 11.50 | 11.52 | 11.41 | 11.44 | 11.44 | 46714710.0 | 5.348968e+08 |
---|
2019-04-03 | sh600000 | 浦发银行 | 11.37 | 11.54 | 11.34 | 11.50 | 11.44 | 50271029.0 | 5.757994e+08 |
---|
2019-04-04 | sh600000 | 浦发银行 | 11.55 | 11.71 | 11.54 | 11.71 | 11.50 | 75232527.0 | 8.760995e+08 |
---|
4582 rows × 9 columns
type(df)
pandas.core.frame.DataFrame
df.dtypes
股票代码 object
股票名称 object
开盘价 float64
最高价 float64
最低价 float64
收盘价 float64
前收盘价 float64
成交量 float64
成交额 float64
dtype: object
df.shape
(4582, 9)
df.index
Index(['1999-11-10', '1999-11-11', '1999-11-12', '1999-11-15', '1999-11-16',
'1999-11-17', '1999-11-18', '1999-11-19', '1999-11-22', '1999-11-23',
...
'2019-03-22', '2019-03-25', '2019-03-26', '2019-03-27', '2019-03-28',
'2019-03-29', '2019-04-01', '2019-04-02', '2019-04-03', '2019-04-04'],
dtype='object', name='交易日期', length=4582)
df.columns
Index(['股票代码', '股票名称', '开盘价', '最高价', '最低价', '收盘价', '前收盘价', '成交量', '成交额'], dtype='object')
df.info()
<class 'pandas.core.frame.DataFrame'>
Index: 4582 entries, 1999-11-10 to 2019-04-04
Data columns (total 9 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 股票代码 4582 non-null object
1 股票名称 4582 non-null object
2 开盘价 4582 non-null float64
3 最高价 4582 non-null float64
4 最低价 4582 non-null float64
5 收盘价 4582 non-null float64
6 前收盘价 4582 non-null float64
7 成交量 4582 non-null float64
8 成交额 4582 non-null float64
dtypes: float64(7), object(2)
memory usage: 358.0+ KB
df.describe()
| 开盘价 | 最高价 | 最低价 | 收盘价 | 前收盘价 | 成交量 | 成交额 |
---|
count | 4582.000000 | 4582.000000 | 4582.000000 | 4582.000000 | 4582.000000 | 4.582000e+03 | 4.582000e+03 |
---|
mean | 15.635415 | 15.909773 | 15.395792 | 15.650061 | 15.640426 | 5.692092e+07 | 8.154719e+08 |
---|
std | 8.721635 | 8.980982 | 8.501645 | 8.741688 | 8.737362 | 9.247712e+07 | 1.331689e+09 |
---|
min | 6.460000 | 6.650000 | 6.410000 | 6.480000 | 6.480000 | 2.711200e+05 | 3.964432e+06 |
---|
25% | 9.760000 | 9.880000 | 9.660000 | 9.750000 | 9.750000 | 7.460875e+06 | 8.924417e+07 |
---|
50% | 13.025000 | 13.250000 | 12.890000 | 13.050000 | 13.040000 | 2.577607e+07 | 3.927869e+08 |
---|
75% | 18.300000 | 18.670000 | 18.027500 | 18.400000 | 18.387500 | 6.659754e+07 | 9.631053e+08 |
---|
max | 61.000000 | 61.970000 | 59.000000 | 61.590000 | 61.590000 | 1.198024e+09 | 1.383364e+10 |
---|
|