Masoomjethwa
Masoomjethwa

Reputation: 74

reading csv file from panda and plotting

I have 1000 files in which the data is stored in comma separation. The description of a file is given below:

The values are comma separated, -9999 values should be ignored and if it can be read, all the values of row and column should be stored in numbers, as it has to used in plotting. The shape of file is [104 rows x 15 columns].

The few lines of the files are as follows:

0,   9.8597e+00, 129.944,   1.071, 6.7433e-06, 1.0911e-05,      -9999,      -9999, 3.7134e-07, 3.5245e-05,      -9999,      -9999,  26.295,   -86.822,  -123.017



0,   8.7012e+00, 130.908,   0.966, 1.9842e-06, 1.0799e-05,      -9999,      -9999, 3.5888e-07, 7.8133e-05,      -9999,      -9999,  27.140,   -86.818,  -122.322

After reading into numeric values, I need to plot it into subplot also. Like COl1 vs Col2 , Col3 vs col5 and so on....

Any idea how to achieve it?

import numpy as np
import pandas as pd 
import matplotlib.pyplot as plt

df1=pd.read_csv("small_file_106.txt",header=1)
print(df1)

Upvotes: 0

Views: 413

Answers (2)

Sohier Dane
Sohier Dane

Reputation: 142

Once you've read the data in (Shijo's method looks good) the Seaborn library's pairplot should generate the plot you want.

Upvotes: 0

Shijo
Shijo

Reputation: 9721

I never used plot ,but following would be useful for the first question input the list of values to na_values and those will be considered as NA by pandas

pd.read_csv(File, sep=',',na_values=['-9999'],keep_default_na=False)

Also pd.to_numeric is available to convert data to numeric

df.apply(lambda x: pd.to_numeric(x, errors='ignore'))

Upvotes: 1

Related Questions