У меня есть 2 кадра данных, как показано ниже:
1-й кадр данных data
:
2019-06-19 2019-06-20 2019-06-21 2019-06-22 2019-06-23 2019-06-24 2019-06-25
currency
BCH 485.424079 485.424079 57.574609 57.559609 57.559609 57.559609 57.559609
BTC 202.204572 256.085103 197.291801 177.359726 177.359726 177.359726 252.859726
BTG 4065.370000 4065.370000 4065.370000 4065.370000 4065.370000 4065.370000 4065.370000
ETC 40001.000000 40001.000000 40001.000000 40001.000000 40001.000000 40001.000000 0.000000
ETH 4092.917231 4092.917231 1497.655594 1497.655594 1497.655594 1497.655594 1497.655594
2-й кадр данных sys_bal
:
created_at 2019-06-19 2019-06-20 2019-06-21 2019-06-22 2019-06-23 2019-06-24 2019-06-25
currency
1WO 1997308 1996908 1996908 1996908 1996908 1996908 1996908
ABX 241444 241444 241444 241444 241444 241444 241444
ADH 5981797 5981797 5981797 5981797 5981797 5981797 5981797
ALX 385466 385466 385466 385466 385466 385466 385466
AMLT 4749604 4749604 4749604 4687869 4687869 4687869 4687869
BCH 4547 4547 4483 4463 4465 4467 4403
BRC 1231312 1231312 1231312 1231312 1231312 1231312 1231142
BTC 7366 7342 7287 7307 8292 8635 7772
BTRN 15236038 15236038 15236038 15236038 15236038 15236233 15236233
Я пытаюсь добавитьодин с другим, выполнив pos_bal = sys_bal + data
.Они имеют одинаковый размер, но у меня есть ошибка.
ошибка:
pos_bal = sys_bal + data
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/ops.py", line 1547, in f
other = _align_method_FRAME(self, other, axis)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/ops.py", line 1481, in _align_method_FRAME
right = to_series(right)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/ops.py", line 1456, in to_series
given_len=len(right)))
ValueError: Unable to coerce to Series, length must be 7: given 2
Я напечатал dtypes обоих фреймов данных и получил следующее:
1-й фрейм данных:
2019-06-19 float64
2019-06-20 float64
2019-06-21 float64
2019-06-22 float64
2019-06-23 float64
2019-06-24 float64
2019-06-25 float64
dtype: object
2-й кадр данных:
created_at
0 2019-06-19 int64
2019-06-20 int64
2019-06-21 int64
2019-06-22 int64
2019-06-23 int64
2019-06-24 int64
2019-06-25 int64
dtype: object
data.info()
выход:
<class 'pandas.core.frame.DataFrame'>
Index: 12 entries, BCH to XRP
Data columns (total 7 columns):
2019-06-20 12 non-null float64
2019-06-21 12 non-null float64
2019-06-22 12 non-null float64
2019-06-23 12 non-null float64
2019-06-24 12 non-null float64
2019-06-25 12 non-null float64
2019-06-26 12 non-null float64
dtypes: float64(7)
memory usage: 768.0+ bytes
None
sys_bal.info()
выход:
<class 'pandas.core.frame.DataFrame'>
Index: 126 entries, 1WO to ZPR
Data columns (total 7 columns):
2019-06-20 126 non-null int64
2019-06-21 126 non-null int64
2019-06-22 126 non-null int64
2019-06-23 126 non-null int64
2019-06-24 126 non-null int64
2019-06-25 126 non-null int64
2019-06-26 126 non-null int64
dtypes: int64(7)
memory usage: 7.9+ KB
None