0
I am developing code to help me analyze import spreadsheets faster and better than the tools excel offers.
Basically, I take a spreadsheet, convert to CSV and import pandas and numpy to analyze the data.
I’m focusing analysis on using np.Where:
Libraries used
import pandas as pd
import numpy as np
Uploading the CSV database and isolating the column I’m interested in working with
database = pd.read_csv("https://raw.githubusercontent.com/CaiqueBarrreto/agroci/main/basePY.csv?token=ALHIP5CKNZG5LXZUVMQPAMLADLQGM")
database_goodshipped = database.iloc[:,[26]]
The critical step now is to turn the 26 column of this base into a list and analyze the strings of each row of it, returning a conditional value in another column:
conteudo = [database_goodshipped]
df = pd.DataFrame({"dados_de_compra": conteudo})
df['variavel_resposta'] = np.where(df['dados_de_compra'].str.contains('FLUTRIAFOL'),
'FLUTRIAFOL', 'NID')
df
Basically, I want him to return me in another column the expression 'FLUTRIAFOL' if he finds this expression in any row of the column I’m analyzing (which in this case was converted into the list 'content')
I’m confused and do not know what could be there for the code not working for all lines, since there are almost 3k items in the list 'content' I created and for sure have more than one line containing the 'FLUTRIAFOL'
Link to csv not working
– Paulo Marques
for some reason it expires in a short time and I have to keep updating.... the following is another: https://raw.githubrcontent.com/CaiqueBarrreto/agroci/main/basePY.csv?token=ALHIP5GRZSSWEF5TWSX4AX3ADLSPW
– Caique Barreto
no access again
– Paulo Marques
puts... sorry. I don’t know yet how to make it not expire, Paulo. Thanks for the patience. I think you should go now, I made an adjustment on the github: https://raw.githubusercontent.com/CaiqueBarrreto/agroci/main/basePY.csv?token=ALHIP5HTMLLMRGZFZRHVIYTADLT6C
– Caique Barreto
The mistake is
404: Not Found
. The repository is private or public?– Paulo Marques
was private... I made it public now. It should work this time: https://raw.githubrcontent.com/CaiqueBarrreto/agroci/main/basePY.csv
– Caique Barreto