0

Just wondering if there is a way to pass the other arguments than path for the pd.read_csv dynamically ?

filepath='c:\works\abcd.csv'
args = {"delimiter":"|","index_col":"None"}
df=pd.read_csv(filepath,args)

my requirement is to pass multiple parameters like that dynamically.

2
  • 1
    Are you familiar with *args and **kwargs? Commented Oct 22, 2021 at 14:46
  • pd.read_csv(**filepath,args)? Commented Oct 22, 2021 at 14:46

1 Answer 1

1

What does ** mean in pyhton

import pandas as pd
from io import StringIO

filepath="""1|2|3|4
A|B|C|D"""
args = {"delimiter": "|", "index_col": None}
df=pd.read_csv(StringIO(filepath), **args)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.