Differences between revisions 2 and 3
Revision 2 as of 2020-04-08 15:53:19
Size: 641
Editor: Burathar
Comment:
Revision 3 as of 2020-04-08 16:01:34
Size: 1021
Editor: Burathar
Comment:
Deletions are marked like this. Additions are marked like this.
Line 22: Line 22:
import pandas as pd df = pd.read_csv(path + 'name.csv', sep=';', header=0, dtype={'Force String Column': str},
                 parse_dates=['Date Column'] encoding='utf-8')
Line 25: Line 26:
== Renaming Columns ==
Line 26: Line 29:
import numpy as np
df = pd.read_csv(path + 'name.csv', sep=';', header=0, dtype={'Force String Column': str}, parse_dates=['Date Column'] encoding='utf-8')
}}}
dt.rename(columns={'File column name 1': 'Column1', 'File column name 2': '2'}, inplace=True)
}}

== Do Y for each value in column X ==

{{{#!highlight python
df.loc[:, ['X']] = df.loc[:, ['X']].apply(lambda x: x.Y)
}}



== Renaming Columns ==

{{{#!highlight python
dt.rename(columns={'File column name 1': 'Column1', 'File column name 2': '2'}, inplace=True)
}}

Description

Pandas is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool, built on top of the Python programming language.

Snippets

Standard import

   1 import numpy as np
   2 import pandas as pd

Read CSV file

   1 path = '/path/to/file(s)'
   2 df = pd.read_csv(path + 'name.csv', sep=';', header=0, dtype={'Force String Column': str}, 
   3                  parse_dates=['Date Column'] encoding='utf-8')

Renaming Columns

Howto/Python3/pandas (last edited 2020-04-08 17:13:18 by Burathar)