1

I am playing some data from here in CSV.

I want to delete the "Timestamps are UTC timezone" and the "https://www.CryptoDataDownload.com" in the file. I've been trying to delete these items in pandas through drop() and adjust axis, label and some other parameters but no use. Since that row with those items has no label, so I can't really go through the label. I found some other posts to that need to create a list to process (e.g. this post), or go through import csv (e.g. this post). But I just wonder if it's possible to do it through pandas? Since this will be a repeat process with many CSVs, it would be spending resource to go through csv package (I guess?).

What I really want to do is to delete the column "Unix Timestamp" and change the "Date" to "datetime_UTC" so that I can convert the datetime format in "Date" (it seems I can't use the name "Date" to convert the datetime format in pandas as far as I have done so far). But the "Timestamps are UTC timezone" and the "https://www.CryptoDataDownload.com" have been blocking to process the column deletion in pandas.

Many thanks!

1 Answer 1

1

In this case of sample file it is enough to use keyword skiprows of pd.read_csv method

import pandas as pd
df = pd.read_csv('https://www.cryptodatadownload.com/cdd/Okcoin_BTCUSD_1h.csv', skiprows=1)

after running this code method df.info() renders following results:

<class 'pandas.core.frame.DataFrame'>  
RangeIndex: 29650 entries, 0 to 29649  
Data columns (total 9 columns):  
Unix Timestamp    29650 non-null float64  
Date              29650 non-null object  
Symbol            29650 non-null object  
Open              29650 non-null float64  
High              29650 non-null float64  
Low               29650 non-null float64  
Close             29650 non-null float64  
Volume BTC        29650 non-null float64  
Volume USD        29650 non-null float64  
dtypes: float64(7), object(2)   
memory usage: 2.0+ MB  
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! It works well! Simple curious, what if I do really want to delete the row, the only way is going through csv package?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.