0

i am a beginner with pandas and matplotlib but i was able to use them previously with data structures i created in my own. (before i knew i could load to pandas from a file) i am trying to plot data from 2 sources and i am having some trouble. the first source is a log from windows PerfMon, below is a snippet of the data:

"(PDH-CSV 4.0) (Coordinated Universal Time)(0)","\\MainUser\Process(App)\% Processor Time"
"04/03/2020 16:09:58.398"," "
"04/03/2020 16:09:59.399","85.795642489249616"
"04/03/2020 16:10:00.401","99.635659557592177"
"04/03/2020 16:10:01.405","71.470475691927575"
"04/03/2020 16:10:02.394","85.172618028129037"
"04/03/2020 16:10:03.401","96.138262475057346"
"04/03/2020 16:10:04.393","88.060038497795688"
"04/03/2020 16:10:05.402","77.300336739910918"
"04/03/2020 16:10:06.397","92.497815954042423"

And the second data source is a log file from GPU-Z:

        Date        , Memory Used [MB] , GPU Load [%] , System Memory Used [MB] ,
2020-04-03 16:08:56 ,           1409   ,         14   ,                  6565   ,
2020-04-03 16:08:57 ,           1410   ,         14   ,                  6569   ,
2020-04-03 16:08:58 ,           1410   ,         14   ,                  6569   ,
2020-04-03 16:08:59 ,           1412   ,         16   ,                  6573   ,
2020-04-03 16:09:00 ,           1412   ,         15   ,                  6571   ,
2020-04-03 16:09:01 ,           1412   ,         15   ,                  6572   ,
2020-04-03 16:09:02 ,           1410   ,         14   ,                  6572   ,
2020-04-03 16:09:03 ,           1410   ,         15   ,                  6572   ,

i decided to tackle the CPU graph first, but after fiddling with the data, learning how to replace empty strings and converting from 'object' dtype to date and float types - i passed the data frame to .plot() and the maximum i got was a straight line with a bunch of errors..

Right now, all i got is this:

import matplotlib.pyplot as plt
import pandas as pd
from datetime import datetime

ts = pd.read_csv(r'CSV\CPU_000001.csv',na_values=' ')

ts[list(ts.columns)[0]] = ts[list(ts.columns)[0]].map(lambda x: datetime.strptime(str(x), '%d/%m/%Y %H:%M:%S.%f'))
ts[list(ts.columns)[1]] = ts[list(ts.columns)[1]].astype('float')
ts.plot()
plt.show()

i think that my problems might be related to the fact that the column headers in the CPU data file are in quotes.. but i don't know how to tackle this.

I know i am missing something but the online tutorials are not helpful, they all use randomly generated data and would really appreciate it if someone could help me with this real world problem.

1 Answer 1

1

If your question is how to plot, here:

# for plotting a line
plt.plot(X, Y, color = '')
# for plotting dots
plt.scatter(X, Y, color = '')

Enter your plot color in the quotes of the third argument. X and Y are just examples. Your X and Y axis can be anything you choose as long as it is a numerical list from a csv matrix. Please Let me know if this is helpful...

Sign up to request clarification or add additional context in comments.

1 Comment

yep helped me.. previously tried to plot by doing plt.plot(x=X, y=Y, color = '') and it didn't work.. no idea why this time this worked.. thanks alot!

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.