Dec-12-2017, 08:21 PM
hi
i am trying to import a txt file but it's in csv format. this is tick trading data info.
the file is this:
i am using the following code:
the file is imported but not as expected. the results is:
1. why my "names" are not starting on the first column?
2. how do i make 2nd column as date-time and index?
3. how do i widen the result so i will see all the data in one line (i am using pycharm)?
4. since i need to make date-time as index, i need to remove column 0 but when using
nothing happens
thanks for your support and help!
i am trying to import a txt file but it's in csv format. this is tick trading data info.
the file is this:
Quote:0,2017-09-18 02:00:06,12567.00,200,200,12567.00,12567.00,5430,0,0,C,
0,2017-09-18 02:00:06,12568.00,1,201,12567.00,12568.00,5462,0,0,C,
0,2017-09-18 02:00:06,12568.50,2,203,12567.00,12568.00,5463,0,0,C,
0,2017-09-18 02:00:06,12569.00,1,204,12567.00,12569.00,5468,0,0,C,
0,2017-09-18 02:00:06,12569.00,1,205,12567.00,12569.00,5470,0,0,C,
0,2017-09-18 02:00:06,12569.50,3,208,12567.00,12569.00,5471,0,0,C,
0,2017-09-18 02:00:06,12570.00,3,211,12567.00,12569.00,5472,0,0,C,
i am using the following code:
1 2 3 |
import pandas as pd df = pd.read_csv( "XG#/20170918.txt" , names = [ 'empty' , 'date time' , 'last' , 'last size' , 'bid' , 'ask' ]) print (df.head( 1 )) |
Output: empty date time last \
0 2017-09-18 02:00:06 12567.0 200.0 200.0 12567.0 12567.0 5430.0 0.0
last size bid ask
0 2017-09-18 02:00:06 12567.0 200.0 200.0 12567.0 0.0 C NaN
Process finished with exit code 0
my questions are:1. why my "names" are not starting on the first column?
2. how do i make 2nd column as date-time and index?
3. how do i widen the result so i will see all the data in one line (i am using pycharm)?
4. since i need to make date-time as index, i need to remove column 0 but when using
1 |
df.drop(df.index[ 0 ]) |
thanks for your support and help!