Questions tagged as 'pandas'

1
answer

Results of a function in a DataFrame in python

I have a function in python that uses values from two columns labeled as 'POSITION_X' and 'POSITION_Y' in a .csv file (df1) The function calculates the sum |Xn-Xn+N|+|Yn-Yn+N| where n is the row number and N...
asked by 11.05.2017 / 21:31
1
answer

Define in which quartile values of a column are found

From a column that contains different numerical values called 'col6' I want to know for each sample in which quartile it is. To represent it I want to have 4 columns and do it in a binary way. What I had thought is to create 4 columns o...
asked by 14.12.2018 / 13:51
1
answer

Can parameters be passed to a function its own return value?

Hi, I'm trying to do a filter but I need the filter output data to go through the N times filter again, until I get the data I'm looking for. But can this be done in python? I need to do it with the use of calls to a filter function determined b...
asked by 07.07.2018 / 01:59
1
answer

Replace values from a list in an array in Python

My problem is this, I want to replace a list of questions in the first row of a square null matrix leaving the first zero, that is, if the matrix is m rows by n columns, I would like to insert the list of questions to from the value [m, n] = [0,...
asked by 19.05.2018 / 06:15
1
answer

Filter a DataFrame using a list

If I have the following dataframe a,b,c 0 2,3,8 1 5,6,5 2 7,8,7 I would like to filter the rows, but using a previously created list. Use something like this: num=[2,5] df=df[df['a'] in num] I would like to obtain the following resul...
asked by 24.04.2018 / 15:35
1
answer

Edit Dataframe pandas .groupby

I have the following code: import dataiku from dataiku import pandasutils as pdu import pandas as pd mydataset = dataiku.Dataset("PRD_edited_rejoined") mydataset_df = mydataset.get_dataframe()' mydataset_df[u"Válido"] = (mydataset_df.groupby([...
asked by 24.04.2018 / 16:34
2
answers

XLSX Python Search

With this code I can convert a certain column of an xlsx into a list. I need a function that looks in the directory where I am if there is any file with the values that are in my list called to: >>> [u'Jose', u'Martin', u'Pedro'] prin...
asked by 21.12.2017 / 02:57
1
answer

Link Pandas dataframes with a loop

I am chaining Pandas Dataframes in the following way: import os import pandas as pd file = [file for file in os.listdir() if file.endswith('csv')] dict = {} for file in file: d[file] = pd.read_csv(file) df_A = pd.concat([dict['A_0.csv'],...
asked by 13.11.2017 / 15:48
1
answer

In Python Pandas how can I filter a dataFrame with part of the content of a string?

I have a dataFrame that has a column named 'linea' . I want to filter the dataFrame only with the lines that have the word "GRANEL" in its content and discard all other lines. To filter currently I use the code: lista_produccion_t...
asked by 19.01.2018 / 20:37
2
answers

Delete and replace values in python pandas using conditionals

I have the following Dataframe prueba = M1 M2 M3 M4 0 1 1 1 NaN 1 2 3 3 NaN 2 3 2 2 1 3 4 NaN 1 NaN 4 1 NaN NaN NaN 5 1 3 2 2 6 3 3 NaN...
asked by 20.05.2018 / 23:13