Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

list columns in pandas df

# Import pandas package 
import pandas as pd 
    
# making data frame 
data = pd.read_csv("nba.csv") 
    
# list(data) or
list(data.columns)
Comment

pandas dataframe lists as columns

In [8]: data = pd.DataFrame({'x': x, 'sin(x)': y})
In [9]: data
Out[9]: 
          x        sin(x)
0  0.000000  0.000000e+00
1  0.349066  3.420201e-01
2  0.698132  6.427876e-01
3  1.047198  8.660254e-01
4  1.396263  9.848078e-01
5  1.745329  9.848078e-01
6  2.094395  8.660254e-01
7  2.443461  6.427876e-01
8  2.792527  3.420201e-01
9  3.141593  1.224647e-16

[10 rows x 2 columns]
Comment

column of lists pandas

# new df from the column of lists
split_df = pd.DataFrame(df['Values'].tolist(), columns=['v1', 'v2', 'v3'])
# concat df and split_df
df = pd.concat([df, split_df], axis=1)
# display df
df
Comment

PREVIOUS NEXT
Code Example
Python :: python startswith method 
Python :: reshape 
Python :: @foreach 1 numper 
Python :: remove element from pack tkinter 
Python :: airflow schedule interval timezone 
Python :: split string by special characters python 
Python :: how to change series datatype from object to float 
Python :: create a flask app 
Python :: multiprocessing while applying a function in pandas 
Python :: django change id to uuid 
Python :: django pk 
Python :: python basics 
Python :: lru_cache 
Python :: python cron job virtualenv 
Python :: fetch image url discord py 
Python :: mean pandas 
Python :: Palindrome in Python Using while loop for string 
Python :: python coding practice 
Python :: shape 
Python :: flask windows auto reload 
Python :: python random.sample 
Python :: numpy arange 
Python :: do while python 
Python :: reverse range python 
Python :: drf serializer 
Python :: Example of ceil method in python 
Python :: keras model 2 outputs 
Python :: draw bipartite graph networkx 
Python :: how to perform group by with django orm 
Python :: python console 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =