samedi 25 janvier 2020

constraining data frame with if statement in Python

I am going to constraint a data file like this, that I am reading the file and then choose values that the 4th column h starts and ends between my chosen range which here is for example1e-5<H< 7e-1. For this Python suggest to use any and all and after that, it says that you're using float with tuple. I need your help. How to do this exactly like I have written?

import pandas as pd
n, t, I, h = np.genfromtxt('C:...../221.txt',unpack=True)
for H in zip(h):
  if 1e-5<H< 7e-1:
     df=pd.DataFrame(data={'A':n,'B':t,'C':I, 'G':H})
     import matplotlib.colors
     points = plt.scatter(df.A, df.B, c=df.C,cmap="jet", lw=0, norm=matplotlib.colors.LogNorm())

Aucun commentaire:

Enregistrer un commentaire