Read csv in pandas does not show me all values

1

I'm working with a CSV file that comes down from a URL. I keep it and even there everything is perfect. Once I want to read it and print the results it just shows me some. He puts me some ... ... ... and tells me how many lines I have but he does not show me all:

Sitio                  valores1      valores2  Fill Rate
si.com                  326014         3585      1.10
elcte.com               11333          121       1.07
youthage.co.za          19774          212       1.07
ginh.tv                 44086          457       1.04
taianhdep.com           14149          147       1.04
...                       ...          ...        ...
boe.com.br              411299         868       0.21
jbsis.com               18436          38        0.21
rqueamo.com.br          17414          36        0.21
tats.com                13192          28        0.21
ho.vn                   264321         558       0.21
nie.com.au              126480         264       0.21
[475 rows x 3 columns]

I leave the code here to see:

import pandas as pd

datos = pd.read_csv('data.csv', header=0, index_col=0)
auto = (datos.sort_values(by='Fill Rate', ascending=False))
auto2 = auto[(auto['Fill Rate'] >0.2)]

f = open("WL.csv", "w")
content2 = str(auto2)

f.write(content2)

f.close()

In the code what I do is read the csv, sort it by the last column and only show the highest values of 0.2. Use Python 2.7

Thank you very much

    
asked by Martin Bouhier 02.10.2017 в 19:32
source

1 answer

0

The basic problem you have is that you are saving the "screen version" of the dataframe, which is limited to showing you a maximum number of rows, you could eventually modify it, for example: pd.set_option('max_rows', 10000) . But beyond this, the correct thing would be to use the panda's own function to save the data to a csv - > to_csv() . Something like this:

df.to_csv("WL.csv", sep='\t', encoding='utf-8')

You should then save your dataframe in the following way:

import pandas as pd

datos = pd.read_csv('data.csv', header=0, index_col=0)
auto = (datos.sort_values(by='Fill Rate', ascending=False))
auto2 = auto[(auto['Fill Rate'] >0.2)]

df.to_csv("WL.csv", sep='\t', encoding='utf-8')
    
answered by 02.10.2017 / 19:58
source