Machine learning in trading: theory, models, practice and algo-trading - page 3449

 
Maxim Dmitrievsky #:

Well, I don't keep all the nuances in my head either. I use the documentation.

I didn't find it in the documentation - I didn't look hard enough?

 
Aleksey Vyazmikin #:

I couldn't find it in the documentation - I didn't look hard enough?

maybe the question is wrong, what does it mean to merge on line 0?

There is also a merge function
 
Maxim Dmitrievsky #:

Maybe the question is wrong, what does it mean to merge on line 0?

There is also a merge function.
As far as I understand it wants to merge two DFs by columns with names.

But it merges by rows, and the row names are used as indices.
 
mytarmailS #:
As far as I understand from wants to combine two DFs by columns with names.

But it combines them by rows, and the row names are used as indexes

I don't understand anything.

Here's everything merged.

>>> Input_Data = pd.DataFrame({'A': [1, 2, 3],
...                            'B': [4, 5, 6]})
>>> 
>>> Input_Info = pd.DataFrame({'C': [7, 8, 9],
...                            'D': [10, 11, 12]})
>>> pd.concat([Input_Data, Input_Info], axis=1)
   A  B  C   D
0  1  4  7  10
1  2  5  8  11
2  3  6  9  12
>>> 

The first rows can be merged like this.

pd.concat([Input_Data.iloc[0:1], Input_Info.iloc[0:1]], axis=1)
   A  B  C   D
0  1  4  7  10
 
Hmm... why is the index 0:1 if the string is one?
 
Aleksey Vyazmikin #:

Well... here's an example - I've been stumped for a long time - I don't understand why the code doesn't work properly.

We should get a row with ABCD columns in a row, but we get

Got it. Because such indexing as you have returns pd.Series objects, not pd.Dataframe objects.

I have shown above how to do it correctly

 
mytarmailS #:
Hmm... why is the index 0:1 if there's only one line?

Zero to one, so it's one.

If you set one value, it'll return a different object, with a different indexing.

You can go from zero to two, and so on.

>>> pd.concat([Input_Data.iloc[0:2], Input_Info.iloc[0:2]], axis=1)
   A  B  C   D
0  1  4  7  10
1  2  5  8  11
 

TensorFlow winds up on Nvidia


 
Maxim Dmitrievsky #:

from zero to one, i.e. one

if you set one value, it will return a different object, with a different indexing

you can go from zero to two, and so on.

Hmm. Interesting and confusing.
 
mytarmailS #:
Hmm. Interesting and confusing.

Well, that's how indexing works. Because a dataframe is an array of series.

If you specify a single column, it will return a series. If it's a range, it returns a dataframe, even if there's only one row in the range.

handy.
Reason: