Answers for "pandas example dataframe"

10

create dataframe panndas

import pandas as pd

data = {'First Column Name':  ['First value', 'Second value',...],
        'Second Column Name': ['First value', 'Second value',...],
         ....
        }

df = pd.DataFrame (data, columns = ['First Column Name','Second Column Name',...])

print (df)
Posted by: Guest on July-12-2020
0

pandas create sample dataframe

>>> import pandas as pd
>>> sentence = 'The quick brown fox jumps over a lazy dog.'
>>> words = sentence.split(' ')
>>> df1 = pd.DataFrame({'key': range(len(words)),
...                     'column1_Words': words,
...                     'column2_Length': [len(x) for x in words]
...                     })
>>> df1
   key column1_Words  column2_Length
0    0           The               3
1    1         quick               5
2    2         brown               5
3    3           fox               3
4    4         jumps               5
5    5          over               4
6    6             a               1
7    7          lazy               4
8    8          dog.               4
>>>
Posted by: Guest on November-10-2020

Code answers related to "pandas example dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language