Add index column wich is under a hierarchical index PANDAS/python

Advertisements I want set the col1 as Index. The dataframe is the result of a concatenation and I using keys for created hierarchical index import pandas as pd d = {‘col1’: [0, 1, 2, 3], ‘col2’: pd.Series([2, 3], index=[2, 3])} df = pd.DataFrame(data=d, index=[0, 1, 2, 3]) d2 = {‘col1’: [0, 1, 4, 3], ‘col2’:… Read More Add index column wich is under a hierarchical index PANDAS/python

R: Building phylogenetic tree from arbitrary features?

Advertisements StackExchange. I’m trying to build a phylogenetic tree for >100 individuals, using R. However, while tutorials for packages like APE and ggtree readily show how to do this using raw DNA or pre-sorted groupings (e.g. (((A,B),(C,D)),E)), my data takes the form of a list of machine-numbered tags assembled from all over the genome. For… Read More R: Building phylogenetic tree from arbitrary features?

How to create hiearchical multi-index dataframe from multiple dataframes?

Advertisements I have multiple dataframes with identical shape, say: d1 = {‘time’: [1,2,3,4], ‘A’: [55.5,55.5,55.5,55.5], ‘B’:[55.5,55.5,55.5,55.5]} d2 = {‘time’: [1,2,3,4], ‘A’: [7,6,5,4], ‘B’:[9,8,7,6]} d3 = {‘time’: [1,2,3,4], ‘A’: [1,2,3,4], ‘B’:[2,3,4,5]} df1 = pd.DataFrame(data = d1) df2 = pd.DataFrame(data = d2) df3 = pd.DataFrame(data = d3) They will always have the same column names and the… Read More How to create hiearchical multi-index dataframe from multiple dataframes?

How to create a multiIndex (hierarchical index) dataframe object from another df's column's unique values?

Advertisements I’m trying to create a pandas multiIndexed dataframe that is a summary of the unique values in each column. Is there an easier way to have this information summarized besides creating this dataframe? Either way, it would be nice to know how to complete this code challenge. Thanks for your help! Here is the… Read More How to create a multiIndex (hierarchical index) dataframe object from another df's column's unique values?