Extract rows from a database

0
import pandas as pd  
datos=pd.read_csv('datos.csv', header=0 )
datos=(datos[datos.iloc[:,3]>=0]) 
anios1=datos[datos.iloc[:,2]==1975]

Use this code to read a database, this database stores precipitation in a certain area every day every day from 1950 to 2015. Subsequently extracted as a new database the values corresponding to the year 1975. The idea of the code in general is to obtain the highest precipitation of each month of that year and make a graph with that data. I did not find a way to extract the rows with the values I need as a new database.

    
asked by Pedro Rincón Avalos 19.10.2017 в 01:06
source

1 answer

0

data = (data [datos.iloc [:, 3] > = 0])
anios1 = data [datos.iloc [:, 2] == 1975]
this returns True or False only and not the values

I think this can help you
the file rain.cvs contains the following rows:
Year, Month, Day, Rain
1974,12,24,0.0
1974,12,25,0.0
1974,12,26,0.0
1974,12,27,0.0
1974,12,28,0.0
1974,12,29,0.0
1974,12,30,0.0
1974,12,31,0.0
1975,1,1,0.0
1975,1,2,0.0
1975,1,3,0.0
1975,1,4,0.0
1975,1,5,0.4
1975,1,6,0.0
1975,1,7,0.6
1975,1,8,0.0
1975,1,9,0.0
1975,1,10,3.0
1975,1,11,0.0
1975,1,12,4.5
1975,1,13,0.0
1975,1,14,0.0

'' 'python
 #! / usr / bin / env python3
 # - - coding: utf-8 - -
"" "
Created on Wed Nov 15 11:55:15 2017
rain75.py
Rains in 1975
@author: jab
"" "

import pandas as pd

data = pd.read_csv ('rain.csv', header = 0)
Rains = pd.DataFrame ()
for index, row in datos.iterrows ():
... if row [0] == 1975.0 and row [3] > 0.0:
... rain = rainfall.append (row)

print (rain)
'' '

       Año   Dia  Lluvia  Mes  
12  1975.0   5.0     0.4  1.0  
14  1975.0   7.0     0.6  1.0  
17  1975.0  10.0     3.0  1.0  
19  1975.0  12.0     4.5  1.0  
    
answered by 15.11.2017 в 17:40