pandas

How to split an array using its minimum entry

How to split an array using its minimum entry Question: I am trying to split a dataset into two separate ones by finding its minimum point in the first column. I have used idxmin to firstly identify the location of the minimum entry and secondly iloc to slice the array from 0 to the minimum …

Total answers: 1

Query the non-nan value from a pivoted df

Query the non-nan value from a pivoted df Question: I have a pivoted df: data = np.column_stack([["alpha", "beta", "gamma", "delta"], ["a", "b", "c", "d"], [0, 1, 2, 3], othercol, othercol2]) df = pn.DataFrame(data, columns=["greek", "latin", "distance", "othercol", "othercol2"]) piv = df.pivot(index = "greek", columns="latin", values="values") and would like to access piv‘s values by name, so …

Total answers: 3

Cannot Convert Local CSV to dataframe in Pandas on Spyder

Cannot Convert Local CSV to dataframe in Pandas on Spyder Question: Hello I am learning Python using Spyder (Python 3.8.10 64-bit | Qt 5.15.2 | PyQt5 5.15.10 | Windows 10 (AMD64). I am unable to convert a local copy of a csv into a dataframe using pandas # import pandas module import pandas as pd …

Total answers: 1

Pandas: Explode a list of nested dictionaries column and append as new rows

Pandas: Explode a list of nested dictionaries column and append as new rows Question: Please consider the below dict for example: d2 = [{‘event_id’: ‘t1’, ‘display_name’: ‘t1’, ‘form_count’: 0, ‘repetition_id’: None, ‘children’: [{‘event_id’: ‘t_01’, ‘display_name’: ‘t(1)’, ‘form_count’: 1, ‘repetition_id’: ‘t1’, ‘children’: [], ‘forms’: [{‘form_id’: ‘f1’, ‘form_repetition_id’: ‘1’, ‘form_name’: ‘fff1’, ‘is_active’: True, ‘is_submitted’: False}]}], ‘forms’: []}, …

Total answers: 1

Regex to remove character before a character set

Regex to remove character before a character set Question: I have dataframe with column ‘code’. import pandas as pd df = pd.DataFrame({‘code’: [’10SGD35/AA501/10SGD35/AA599/10SGD36/AA501/10SGD36AA599/10SGD37/AA501/10SGD37/AA527′, ’10SGD08/AA701/10SGD08/AA704/10SGD09/AA701/10SGD09AA708′]}) How can I drop character ‘/’ before character set ‘AA’ in pandas? code 0 10SGD35AA501/10SGD35AA599/10SGD36AA501/10SGD36AA599/10SGD37AA501/10SGD37AA527 1 10SGD08AA701/10SGD08AA704/10SGD09AA701/10SGD09AA708 I use str.replace: df[‘data’] = df[‘data’].str.replace(‘|(?=AA)’, ”, regex=True) This regex does not work. Where …

Total answers: 1

How can i import data from kaggle while not downloading it?

How can i import data from kaggle while not downloading it? Question: I want to import data from kaggle to my Notebook while not having to download it (So if i share my .ipynb u only need to run the code and it will download it from the internet), but i can’t figure out if …

Total answers: 1

How to fusion cells of a dataframe by summation

How to fusion cells of a dataframe by summation Question: I want to transform my dataframe by merging it cells and summing them into other larger cells given the indices of those, as an example, given the indices [0,2] & [2,4] on the X and Y axis and go from the following dataframe : +—-+—-+—-+—-+ …

Total answers: 3