Question
In Python Write function to create a Pandas DataFrame, 'Employee', whose columns are 'Name', 'Year' and 'Department'. The function should extract the data from the
In Python Write function to create a Pandas DataFrame, 'Employee', whose columns are 'Name', 'Year' and 'Department'. The function should extract the data from the following text:
txt=" - Bob has been working for IT department for 1 year. - Sam has been working for Trade department for 3 years. ........ ........ - Jerilyn has been working for HR department for 8 years. - Elois has been working for IT department for 2 years. - Matha has been working for Trade department for 2 years."
Hint: Try to use str.split and list comprehension. import pandas as pd txt='''- Bob has been working for IT department for 1 year. - Sam has been working for Trade department for 3 years. - Peter has been working for HR department for 8 years. - Mike has been working for IT department for 2 years. - Sarah has been working for Trade department for 2 years. - Sali has been working for IT department for 7 years. - Tim has been working for IT department for 12 years. - Maya has been working for HR department for 10 years. - Susan has been working for IT department for 7 years. - Kati has been working for IT department for 11 years. - Robert has been working for Trade department for 9 years. - Shahd has been working for Trade department for 2 years. - Ema has been working for IT department for 7 years. - Hala has been working for HR department for 12 years. - Joe has been working for HR department for 18 years. - Ali has been working for HR department for 4 years. - Nader has been working for IT department for 15 years. - Kim has been working for Trade department for 5 years. - Bilal has been working for Trade department for 2 years. - Albert has been working for IT department for 7 years. - Hind has been working for Trade department for 12 years. - Alberto has been working for HR department for 10 years. - Yashar has been working for HR department for 4 years. - Kumar has been working for Trade department for 13 years. - Taha has been working for Trade department for 5 years. - Damon has been working for HR department for 12 years. - Brandon has been working for HR department for 18 years. - Ali has been working for HR department for 4 years. - Jaclyn has been working for IT department for 15 years. - Vita has been working for Trade department for 5 years. - Lisa has been working for Trade department for 2 years. - Alice has been working for IT department for 3 years. - Lyndsey has been working for HR department for 12 years. - Samanth has been working for HR department for 10 years. - Roula has been working for HR department for 14 years. - Georgene has been working for Trade department for 11 years. - Reem has been working for HR department for 15 years. - Jerilyn has been working for HR department for 8 years. - Elois has been working for IT department for 2 years. - Matha has been working for Trade department for 2 years.'''
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started