Python Day 51 – formatting .txt in Pandas

Success! In a matter of minutes I solved the problem that was vexing me yesterday. I sense a pattern here… yay for a fresh mind.

I learned:

When getting data from a .txt file, one can still use the pd.read_csv function. The issue I was running into yesterday was that it was reading the column names as a website link which must’ve been at the top of the file. So I looked into the issue in the documentation with the ?.read_csv command and realized that one can set custom headers! So I switched it to say: pd.read_csv(“data”,header = 1).

This correctly set the headers and I was then able to mess around with the ordering of the code. I also learned about a useful data plotting code called matplotlib.pyplot. Once I imported that as ‘plt’ I was able to use the function to more cleanly showcase different parts of the data.

I’m still confused on:

In, how does one show multiple lines on the same chart?

Additionally, and quite frustratingly, I ran into an error when I tried to import some other datasets. The data was in the same folder as the previous data I had worked with, yet when I did .read_csv I got the error that there is ‘no such file or directory’. This one is stumping me right now.

Alas, this shall be a problem for tomorrow’s Isaac.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: